-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: support l2 plus #1157
feat: support l2 plus #1157
Conversation
7696425
to
463ee74
Compare
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.
Some minor comments.
@karlem Another question I have is regarding nonce. Say a bottom up message is created in L3, the nonce will be set by the local network. Then in L2, will the cross network message nonce change? If so, then the id ( |
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.
Some initial comments.
Hmm that's a good point. I will think about how to mitigate this. |
0d896a7
to
ff75e79
Compare
@cryptoAtwill should be ready for another review :) |
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.
LGTM. But I do have a few follow up questions though:
- Does it work in calibration with a live 3 level network? Is there a testnet we can try or planned?
propagateAll
is called in the parent as part of bottom up checkpoint. Bottom up checkpoint is already quite gas costly, not sure if this will burst the gas even more.
@@ -131,6 +135,22 @@ library CrossMsgHelper { | |||
return keccak256(abi.encode(crossMsg)); | |||
} | |||
|
|||
/// @notice Returns a deterministic hash for the given cross message. The hash remains the same accross different networks | |||
/// because it doesn't include the network-specific nonce. | |||
function toDeterministicHash(IpcEnvelope memory crossMsg) internal pure returns (bytes32) { |
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.
I guess most of the time this is ok, but will this cause conflict if say someone sends the same message twice?
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.
It might collide, but it is only for logging so it should not matter.
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.
Hm, this is not great; I'd rather have the protocol generate a message ID at origin and propagate that even inside the IpcEnvelope, even if it costs a few little more gas for the extra bytes.
Also, if this is only used for tracing, it's best to signal that by calling this method: toTracingId
?
It should. Whether is Calibration or not.
We don't really have any other option here. I don't think we really optimise for gas efficiency at this stage. Moving forward we might re-write the contracts L2+ as native actors to make it cheaper. |
e28e275
to
ff75e79
Compare
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.
I think this is no longer correct: https://github.com/consensus-shipyard/ipc/pull/1157/files#diff-71559bfe927afaf1a3980c01ffe9f4d15c77d58650b2d850bbae821de9c009d0R49.
This implicitly assumes the token behind envelop.value
is the native token in the origin subnet. If say I want to trigger transfer from address A to address B in L1 and I'm sending from L3, why should I attach that amount in msg.value
?
It comes back to the definition of envelop.value
, is it just the native token transfer in the target subnet. If this is the case, it does not make sense to have this check.
a7c17ee
to
e514fdb
Compare
@cryptoAtwill The issue was resolved by not using or supporting native token transfers in the Call message. |
17344aa
to
28209f8
Compare
This looks good to me. Just one more thing regarding the tests, shall we also add nonce check to bottom up, just make sure it's correct? |
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.
Some initial feedback. Removing the ability to send value in calls is a no-go. See inline comments for more context. It will be very common for subnets denominated in the same asset to want to interact with one another sending value and calling some logic in an atomic manner.
@karlem can you please detail the rationale for having removed this? Was it due to the risk of supply source mismatches across the hierarchy during a multi-hop? We had logic to prevent this here:
ipc/contracts/contracts/lib/LibGateway.sol
Lines 499 to 513 in 4243ff9
if (applyType == IPCMsgType.BottomUp) { | |
// We're traversing up, so if we're the first hop, we reject if the subnet was ERC20. | |
// If we're not the first hop, a child propagated this to us, they made a mistake and | |
// and we don't have enough info to evaluate. | |
reject = from.getParentSubnet().equals(s.networkName) && from.getActor().hasSupplyOfKind(AssetKind.ERC20); | |
} else if (applyType == IPCMsgType.TopDown) { | |
// We're traversing down. | |
// Check the next subnet (which can may be the destination subnet). | |
reject = to.down(s.networkName).getActor().hasSupplyOfKind(AssetKind.ERC20); | |
} | |
if (reject) { | |
if (crossMessage.kind == IpcMsgKind.Transfer) { | |
revert MethodNotAllowed("propagation of `Transfer` messages not suppported for subnets with ERC20 supply"); | |
} | |
} |
So curious to hear why that was insufficient, or why strengthening the validation to detect supply source mismatches was a no-go?
@@ -131,6 +135,22 @@ library CrossMsgHelper { | |||
return keccak256(abi.encode(crossMsg)); | |||
} | |||
|
|||
/// @notice Returns a deterministic hash for the given cross message. The hash remains the same accross different networks | |||
/// because it doesn't include the network-specific nonce. | |||
function toDeterministicHash(IpcEnvelope memory crossMsg) internal pure returns (bytes32) { |
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.
Hm, this is not great; I'd rather have the protocol generate a message ID at origin and propagate that even inside the IpcEnvelope, even if it costs a few little more gas for the extra bytes.
Also, if this is only used for tracing, it's best to signal that by calling this method: toTracingId
?
Co-authored-by: Karel Moravec <[email protected]> Co-authored-by: cryptoAtwill <[email protected]>
Co-authored-by: cryptoAtwill <[email protected]>
c3aea65
to
fab6ae5
Compare
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.
@karlem this seems like it's close to a merge. Any outstanding changes? My only nit is that now what we've introduced the "original nonce", we should consider renaming the nonce localNonce
to disambiguate. WDYT?
Part of #1080
This PR focuses on:
Integration Tests in Solidity (L3-Level Testing)
Improvements
CheckpointCommitted
NewBottomUpMessage
MessageStoredInPostbox
MessagePropagatedFromPostbox
TODOs