-
Notifications
You must be signed in to change notification settings - Fork 75
fix(hub-pool): Enable data worker to ensure that roots are not redundantly relayed to SpokePools #85
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
Conversation
chrismaree
left a comment
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 once the nits are resolved.
Co-authored-by: Chris Maree <christopher.maree@gmail.com>
Co-authored-by: Chris Maree <christopher.maree@gmail.com>
…ocol/contracts-v2 into npai/redundant-relay
contracts/HubPool.sol
Outdated
| int256[] memory netSendAmounts, | ||
| int256[] memory runningBalances, | ||
| uint8 leafId, | ||
| bool relayToSpokePool, |
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.
What was the reasoning for using a bool over an index? Would something like perChainLeafIndex be more clear to someone creating a bundle?
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 just don't see any utility for the index. If you could give me an example of how an index would be useful to the off-chain data worker, then I'd change to an index. But I can't think of any examples where the index is useful.
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 it's just easier to understand since an index obviously increments for each leaf for a chain. Whereas you have to know that this bool goes true on the first element and then false on every following element. I think the bool makes a lot of sense in the context of the HubPool, but to a relayer, this bool might have less meaning since they aren't working from within the HubPool's send logic. Maybe to reverse the question, what's the reasoning for using a bool over an index?
Not strongly opinionated on this, however. I'm cool with whatever you think!
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.
bool saves calldata gas right? thats the main reasoning
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 would not. See the first example here: https://docs.soliditylang.org/en/v0.8.11/abi-spec.html#examples. All smaller types are padded to 32 bytes in normal abi encoding (which is what we're using here and elsewhere). It's only in packed encoding (and in storage) that they are not padded.
Ironically, an index (or inverted bool) actually saves gas. This is because a nonzero byte costs 4x as much gas as a 0 byte. Since usually the index would be 0, this would result in all 0 bytes as opposed to the case where the bool is set to true and one of the bytes would be nonzero. This is a very small difference, though.
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 ok i'll change to an index since it doesn't seem to matter too much and it gives us a bit more flexibility
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.
Ok changed @mrice32 but I don't love the name groupIndex nor the perChainleafIndex. Any other ideas?
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.
Yeah, the naming is difficult. I think groupIndex is totally fine, though, especially since you documented it so well.
mrice32
left a comment
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.
mrice32
left a comment
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.
mrice32
left a comment
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!
Data worker can mark in
PoolRebalanceLeafwhether it should send roots to theSpokePool. We assume that valid root bundles would only send roots to a SpokePool on a specificchainIdonce.