-
Notifications
You must be signed in to change notification settings - Fork 38
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
evm: per chain transceivers #517
evm: per chain transceivers #517
Conversation
54ec5cd
to
964a4de
Compare
e442b2d
to
6f7cfc4
Compare
Contract sizes before this feature:
Contract sizes with this feature:
|
1270075
to
6eebeda
Compare
That would require them to set the per-chain threshold before enabling anything, right? Is that acceptable? |
I was thinking we could write |
5aa1e47
to
e6a1aca
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 will continue looking a bit into the test files, but wanted to submit the comments so far.
We've decided to not support falling back to the global defaults, and also switch to functions to get / set the bitmaps per chain, rather than doing enable/disable. I'm converting this back to draft while I do the rework. |
ff98457
to
b936d9c
Compare
b936d9c
to
a1fba4a
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.
- Should
setThreshold
be overridden and revert? - More generally to the above bullet point, we should try to minimise unintended side effects of enabling/disabling transceivers globally/per-chain and also setting global/per-chain thresholds (global thresholds appear to be unused now, but worth being explicit)
a3f7772
to
dd0400d
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.
Overall looks pretty solid this way. Just a few nits and questions from my side.
/// @notice The structure of a per-chain entry in the call to setTransceiversForChains. | ||
struct SetTransceiversForChainEntry { | ||
uint64 sendBitmap; | ||
uint64 recvBitmap; |
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.
Genera question regarding this 64 transceiver limit: as more and more chains pop-up and are added to WH, will 64 bits be sufficient in the future?
function _isSendTransceiverEnabledForChain( | ||
address transceiver, | ||
uint16 forChainId | ||
) internal view override returns (bool) { | ||
uint64 bitmap = _getPerChainTransceiverBitmap(forChainId, SEND_TRANSCEIVER_BITMAP_SLOT); | ||
uint8 index = _getTransceiverInfosStorage()[transceiver].index; | ||
return (bitmap & uint64(1 << index)) != 0; | ||
return (bitmap & uint64(1 << index)) > 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.
Why this small change here?
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 me! !=
needs 2 opcodes vs >
just needs 1, so we save (a small amount of) gas here. Plus it matches how we do it elsewhere in the codebase
uint64 enabledTransceiverBitmap = _getEnabledTransceiversBitmap(); | ||
uint64 enabledTransceiversForChain = | ||
_getEnabledRecvTransceiversForChain(attInfo.sourceChainId); | ||
return attInfo.attestedTransceivers & enabledTransceiverBitmap & enabledTransceiversForChain; |
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 _checkTransceiversInvariants()
ensures that you can't remove a transceiver globally, when it's enabled for a chain. Therefore enabledTransceiversForChain
is a subset of enabledTransceiverBitmap
.
function _checkTransceiversInvariants() internal view override { | ||
super._checkTransceiversInvariants(); | ||
_validateTransceivers(SEND_ENABLED_CHAINS_SLOT, SEND_TRANSCEIVER_BITMAP_SLOT); | ||
_validateTransceivers(RECV_ENABLED_CHAINS_SLOT, RECV_TRANSCEIVER_BITMAP_SLOT); |
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 _checkTransceiversInvariants()
seems quite heavy. Would it be worth doing an analysis at how many chains and how many transceivers per chain do the calling functions hit the block gas limit?
|
||
// Can't enable transceiver for an unknown address. | ||
// Can't globally remove a transceiver when it's enabled for a chain. |
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.
Love this test.
The `NttManagerWithPerChainTransceivers` contract which inherits from `NttManagerNoRateLimiting` and allows configuring different transceivers and thresholds for each chain. | ||
You can configure a different set of send and receive transceivers for each chain. If you don't specifically enable any transceivers for a chain, then all transceivers will be used. | ||
The `NttManagerWithPerChainTransceivers` contract inherits from `NttManagerNoRateLimiting` and allows configuring different transceivers and thresholds for each chain. | ||
You can configure a different set of send and receive transceivers for each chain, as well as the receive threshold for the chain. |
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.
Something that might be worth adding to the README.md:
Even when only using per chain transceivers, one needs to register each transceiver using the setTransceiver()
method inherited from ManagerBase
. Note that this only allows registering up to 64 transceivers in total (to be used as send and/or receive transceivers).
Closing this PR given the following:
Therefore, despite the much appreciated effort and reviews, I do not recommend proceeding. |
This PR implements the
NttManagerWithPerChainTransceivers
contract which inherits fromNttManagerNoRateLimiting
and allows configuring different transceivers and thresholds for each chain. You can configure a different set of send and receive transceivers for each chain. If you don't specifically enable any transceivers for a chain, then all transceivers will be used.This new contract has to inherit from the no-rate-limiting due to the contract size limit.