-
Notifications
You must be signed in to change notification settings - Fork 54
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: rateLimiterConfig mapping of localToRemoteTokens to take bytes instead of bytes32 #1207
feat: rateLimiterConfig mapping of localToRemoteTokens to take bytes instead of bytes32 #1207
Conversation
…ted to take bytes instead of bytes32
LCOV of commit
|
…d its internal function usage
@@ -482,14 +482,14 @@ contract MultiAggregateRateLimiter_updateRateLimitTokens is MultiAggregateRateLi | |||
remoteChainSelector: CHAIN_SELECTOR_1, | |||
localToken: s_destTokens[0] | |||
}), | |||
remoteToken: bytes32(bytes20(s_sourceTokens[0])) | |||
remoteToken: abi.encodePacked(s_sourceTokens[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.
issue: we use abi.encode
for addresses -> bytes conversion instead of encodePacked
- e.g. see https://github.com/smartcontractkit/ccip/blob/ccip-develop/contracts/src/v0.8/ccip/onRamp/EVM2EVMOnRamp.sol#L371
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.
updated
contracts/src/v0.8/shared/enumerable/EnumerableMapAddresses.sol
Outdated
Show resolved
Hide resolved
@@ -1,12 +1,15 @@ | |||
// SPDX-License-Identifier: MIT |
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 cherry-pick the commit from chainlink to make this lib in sync:
- Add
chainlink
remote via:git remote add
git cherry-pick <commit-id>
This looks like it's missing the src/v0.8/shared/test/enumerable
files
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.
updated
contracts/src/v0.8/ccip/test/rateLimiter/MultiAggregateRateLimiter.t.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/test/rateLimiter/MultiAggregateRateLimiter.t.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/test/rateLimiter/MultiAggregateRateLimiter.t.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/test/rateLimiter/MultiAggregateRateLimiter.t.sol
Outdated
Show resolved
Hide resolved
@@ -918,7 +915,7 @@ contract MultiAggregateRateLimiter_onOutboundMessage is MultiAggregateRateLimite | |||
remoteChainSelector: CHAIN_SELECTOR_1, | |||
localToken: s_sourceTokens[i] | |||
}), | |||
remoteToken: bytes32(bytes20(s_destTokenBySourceToken[s_sourceTokens[i]])) | |||
remoteToken: abi.encodePacked(bytes20(s_destTokenBySourceToken[s_sourceTokens[i]])) |
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.
remoteToken: abi.encodePacked(bytes20(s_destTokenBySourceToken[s_sourceTokens[i]])) | |
remoteToken: abi.encode(bytes20(s_destTokenBySourceToken[s_sourceTokens[i]])) |
contracts/src/v0.8/ccip/test/rateLimiter/MultiAggregateRateLimiter.t.sol
Outdated
Show resolved
Hide resolved
contracts/src/v0.8/ccip/test/rateLimiter/MultiAggregateRateLimiter.t.sol
Outdated
Show resolved
Hide resolved
8d916f8
to
1ddb158
Compare
* feat: CCIP-2465 enumerableMap for addressToBytes Mapping * fix: CCIP-2465 prettier write for new library contracts * fix: CCIP-2465 gas-snapshot updated and changeset added for new library * fix: CCIP-2465 gassnapshot corrections for EnumerableAddresses
Quality Gate passedIssues Measures |
import {EnumerableMap} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/structs/EnumerableMap.sol"; | ||
import {EnumerableMapBytes32} from "./EnumerableMapBytes32.sol"; |
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.
nit: probably not for this PR but now that we have OZ v5 we might want to update 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.
got it will add a note for this one
…instead of bytes32 (#1207) rateLimiterConfig mapping of localToRemoteTokens to take bytes instead of bytes32 - In the MultiAggregateRateLimiter contract, the the following mapping might be simplifiable to - (uint64 remoteChainSelector -> address token) , - since it is only used as an isEnabled check (i.e. the (address token -> bytes32 remoteToken) is never used on-chain) - mapping being necessary off-chain, we need to convert the (address -> bytes32) mapping to (address -> bytes) to be consistent with using bytes for all family-agnostic addresses ```js mapping(uint64 remoteChainSelector => EnumerableMapAddresses.AddressToBytes32Map tokensLocalToRemote) internal s_rateLimitedTokensLocalToRemote; ``` this has to been changed to ```js mapping(uint64 remoteChainSelector => EnumerableMapAddresses.AddressToBytesMap tokensLocalToRemote) internal s_rateLimitedTokensLocalToRemote; ``` 1. New solidity library `EnumerableMapBytes32` which contains `Bytes32ToBytes` Mapping and enumerate it 2. `EnumerableMapAddresses.sol` library has added support for the new library cherrypicked from chainlink repo `EnumerableMapBytes32` 3. `MultiAggregateRateLimiter` with mapping for remoteSelector -> localTokenAddress -> remoteTokenAddress is updated to contain remoteTokenAddress as `bytes` instead of `bytes32` --------- Co-authored-by: app-token-issuer-infra-releng[bot] <120227048+app-token-issuer-infra-releng[bot]@users.noreply.github.com>
Description:
rateLimiterConfig mapping of localToRemoteTokens to take bytes instead of bytes32
Details
this has to been changed to
Change List:
EnumerableMapBytes32
which containsBytes32ToBytes
Mapping and enumerate itEnumerableMapAddresses.sol
library has added support for the new library cherrypicked from chainlink repoEnumerableMapBytes32
MultiAggregateRateLimiter
with mapping for remoteSelector -> localTokenAddress -> remoteTokenAddress is updated to contain remoteTokenAddress asbytes
instead ofbytes32