From b0ef005a5963a505fe9aac1646fea1cd0242084b Mon Sep 17 00:00:00 2001 From: Akash Date: Tue, 19 Sep 2023 15:24:08 +0530 Subject: [PATCH 1/5] feat:added seal, getProposalCounts in batcher --- contracts/interfaces/ISocket.sol | 10 +++ contracts/socket/SocketBatcher.sol | 100 +++++++++++++++++++++++++---- test/socket/SocketBatcher.t.sol | 2 + 3 files changed, 100 insertions(+), 12 deletions(-) diff --git a/contracts/interfaces/ISocket.sol b/contracts/interfaces/ISocket.sol index 5a8314a4..493fa695 100644 --- a/contracts/interfaces/ISocket.sol +++ b/contracts/interfaces/ISocket.sol @@ -189,6 +189,16 @@ interface ISocket { address switchboard_ ) external view returns (bytes32); + + /** + * @notice Retrieves the latest proposalCount for a packet id. + * @return The proposal count for the specified packet id. + */ + function proposalCount( + bytes32 packetId_ + ) external view returns (uint256); + + /** * @notice Retrieves the minimum fees required for a message with a specified gas limit and destination chain. * @param minMsgGasLimit_ The gas limit of the message. diff --git a/contracts/socket/SocketBatcher.sol b/contracts/socket/SocketBatcher.sol index d226b12c..dc7b3d6a 100644 --- a/contracts/socket/SocketBatcher.sol +++ b/contracts/socket/SocketBatcher.sol @@ -259,10 +259,10 @@ contract SocketBatcher is AccessControl { * @param socketAddress_ address of socket * @param sealRequests_ the list of requests with packets to be sealed on sourceChain */ - function sealBatch( + function _sealBatch( address socketAddress_, SealRequest[] calldata sealRequests_ - ) external { + ) internal { uint256 sealRequestLength = sealRequests_.length; for (uint256 index = 0; index < sealRequestLength; ) { ISocket(socketAddress_).seal( @@ -276,15 +276,27 @@ contract SocketBatcher is AccessControl { } } + /** + * @notice seal a batch of packets from capacitor on sourceChain mentioned in sealRequests + * @param socketAddress_ address of socket + * @param sealRequests_ the list of requests with packets to be sealed on sourceChain + */ + function sealBatch( + address socketAddress_, + SealRequest[] calldata sealRequests_ + ) external { + _sealBatch(socketAddress_, sealRequests_); + } + /** * @notice propose a batch of packets sequentially by socketDestination * @param socketAddress_ address of socket * @param proposeRequests_ the list of requests with packets to be proposed by socketDestination */ - function proposeBatch( + function _proposeBatch( address socketAddress_, ProposeRequest[] calldata proposeRequests_ - ) public { + ) internal { uint256 proposeRequestLength = proposeRequests_.length; for (uint256 index = 0; index < proposeRequestLength; ) { ISocket(socketAddress_).proposeForSwitchboard( @@ -299,15 +311,27 @@ contract SocketBatcher is AccessControl { } } + /** + * @notice propose a batch of packets sequentially by socketDestination + * @param socketAddress_ address of socket + * @param proposeRequests_ the list of requests with packets to be proposed by socketDestination + */ + function proposeBatch( + address socketAddress_, + ProposeRequest[] calldata proposeRequests_ + ) external { + _proposeBatch(socketAddress_, proposeRequests_); + } + /** * @notice attests a batch of Packets * @param switchboardAddress_ address of switchboard * @param attestRequests_ the list of requests with packets to be attested by switchboard in sequence */ - function attestBatch( + function _attestBatch( address switchboardAddress_, AttestRequest[] calldata attestRequests_ - ) public { + ) internal { uint256 attestRequestLength = attestRequests_.length; for (uint256 index = 0; index < attestRequestLength; ) { FastSwitchboard(switchboardAddress_).attest( @@ -322,6 +346,18 @@ contract SocketBatcher is AccessControl { } } + /** + * @notice attests a batch of Packets + * @param switchboardAddress_ address of switchboard + * @param attestRequests_ the list of requests with packets to be attested by switchboard in sequence + */ + function attestBatch( + address switchboardAddress_, + AttestRequest[] calldata attestRequests_ + ) external { + _attestBatch(switchboardAddress_, attestRequests_); + } + /** * @notice send a batch of propose, attest and execute transactions * @param socketAddress_ address of socket @@ -333,13 +369,15 @@ contract SocketBatcher is AccessControl { function sendBatch( address socketAddress_, address switchboardAddress_, + SealRequest[] calldata sealRequests_, ProposeRequest[] calldata proposeRequests_, AttestRequest[] calldata attestRequests_, ExecuteRequest[] calldata executeRequests_ - ) external { - proposeBatch(socketAddress_, proposeRequests_); - attestBatch(switchboardAddress_, attestRequests_); - executeBatch(socketAddress_, executeRequests_); + ) external payable { + _sealBatch(socketAddress_, sealRequests_); + _proposeBatch(socketAddress_, proposeRequests_); + _attestBatch(switchboardAddress_, attestRequests_); + _executeBatch(socketAddress_, executeRequests_); } /** @@ -378,10 +416,10 @@ contract SocketBatcher is AccessControl { * @param socketAddress_ address of socket * @param executeRequests_ the list of requests with messages to be executed in sequence */ - function executeBatch( + function _executeBatch( address socketAddress_, ExecuteRequest[] calldata executeRequests_ - ) public payable { + ) internal { uint256 executeRequestLength = executeRequests_.length; uint256 totalMsgValue = msg.value; for (uint256 index = 0; index < executeRequestLength; ) { @@ -409,6 +447,18 @@ contract SocketBatcher is AccessControl { } } + /** + * @notice executes a batch of messages + * @param socketAddress_ address of socket + * @param executeRequests_ the list of requests with messages to be executed in sequence + */ + function executeBatch( + address socketAddress_, + ExecuteRequest[] calldata executeRequests_ + ) external payable { + _executeBatch(socketAddress_, executeRequests_); + } + /** * @notice invoke receive Message on PolygonRootReceiver for a batch of messages in loop * @param polygonRootReceiverAddress_ address of polygonRootReceiver @@ -429,6 +479,32 @@ contract SocketBatcher is AccessControl { } } + /** + * @notice returns latest proposalCounts for list of packetIds + * @param socketAddress_ address of socket + * @param packetIds_ the list of packetIds + */ + function getProposalCountBatch( + address socketAddress_, + bytes32[] calldata packetIds_ + ) external view returns (uint256[] memory) { + + uint256 packetIdsLength = packetIds_.length; + + uint256[] memory proposalCounts = new uint256[](packetIdsLength); + + for (uint256 index = 0; index < packetIdsLength; ) { + uint256 proposalCount = ISocket(socketAddress_).proposalCount( + packetIds_[index] + ); + proposalCounts[index] = proposalCount; + unchecked { + ++index; + } + } + return proposalCounts; + } + /** * @notice initiate NativeConfirmation on arbitrumChain for a batch of packets in loop * @param switchboardAddress_ address of nativeArbitrumSwitchboard diff --git a/test/socket/SocketBatcher.t.sol b/test/socket/SocketBatcher.t.sol index e92baaa3..d5346911 100644 --- a/test/socket/SocketBatcher.t.sol +++ b/test/socket/SocketBatcher.t.sol @@ -137,10 +137,12 @@ contract SocketBatcherTest is Setup { memory attestRequests = new SocketBatcher.AttestRequest[](1); attestRequests[0] = attestRequest; SocketBatcher.ExecuteRequest[] memory executeRequests; + SocketBatcher.SealRequest[] memory sealRequests; batcher__.sendBatch( address(_b.socket__), address(_b.configs__[0].switchboard__), + sealRequests, proposeRequests, attestRequests, executeRequests From 553f72166b8073d42632af60bda4134972098a8c Mon Sep 17 00:00:00 2001 From: Akash Date: Tue, 19 Sep 2023 15:24:54 +0530 Subject: [PATCH 2/5] chore:lint --- contracts/interfaces/ISocket.sol | 6 +----- contracts/socket/SocketBatcher.sol | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/contracts/interfaces/ISocket.sol b/contracts/interfaces/ISocket.sol index 493fa695..57c13185 100644 --- a/contracts/interfaces/ISocket.sol +++ b/contracts/interfaces/ISocket.sol @@ -189,15 +189,11 @@ interface ISocket { address switchboard_ ) external view returns (bytes32); - /** * @notice Retrieves the latest proposalCount for a packet id. * @return The proposal count for the specified packet id. */ - function proposalCount( - bytes32 packetId_ - ) external view returns (uint256); - + function proposalCount(bytes32 packetId_) external view returns (uint256); /** * @notice Retrieves the minimum fees required for a message with a specified gas limit and destination chain. diff --git a/contracts/socket/SocketBatcher.sol b/contracts/socket/SocketBatcher.sol index dc7b3d6a..eca2ec8e 100644 --- a/contracts/socket/SocketBatcher.sol +++ b/contracts/socket/SocketBatcher.sol @@ -482,13 +482,12 @@ contract SocketBatcher is AccessControl { /** * @notice returns latest proposalCounts for list of packetIds * @param socketAddress_ address of socket - * @param packetIds_ the list of packetIds + * @param packetIds_ the list of packetIds */ function getProposalCountBatch( address socketAddress_, bytes32[] calldata packetIds_ ) external view returns (uint256[] memory) { - uint256 packetIdsLength = packetIds_.length; uint256[] memory proposalCounts = new uint256[](packetIdsLength); From f6d8f7cd7cf52966c17399d3bc24aa6f2d426b27 Mon Sep 17 00:00:00 2001 From: Akash Date: Tue, 19 Sep 2023 18:18:49 +0530 Subject: [PATCH 3/5] feat: added fast2 switchboard support - dev --- deployments/dev_addresses.json | 75 +++++++++++++++++++-- deployments/dev_verification.json | 60 +++++++++++++++++ scripts/constants/config.ts | 3 +- scripts/deploy/checkRoles.ts | 33 ++++++++- scripts/deploy/configure.ts | 28 +++++++- scripts/deploy/scripts/deploySwitchboard.ts | 13 ++++ scripts/deploy/scripts/getABIs.ts | 1 + scripts/deploy/switchboards/index.ts | 7 ++ scripts/deploy/utils/address.ts | 2 + src/types.ts | 11 +++ 10 files changed, 224 insertions(+), 9 deletions(-) diff --git a/deployments/dev_addresses.json b/deployments/dev_addresses.json index 04156850..4aa5d274 100644 --- a/deployments/dev_addresses.json +++ b/deployments/dev_addresses.json @@ -123,6 +123,11 @@ "capacitor": "0xc78898F997FF293F1F06aa3bd9f663bEA88248a0", "decapacitor": "0x2e1eC79B8fddF2fCcd59093f0a56a206Be585904", "switchboard": "0xc98a5dB97F7887302877C900f2F8d86f110A7F5d" + }, + "FAST2": { + "capacitor": "0xFbFE7e589c079919665f07B7510D430506faa3Fa", + "decapacitor": "0x9A0D2de3Cd9f63429688D3B486d622a803aFbC6E", + "switchboard": "0x7E7735e77574228C4F55d4B2F96Fe586dF10104e" } }, "421613": { @@ -135,6 +140,11 @@ "capacitor": "0x8a829246b6B93a9ed829305a9a47F3FC67fbBdcE", "decapacitor": "0x622Cf22447E40e89396eb695797aABaF616703D8", "switchboard": "0xc98a5dB97F7887302877C900f2F8d86f110A7F5d" + }, + "FAST2": { + "capacitor": "0x4702e9A9d376CFF6e20eFD786d1811AafFb3935c", + "decapacitor": "0xe9E039099E5445b6d8B9966Eb7f1567F97846B0f", + "switchboard": "0x7E7735e77574228C4F55d4B2F96Fe586dF10104e" } }, "11155111": { @@ -159,13 +169,19 @@ "capacitor": "0x320D695989a7198536112bCaB534F6b9cDB2b1a0", "decapacitor": "0x312b12DAadbe0017012837587543FE5CCac34542", "switchboard": "0xc98a5dB97F7887302877C900f2F8d86f110A7F5d" + }, + "FAST2": { + "capacitor": "0xB0A6648ad41eC955E676FafCd1313DF46224D300", + "decapacitor": "0x8476198C9070e9E94e7b816055600E58063526E7", + "switchboard": "0x7E7735e77574228C4F55d4B2F96Fe586dF10104e" } } }, "FastSwitchboard": "0xE350007007b84483CC5bd764e2220187Ad477F2D", "OptimisticSwitchboard": "0xc98a5dB97F7887302877C900f2F8d86f110A7F5d", "Counter": "0xE89A18D6eB897236BEd71e5975940DA603d80084", - "SocketBatcher": "0xEe391E4a214E6312B42BF5FAcA9Bd214e8ebd206" + "SocketBatcher": "0xEe391E4a214E6312B42BF5FAcA9Bd214e8ebd206", + "FastSwitchboard2": "0x7E7735e77574228C4F55d4B2F96Fe586dF10104e" }, "80001": { "SignatureVerifier": "0x79Dc67853cab8FB77f14A76116cAa7B4478B53Da", @@ -202,6 +218,11 @@ "capacitor": "0xd5cA9396BB182462C4a63AB28b81725896D573Eb", "decapacitor": "0xB063b3B6A0c40ee06101A1F024bcF6ad7C94f5F6", "switchboard": "0xb1139c246ef3cc8F968ea2C61de813fEe1dB8758" + }, + "FAST2": { + "capacitor": "0x27618b47813c6cCb94968acD1813702A8dDA2736", + "decapacitor": "0x83bB0bf729B6BADB8222fB52f4Fb2f51C8caBd24", + "switchboard": "0x0dD648cdF51b7f7AdA68F84BB245D52172199F0d" } }, "421613": { @@ -214,6 +235,11 @@ "capacitor": "0x8874F6D2a68C0EC09c14a257fAF8C055850668db", "decapacitor": "0xa60922DBF6Ac2396687Ab6DBCCd086B4b6D096f7", "switchboard": "0xb1139c246ef3cc8F968ea2C61de813fEe1dB8758" + }, + "FAST2": { + "capacitor": "0x55c9d8E06418d3B21b2Cd0d8Dc08D7E7c9e9f9b8", + "decapacitor": "0x65B294AC9aBEaDE3DBa851A1E0AaaeA73fb2105c", + "switchboard": "0x0dD648cdF51b7f7AdA68F84BB245D52172199F0d" } }, "11155111": { @@ -238,13 +264,19 @@ "capacitor": "0xa3C52f32Df52394aC3f45B93b1601F47a3c1D71d", "decapacitor": "0xB2104b426bB1480004a68d12505679be54eb304f", "switchboard": "0xb1139c246ef3cc8F968ea2C61de813fEe1dB8758" + }, + "FAST2": { + "capacitor": "0x8dD81a43ACe519BEa114a0d01BA25c70B49027A5", + "decapacitor": "0xBD7F4D2F5200B07a13e2F074Ab0248Fd90FcAEEc", + "switchboard": "0x0dD648cdF51b7f7AdA68F84BB245D52172199F0d" } } }, "FastSwitchboard": "0x27513Ed43490B6e0801e724ff1b1637be657447E", "OptimisticSwitchboard": "0xb1139c246ef3cc8F968ea2C61de813fEe1dB8758", "Counter": "0x154425b14538ca5dCE77357133CEA76DDc6650EA", - "SocketBatcher": "0x50E32b5595d31dFBA53E189513718412EA42c804" + "SocketBatcher": "0x50E32b5595d31dFBA53E189513718412EA42c804", + "FastSwitchboard2": "0x0dD648cdF51b7f7AdA68F84BB245D52172199F0d" }, "421613": { "SignatureVerifier": "0x353287093b3C9f5842396a6fc9704766aA5409c7", @@ -281,6 +313,11 @@ "capacitor": "0xC066998D3D84688f349abaFDaf35ee4da6a89669", "decapacitor": "0x261d1DB0B65AFF064141058C95A662cD9ecf066a", "switchboard": "0x0FE19867199d6c96f2e1FE022c38ebb4292543F8" + }, + "FAST2": { + "capacitor": "0xD5a258282aF75D2758D6D10F047D590f06c7E950", + "decapacitor": "0x132c95211972cc709eB1Aab754E03b49Fc2C6D15", + "switchboard": "0xFD468fc7d23dA3e7466EE78327D4db5FcA232B2d" } }, "80001": { @@ -293,6 +330,11 @@ "capacitor": "0x8703748808130233B8E24659254E3136650Adb1e", "decapacitor": "0x867d1C40be7229F099E72d88b1Afef62339Fc344", "switchboard": "0x0FE19867199d6c96f2e1FE022c38ebb4292543F8" + }, + "FAST2": { + "capacitor": "0xb26412B7aFd7E9c1BC3553C1d070bEE2a380bc71", + "decapacitor": "0x370eE148379e26E22C00f6d083c32B4a8D5bFE40", + "switchboard": "0xFD468fc7d23dA3e7466EE78327D4db5FcA232B2d" } }, "11155111": { @@ -317,13 +359,19 @@ "capacitor": "0xC1295bD9c08d8F9059172fB5640c7e8CFD82b3c7", "decapacitor": "0xb6562dDFF738FD1D1fad0Ce7BCEE51F3FA715A8F", "switchboard": "0x0FE19867199d6c96f2e1FE022c38ebb4292543F8" + }, + "FAST2": { + "capacitor": "0x5ef8a3FE885d40486456691F7A280698bbAd8293", + "decapacitor": "0x77230d566c3FA6Fa714659A0365Fe0a8b1041018", + "switchboard": "0xFD468fc7d23dA3e7466EE78327D4db5FcA232B2d" } } }, "FastSwitchboard": "0xA4C366be8e0BFE59011d26f66E683B1D290DcF45", "OptimisticSwitchboard": "0x0FE19867199d6c96f2e1FE022c38ebb4292543F8", "Counter": "0xc8dD08F4f7392b4577f4D6499233792d163DA5Ee", - "SocketBatcher": "0x93D246a24B032C101c0858354dC5FbB7A113d500" + "SocketBatcher": "0x93D246a24B032C101c0858354dC5FbB7A113d500", + "FastSwitchboard2": "0xFD468fc7d23dA3e7466EE78327D4db5FcA232B2d" }, "11155111": { "SignatureVerifier": "0x6f6f4C24bE59c42F524b133d623170376b8Eed64", @@ -397,7 +445,8 @@ "FastSwitchboard": "0xaDDaC77B80C990A87906C4273902be5EC7f25B42", "OptimisticSwitchboard": "0xaE51c633fb58df92FCcBb0694EA22E060d29F5F7", "Counter": "0x918ECe20236B9d8C2AA1742540246D6F9a9eB081", - "SocketBatcher": "0xec7A753bc2D4Fab9Fcc459B7205d2FCa96b6c622" + "SocketBatcher": "0xec7A753bc2D4Fab9Fcc459B7205d2FCa96b6c622", + "FastSwitchboard2": "0xb2dA552c9Baa0e15b13302aBBF7B555aBc8eE4E8" }, "11155112": { "SignatureVerifier": "0x1d7C105919E4D75e30581D4a5B3724F8D6159251", @@ -429,6 +478,11 @@ "capacitor": "0xe1D244B53eB376E614a749953216855eFF19AD3f", "decapacitor": "0x7d5934a197F94e274979476903612E4Ac320b150", "switchboard": "0xB9EDe9aaEaA40e35033ABBC872D141950d08cc4d" + }, + "FAST2": { + "capacitor": "0x41667f3df292b3eD613D66b39dD2D8327D2EF5A8", + "decapacitor": "0x7A637ec130A51cb9517B341368F9F30c4b09Cb2d", + "switchboard": "0x10cfBbFaF37AD46aDF4F783D02Ac57806eaD620b" } }, "80001": { @@ -441,6 +495,11 @@ "capacitor": "0x830fc6d0e201b8358B037C0Ce839dc2F70f0b955", "decapacitor": "0x04C09f62ce7021Dc0Ebb97982C16ca442258087a", "switchboard": "0xB9EDe9aaEaA40e35033ABBC872D141950d08cc4d" + }, + "FAST2": { + "capacitor": "0x9aa6B8cE85f7cb1FDd38Ae43f7823668C83C180C", + "decapacitor": "0x5161A62859BC1F28A9d88F9EceB18E661F28aFAb", + "switchboard": "0x10cfBbFaF37AD46aDF4F783D02Ac57806eaD620b" } }, "421613": { @@ -453,6 +512,11 @@ "capacitor": "0xF03D4990d5d66181f49d7213574aAbCB2f90ac7f", "decapacitor": "0x7835D5dCA730bC4788460c5919a6C433FB0233e7", "switchboard": "0xB9EDe9aaEaA40e35033ABBC872D141950d08cc4d" + }, + "FAST2": { + "capacitor": "0x7D3388F5F7feD2539082a2Ce8D19737275d638d5", + "decapacitor": "0xd32d5eA4628f35985Cd4c21d0FEC1c7c94587731", + "switchboard": "0x10cfBbFaF37AD46aDF4F783D02Ac57806eaD620b" } }, "11155111": { @@ -471,6 +535,7 @@ "FastSwitchboard": "0x85778A90ec60249f10d7AEe06484ffC290d5Efd8", "OptimisticSwitchboard": "0xB9EDe9aaEaA40e35033ABBC872D141950d08cc4d", "Counter": "0xAE9bE0eA6DD7B53C88665Cb2EFf7d40dFD51cf91", - "SocketBatcher": "0x06845FE0597cD0027df2d62B152B17E5eBaE22DB" + "SocketBatcher": "0x06845FE0597cD0027df2d62B152B17E5eBaE22DB", + "FastSwitchboard2": "0x10cfBbFaF37AD46aDF4F783D02Ac57806eaD620b" } } diff --git a/deployments/dev_verification.json b/deployments/dev_verification.json index dcb7aa39..d8fa6534 100644 --- a/deployments/dev_verification.json +++ b/deployments/dev_verification.json @@ -136,6 +136,18 @@ ] ], "420": [ + [ + "0x7E7735e77574228C4F55d4B2F96Fe586dF10104e", + "FastSwitchboard", + "contracts/switchboard/default-switchboards/FastSwitchboard.sol", + [ + "0x752B38FA38F53dF7fa60e6113CFd9094b7e040Aa", + "0xD97B9F7fF00E252C0abAa6ce0E13B5F6d9185202", + 420, + 7200, + "0x1B458A51D91f179DBbBb6C43d7962Ba17CC84628" + ] + ], [ "0xEe391E4a214E6312B42BF5FAcA9Bd214e8ebd206", "SocketBatcher", @@ -245,6 +257,18 @@ ] ], "80001": [ + [ + "0x0dD648cdF51b7f7AdA68F84BB245D52172199F0d", + "FastSwitchboard", + "contracts/switchboard/default-switchboards/FastSwitchboard.sol", + [ + "0x752B38FA38F53dF7fa60e6113CFd9094b7e040Aa", + "0x718826B533DF29C30f2d3f30E585e405eeF22784", + 80001, + 7200, + "0x79Dc67853cab8FB77f14A76116cAa7B4478B53Da" + ] + ], [ "0x50E32b5595d31dFBA53E189513718412EA42c804", "SocketBatcher", @@ -353,6 +377,18 @@ ] ], "421613": [ + [ + "0xFD468fc7d23dA3e7466EE78327D4db5FcA232B2d", + "FastSwitchboard", + "contracts/switchboard/default-switchboards/FastSwitchboard.sol", + [ + "0x752B38FA38F53dF7fa60e6113CFd9094b7e040Aa", + "0x5a90a285ab72393B2c47168374895a5C8101012c", + 421613, + 7200, + "0x353287093b3C9f5842396a6fc9704766aA5409c7" + ] + ], [ "0x93D246a24B032C101c0858354dC5FbB7A113d500", "SocketBatcher", @@ -460,6 +496,18 @@ ] ], "11155111": [ + [ + "0xb2dA552c9Baa0e15b13302aBBF7B555aBc8eE4E8", + "FastSwitchboard", + "contracts/switchboard/default-switchboards/FastSwitchboard.sol", + [ + "0x752B38FA38F53dF7fa60e6113CFd9094b7e040Aa", + "0xEDF6dB2f3BC8deE014762e0141EE4CA19d685dBd", + 11155111, + 7200, + "0x6f6f4C24bE59c42F524b133d623170376b8Eed64" + ] + ], [ "0xec7A753bc2D4Fab9Fcc459B7205d2FCa96b6c622", "SocketBatcher", @@ -556,6 +604,18 @@ ] ], "11155112": [ + [ + "0x10cfBbFaF37AD46aDF4F783D02Ac57806eaD620b", + "FastSwitchboard", + "contracts/switchboard/default-switchboards/FastSwitchboard.sol", + [ + "0x752B38FA38F53dF7fa60e6113CFd9094b7e040Aa", + "0x66ffe416eB16D879EcE55B1d50C34789CB4Ab80a", + 11155112, + 7200, + "0x1d7C105919E4D75e30581D4a5B3724F8D6159251" + ] + ], [ "0x06845FE0597cD0027df2d62B152B17E5eBaE22DB", "SocketBatcher", diff --git a/scripts/constants/config.ts b/scripts/constants/config.ts index e5256c4c..309d3aa1 100644 --- a/scripts/constants/config.ts +++ b/scripts/constants/config.ts @@ -65,7 +65,8 @@ export const getDefaultIntegrationType = ( ): IntegrationTypes => { return switchboards?.[chain]?.[sibling] ? IntegrationTypes.native - : IntegrationTypes.fast; + : IntegrationTypes.fast2; + // : IntegrationTypes.fast; // revert back this when migration done }; export const switchboards = { diff --git a/scripts/deploy/checkRoles.ts b/scripts/deploy/checkRoles.ts index ea92ca8d..ee79900d 100644 --- a/scripts/deploy/checkRoles.ts +++ b/scripts/deploy/checkRoles.ts @@ -452,7 +452,8 @@ export const checkAndUpdateRoles = async (params: checkAndUpdateRolesObj) => { // If Watcher role in FastSwitchboard, have to call another function // to set the role if ( - contractName === CORE_CONTRACTS.FastSwitchboard && + (contractName === CORE_CONTRACTS.FastSwitchboard || + contractName === CORE_CONTRACTS.FastSwitchboard2) && role === ROLES.WATCHER_ROLE && isRoleChanged(hasRole, newRoleStatus) ) { @@ -618,6 +619,36 @@ const main = async () => { newRoleStatus, }); + // Setup Fast Switchboard2 roles except WATCHER + await checkAndUpdateRoles({ + userSpecificRoles: [ + { + userAddress: ownerAddress, + filterRoles: [ + ROLES.RESCUE_ROLE, + ROLES.GOVERNANCE_ROLE, + ROLES.TRIP_ROLE, + ROLES.UN_TRIP_ROLE, + ROLES.WITHDRAW_ROLE, + ROLES.FEES_UPDATER_ROLE, + ], + }, + { + userAddress: transmitterAddress, + filterRoles: [ROLES.FEES_UPDATER_ROLE], + }, + { + userAddress: watcherAddress, + filterRoles: [ROLES.WATCHER_ROLE], + }, + ], + + contractName: CORE_CONTRACTS.FastSwitchboard2, + filterChains, + sendTransaction, + newRoleStatus, + }); + // Grant watcher role to watcher for OptimisticSwitchboard await checkAndUpdateRoles({ userSpecificRoles: [ diff --git a/scripts/deploy/configure.ts b/scripts/deploy/configure.ts index e4acf8c3..8aefc3e6 100644 --- a/scripts/deploy/configure.ts +++ b/scripts/deploy/configure.ts @@ -149,6 +149,30 @@ export const main = async () => { addr ); } + + // register fast2 + for (let sibling of siblingSlugs) { + const siblingSwitchboard = getSwitchboardAddress( + chain, + IntegrationTypes.fast2, + addresses?.[sibling] + ); + + if (!siblingSwitchboard || !addr[CORE_CONTRACTS.FastSwitchboard2]) + continue; + + addr = await registerSwitchboardForSibling( + addr[CORE_CONTRACTS.FastSwitchboard2], + siblingSwitchboard, + sibling, + capacitorType, + maxPacketLength, + socketSigner, + IntegrationTypes.fast2, + addr + ); + } + // register optimistic for (let sibling of siblingSlugs) { const siblingSwitchboard = getSwitchboardAddress( @@ -206,7 +230,7 @@ const configureExecutionManager = async ( let nextNonce = ( await executionManagerContract.nextNonce(socketSigner.address) ).toNumber(); - console.log({ nextNonce }); + // console.log({ nextNonce }); let requests: any = []; @@ -220,7 +244,7 @@ const configureExecutionManager = async ( currentValue.toString() == msgValueMaxThreshold[siblingSlug]?.toString() ) { - console.log("already set, returning ", { currentValue }); + // console.log("already set, returning ", { currentValue }); return; } diff --git a/scripts/deploy/scripts/deploySwitchboard.ts b/scripts/deploy/scripts/deploySwitchboard.ts index e51daab8..da196408 100644 --- a/scripts/deploy/scripts/deploySwitchboard.ts +++ b/scripts/deploy/scripts/deploySwitchboard.ts @@ -32,6 +32,16 @@ export default async function deploySwitchboards( mode ); + if (!sourceConfig.FastSwitchboard2) + updatedConfig = await deploySwitchboard( + IntegrationTypes.fast2, + network, + "", + signer, + updatedConfig, + mode + ); + if (!sourceConfig.OptimisticSwitchboard) updatedConfig = await deploySwitchboard( IntegrationTypes.optimistic, @@ -114,6 +124,9 @@ async function deploySwitchboard( if (integrationType === IntegrationTypes.fast) { sourceConfig[CORE_CONTRACTS.FastSwitchboard] = switchboard.address; } + if (integrationType === IntegrationTypes.fast2) { + sourceConfig[CORE_CONTRACTS.FastSwitchboard2] = switchboard.address; + } } catch (error) { console.log("Error in deploying switchboard", error); throw error; diff --git a/scripts/deploy/scripts/getABIs.ts b/scripts/deploy/scripts/getABIs.ts index d2775aae..930b9f7a 100644 --- a/scripts/deploy/scripts/getABIs.ts +++ b/scripts/deploy/scripts/getABIs.ts @@ -18,6 +18,7 @@ export const getABI = { Capacitor: Capacitor.abi, Socket: Socket.abi, FastSwitchboard: FastSwitchboard.abi, + FastSwitchboard2: FastSwitchboard.abi, OptimisticSwitchboard: OptimisticSwitchboard.abi, NativeSwitchboard: NativeSwitchboard.abi, AccessControlExtended: AccessControlExtended.abi, diff --git a/scripts/deploy/switchboards/index.ts b/scripts/deploy/switchboards/index.ts index 57211209..ab8a3835 100644 --- a/scripts/deploy/switchboards/index.ts +++ b/scripts/deploy/switchboards/index.ts @@ -26,6 +26,13 @@ export const getSwitchboardDeployData = ( sigVerifierAddress, signerAddress ); + } else if (integrationType === IntegrationTypes.fast2) { + return fastSwitchboard( + localChain, + socketAddress, + sigVerifierAddress, + signerAddress + ); } else if (integrationType === IntegrationTypes.optimistic) { return optimisticSwitchboard( localChain, diff --git a/scripts/deploy/utils/address.ts b/scripts/deploy/utils/address.ts index c16e489d..c45b4a79 100644 --- a/scripts/deploy/utils/address.ts +++ b/scripts/deploy/utils/address.ts @@ -7,6 +7,8 @@ function getSwitchboardAddress( ) { if (integrationType === IntegrationTypes.fast) { return config?.["FastSwitchboard"]; + } else if (integrationType === IntegrationTypes.fast2) { + return config?.["FastSwitchboard2"]; } else if (integrationType === IntegrationTypes.optimistic) { return config?.["OptimisticSwitchboard"]; } else diff --git a/src/types.ts b/src/types.ts index cb6a0c8d..59b8369c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -146,6 +146,7 @@ export const isNonNativeChain = (chainSlug: ChainSlug) => { }; export enum IntegrationTypes { + fast2 = "FAST2", fast = "FAST", optimistic = "OPTIMISTIC", native = "NATIVE_BRIDGE", @@ -180,6 +181,7 @@ export interface ChainSocketAddresses { Socket: string; TransmitManager: string; FastSwitchboard: string; + FastSwitchboard2?: string; OptimisticSwitchboard: string; SocketBatcher: string; integrations?: Integrations; @@ -212,6 +214,7 @@ export enum CORE_CONTRACTS { Socket = "Socket", SocketBatcher = "SocketBatcher", FastSwitchboard = "FastSwitchboard", + FastSwitchboard2 = "FastSwitchboard2", OptimisticSwitchboard = "OptimisticSwitchboard", NativeSwitchboard = "NativeSwitchboard", } @@ -243,6 +246,13 @@ export const REQUIRED_ROLES = { ROLES.WITHDRAW_ROLE, ROLES.RESCUE_ROLE, ], + FastSwitchboard2: [ + ROLES.TRIP_ROLE, + ROLES.UN_TRIP_ROLE, + ROLES.GOVERNANCE_ROLE, + ROLES.WITHDRAW_ROLE, + ROLES.RESCUE_ROLE, + ], OptimisticSwitchboard: [ ROLES.TRIP_ROLE, ROLES.UN_TRIP_ROLE, @@ -265,5 +275,6 @@ export const REQUIRED_CHAIN_ROLES = { [CORE_CONTRACTS.ExecutionManager]: [ROLES.FEES_UPDATER_ROLE], [CORE_CONTRACTS.OpenExecutionManager]: [ROLES.FEES_UPDATER_ROLE], FastSwitchboard: [ROLES.WATCHER_ROLE, ROLES.FEES_UPDATER_ROLE], + FastSwitchboard2: [ROLES.WATCHER_ROLE, ROLES.FEES_UPDATER_ROLE], OptimisticSwitchboard: [ROLES.WATCHER_ROLE, ROLES.FEES_UPDATER_ROLE], }; From a76493221ba3c3a805ee73bf6a47b9c876e58caa Mon Sep 17 00:00:00 2001 From: arthcp Date: Tue, 19 Sep 2023 18:54:02 +0530 Subject: [PATCH 4/5] chore: version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0f7dc5aa..4ed779f4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@socket.tech/dl-core", "license": "UNLICENSED", - "version": "2.4.0-test.8", + "version": "2.4.0-test.9", "description": "Smart contracts for socket data layer.", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts", From c78f0426a1d9fbd02644d007a540acec6d20b8ac Mon Sep 17 00:00:00 2001 From: arthcp Date: Mon, 25 Sep 2023 17:04:14 +0530 Subject: [PATCH 5/5] chore: version bump --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46632777..644dd003 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ It is recommended to setup the ide to work with solidity development. In case of } ``` -## Error Signatures +## Error Signatures | Error | Signature | | --------------------------- | ---------- | diff --git a/package.json b/package.json index 4ed779f4..34d205fc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@socket.tech/dl-core", "license": "UNLICENSED", - "version": "2.4.0-test.9", + "version": "2.4.2", "description": "Smart contracts for socket data layer.", "main": "./dist/src/index.js", "types": "./dist/src/index.d.ts",