From 116aa90d170af9f64658263aee7ea58f9e67e6c6 Mon Sep 17 00:00:00 2001 From: Daniel Beal Date: Sun, 1 Oct 2023 20:55:30 +0900 Subject: [PATCH] fix need to have selectors --- protocol/synthetix/cannonfile.test.toml | 11 +++++++++++ protocol/synthetix/cannonfile.toml | 18 ++++++++++++++++++ .../modules/core/CrossChainPoolModule.sol | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/protocol/synthetix/cannonfile.test.toml b/protocol/synthetix/cannonfile.test.toml index da992a1b1c..505ba2b721 100644 --- a/protocol/synthetix/cannonfile.test.toml +++ b/protocol/synthetix/cannonfile.test.toml @@ -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" diff --git a/protocol/synthetix/cannonfile.toml b/protocol/synthetix/cannonfile.toml index 21b7701da7..2a72b7c3b5 100644 --- a/protocol/synthetix/cannonfile.toml +++ b/protocol/synthetix/cannonfile.toml @@ -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" diff --git a/protocol/synthetix/contracts/modules/core/CrossChainPoolModule.sol b/protocol/synthetix/contracts/modules/core/CrossChainPoolModule.sol index 783b07e71e..d795142177 100644 --- a/protocol/synthetix/contracts/modules/core/CrossChainPoolModule.sol +++ b/protocol/synthetix/contracts/modules/core/CrossChainPoolModule.sol @@ -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);