Skip to content

Commit

Permalink
fix need to have selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeal-eth committed Oct 1, 2023
1 parent 6613846 commit 116aa90
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
11 changes: 11 additions & 0 deletions protocol/synthetix/cannonfile.test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ args = [
]
]

[invoke.set_cross_chain_selectors_dummy]
target = ["CoreProxy"]
fromCall.func = "owner"
func = "multicall"
args = [
[
# for all the below functions, the selector is for "setConfig(bytes32,bytes32)"
"0xd1fd27b3<%= defaultAbiCoder.encode(['bytes32', 'bytes32'], [keccak256(defaultAbiCoder.encode(['bytes32', 'bytes4'], [formatBytes32String('crossChainWriteSelector'), '0xea7a2248'])), formatBytes32String('TRUE')]).slice(2) %>",
]
]

# cross chain wormhole
[import.wormhole]
source = "erc7412-wormhole:latest"
Expand Down
18 changes: 18 additions & 0 deletions protocol/synthetix/cannonfile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,24 @@ args = [
]
]

[invoke.set_cross_chain_selectors]
target = ["CoreProxy"]
fromCall.func = "owner"
func = "multicall"
args = [
[
# for all the below functions, the selector is for "setConfig(bytes32,bytes32)"
# wormhole
"0xd1fd27b3<%= defaultAbiCoder.encode(['bytes32', 'bytes32'], [keccak256(defaultAbiCoder.encode(['bytes32', 'bytes4'], [formatBytes32String('crossChainReadSelector'), '0x2a5f0c62'])), formatBytes32String('TRUE')]).slice(2) %>",
# chainlink
"0xd1fd27b3<%= defaultAbiCoder.encode(['bytes32', 'bytes32'], [keccak256(defaultAbiCoder.encode(['bytes32', 'bytes4'], [formatBytes32String('crossChainReadSelector'), '0x00000000'])), formatBytes32String('TRUE')]).slice(2) %>",
# wormhole
"0xd1fd27b3<%= defaultAbiCoder.encode(['bytes32', 'bytes32'], [keccak256(defaultAbiCoder.encode(['bytes32', 'bytes4'], [formatBytes32String('crossChainWriteSelector'), '0x46948b9b'])), formatBytes32String('TRUE')]).slice(2) %>",
# chainlink
"0xd1fd27b3<%= defaultAbiCoder.encode(['bytes32', 'bytes32'], [keccak256(defaultAbiCoder.encode(['bytes32', 'bytes4'], [formatBytes32String('crossChainWriteSelector'), '0x00000000'])), formatBytes32String('TRUE')]).slice(2) %>",
]
]

[invoke.register_const_one_oracle]
target = ["oracle_manager.Proxy"]
func = "registerNode"
Expand Down
19 changes: 19 additions & 0 deletions protocol/synthetix/contracts/modules/core/CrossChainPoolModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ contract CrossChainPoolModule is ICrossChainPoolModule {
) external override {
FeatureFlag.ensureAccessToFeature(_SET_CROSS_CHAIN_SELECTORS);

// selectors must be valid
if (
Config.readUint(
keccak256(abi.encode(bytes32("crossChainReadSelector"), readSelector)),
0
) == 0
) {
revert ParameterError.InvalidParameter("readSelector", "must be permitted");
}

if (
Config.readUint(
keccak256(abi.encode(bytes32("crossChainWriteSelector"), writeSelector)),
0
) == 0
) {
revert ParameterError.InvalidParameter("writeSelector", "must be permitted");
}

Pool.Data storage pool = Pool.loadExisting(poolId);
Pool.onlyPoolOwner(poolId, msg.sender);

Expand Down

0 comments on commit 116aa90

Please sign in to comment.