-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LM Optimism L1 to L2 bridge interface #840
base: ccip-develop
Are you sure you want to change the base?
Add LM Optimism L1 to L2 bridge interface #840
Conversation
100cd3b
to
510e7af
Compare
LCOV of commit
|
510e7af
to
d14abd3
Compare
d14abd3
to
4ee8b91
Compare
// TODO: what if a rebalance is triggered at T=0, the sent log is emitted at t=1 | ||
// and the DepositFinalized log is emitted at T=2, and our query goes back to T=2. There will be | ||
// 1 DepositFinalized log and 0 sent logs. Maybe drop this condition and just do the matching |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @makramkd , we chatted about this in one of our meetings, I'll probably tackle this when I work on the arbitrum side of things
// TODO: these index values might need to be updated when Ryan makes changes to the LM contract and event fields | ||
// LiquidityTransferredToChainSelectorTopicIndex is the index of the topic in the LiquidityTransferred event | ||
// that contains the "to" chain selector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @RyanRHall , these are the indices that might change once we update the contract events and may impact the log poller queries
ERC20BridgeFinalizedTopic = optimism_standard_bridge.OptimismStandardBridgeERC20BridgeFinalized{}.Topic() | ||
|
||
// Optimism contract addresses: https://docs.optimism.io/chain/addresses | ||
// TODO: confirm that we're able to use these L1 proxy addresses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@makramkd or @RyanRHall do you know how often these proxy addresses change? Can we use these hardcoded proxy addresses in log poller queries reliably, or do they need to be fetched programmatically?
l1FilterName := fmt.Sprintf("OptimismL1ToL2Bridge-L1-LiquidityManager:%s-Local:%s-Remote:%s", | ||
l1LiquidityManagerAddress.String(), localChain.Name, remoteChain.Name) | ||
|
||
// TODO: FIXME pass valid context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amirylm what's the correct way to pass a context down into these bridge interfaces? I see this TODO FIXME
inside the arbitrum bridges as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should accept a context arg in this function, that should be passed all the way from NewBridge()
which currently doesn't accept a context but it should.
You can also create a ticket for fixing contexts cross the liquidity manager instead of fixing it in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created LM-116
ctx context.Context, | ||
transfer models.Transfer, | ||
) ([]byte, *big.Int, error) { | ||
// TODO: maybe add check if this is a native transfer or ERC20 transfer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're only transferring ERC20s (WETH) for now right?
// TODO: Applying the 1.2x gas limit bump here to the fee won't really have an effect on the actual gas burned by | ||
// the OP bridge since the gas units are hardcoded to 1e6 in services/relay/evm/liquidity_manager.go. We should | ||
// instead consider a better way to dynamically bump the gas used by the transmitter, or just hardcode an even | ||
// higher gas limit in the transmitter. The OP team has confirmed that only gas up to the "market rate" will be | ||
// burned, not all gas remaining in the limit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @amirylm and @RyanRHall
return nil, errors.New("no transfer nonces found in bridge payloads") | ||
} | ||
|
||
// TODO: reconfirm that all nonces should be the same across all payloads in a given round for OP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @makramkd you said this should hold true, but I wanted to reconfirm, otherwise this QuorumizedBridgePayload()
function gets a little wonky since the bridgeReturnData
/nonce should be unique for a given transfer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @amirylm
4ee8b91
to
d8a8145
Compare
d8a8145
to
17e53fe
Compare
for _, pendingTransfer := range pendingTransfers { | ||
unexecuted = append(unexecuted, pendingTransfer) | ||
} | ||
unexecuted := make([]liquidityrebalancer.UnexecutedTransfer, 0, len(resolvedTransfersQuorum)+len(inflightTransfers)+len(pendingTransfers)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was just a nit, felt like resolved --> inflight --> pending better represented the chronological ordering/stages that the transfers go through
dd16a1b
to
8e0e3d2
Compare
log.Fatalf("Failed to pack depositETHTo function call: %v", err) | ||
} | ||
|
||
// Estimate gas needed for the depositETHTo call issued from the L1 Bridge Adapter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update comment
This PR adds the Optimism bridge interface for L1 to L2 transfers. Some important things to note:
sendERC20
is called. This nonce is included in multiple events throughout the transfer's lifecycle and is how we "match" and link events together to confirm they've reached the various states.GetTransfers()
function makes use of this nonce and implements the matching logic to link these 3 events together and partition transfers into categories:LiquidityTransferred.bridgeReturnData
, which should equalERC20BridgeFinalized.extraData
which should equalLiquidityTransferred.bridgeSpecificData
TODO: Applying the 1.2x gas...
comment on how we should think about adjusting the gas limit appropriately to account for how OP's native bridge dynamically burns gas