-
Notifications
You must be signed in to change notification settings - Fork 39
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
base: main
Are you sure you want to change the base?
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.
function down(SubnetID calldata subnet1, SubnetID calldata subnet2) public pure returns (SubnetID memory) { | ||
if (subnet1.root != subnet2.root) { | ||
revert DifferentRootNetwork(); | ||
return SubnetID({root: 0, route: new address[](0)}); |
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.
is there a reason why it's not reverted? Feels like it's an error that should be handled instead of introducing root = 0
as invalid subnet. Probably in some use cases root: 0, route: []
is a valid use case.
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.
Sounds like this needs multi-return? SubnetID + bool?
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.
The problem here is that if I revert, I lose control elsewhere. The method is also used invalidateCrossMessage
, where reverting is not desirable. Additionally, commonParent
method here returns the empty subnet ID instead of reverting. But I understand your point—if this were deployed on Ethereum, the root could be zero. Would returning a boolean (indicating whether it was found or not) help?
@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.
IPCAddress({ | ||
subnetId: gatewayDiamond.getter().getNetworkName().getParentSubnet(), | ||
rawAddress: FvmAddressHelper.from(receipient) | ||
}), | ||
IPCAddress({subnetId: id, rawAddress: FvmAddressHelper.from(address(this))}), |
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.
Why?
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.
Because it was labeled as a top-down message, but the path (from, to) made it a bottom-up message, the test was incorrect. Since we now have checks ensuring that top-down messages are indeed top-down (as a parent can't send a message to itself), this would cause a revert.
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.
/// `Call` cross-messages also trigger receipts if they are successful. | ||
/// @param arrivingFrom - the immediate subnet from which this message is arriving | ||
/// @param crossMsg - the cross message to be executed | ||
/// @param expectTopDownOnly - whether the message should be top-down only. Reverts if it is not. |
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 I was misled by the comment here. The idea is whether the message should be top-down only. Reverts if this flag is true but the crossmsg is actually bottom up
?
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.
Reverts if it's both - not only top down :)
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. |
Part of #1080
This PR focuses on:
Integration Tests in Solidity (L3-Level Testing)
Improvements
CheckpointCommitted
NewBottomUpMessage
MessageStoredInPostbox
MessagePropagatedFromPostbox