From ef5c74a981cb4da3587c8b73cd52e7fccfb5010c Mon Sep 17 00:00:00 2001 From: Vincent Geddes Date: Sun, 5 Nov 2023 12:43:53 +0200 Subject: [PATCH] Upgrade to Solidity 0.8.22 (#992) * Upgrade to Solidity 0.8.22 * Update foundry to support Solidity 0.8.22 * Update bindings for Gateway.sol * Smokestests now require serde --- contracts/foundry.toml | 2 +- contracts/src/Agent.sol | 2 +- contracts/src/AgentExecutor.sol | 2 +- contracts/src/Assets.sol | 14 +- contracts/src/BeefyClient.sol | 2 +- contracts/src/DeployScript.sol | 2 +- contracts/src/FundAgent.sol | 2 +- contracts/src/Gateway.sol | 2 +- contracts/src/GatewayProxy.sol | 2 +- contracts/src/SubstrateTypes.sol | 2 +- contracts/src/Types.sol | 2 +- contracts/src/Verification.sol | 2 +- contracts/src/interfaces/IERC20.sol | 2 +- contracts/src/interfaces/IGateway.sol | 8 +- contracts/src/interfaces/IInitializable.sol | 2 +- contracts/src/storage/AssetsStorage.sol | 2 +- contracts/src/storage/CoreStorage.sol | 2 +- contracts/src/utils/Address.sol | 2 +- contracts/src/utils/Bitfield.sol | 2 +- contracts/src/utils/Bits.sol | 2 +- contracts/src/utils/Call.sol | 2 +- contracts/src/utils/Counter.sol | 2 +- contracts/src/utils/ERC1967.sol | 2 +- contracts/src/utils/MMRProof.sol | 2 +- contracts/src/utils/Math.sol | 2 +- contracts/src/utils/SafeTransfer.sol | 2 +- contracts/src/utils/ScaleCodec.sol | 2 +- contracts/src/utils/SubstrateMerkleProof.sol | 2 +- contracts/test/Agent.t.sol | 2 +- contracts/test/BeefyClient.t.sol | 2 +- contracts/test/Counter.t.sol | 2 +- contracts/test/Gateway.t.sol | 36 +-- contracts/test/MMRProof.t.sol | 2 +- contracts/test/Math.t.sol | 2 +- contracts/test/ScaleCodec.t.sol | 2 +- contracts/test/Verification.t.sol | 2 +- contracts/test/mocks/BeefyClientMock.sol | 2 +- contracts/test/mocks/GatewayMock.sol | 2 +- contracts/test/mocks/GatewayUpgradeMock.sol | 2 +- contracts/test/mocks/MMRProofWrapper.sol | 2 +- contracts/test/mocks/VerificationWrapper.sol | 2 +- flake.lock | 6 +- relayer/contracts/gateway.go | 292 ++++++++++++++++++- smoketest/Cargo.lock | 1 + smoketest/Cargo.toml | 1 + 45 files changed, 364 insertions(+), 70 deletions(-) diff --git a/contracts/foundry.toml b/contracts/foundry.toml index 4b22198d96..0bec11f871 100644 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -1,5 +1,5 @@ [profile.default] -solc_version = "0.8.20" +solc_version = "0.8.22" optimizer = true optimizer_runs = 20_000 via_ir = true diff --git a/contracts/src/Agent.sol b/contracts/src/Agent.sol index fedaa5d972..e09966e957 100644 --- a/contracts/src/Agent.sol +++ b/contracts/src/Agent.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; /// @title An agent contract that acts on behalf of a consensus system on Polkadot /// @dev Instances of this contract act as an agents for arbitrary consensus systems on Polkadot. These consensus systems diff --git a/contracts/src/AgentExecutor.sol b/contracts/src/AgentExecutor.sol index 488eb4bb9e..df8145bed6 100644 --- a/contracts/src/AgentExecutor.sol +++ b/contracts/src/AgentExecutor.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {AgentExecuteCommand, ParaID} from "./Types.sol"; import {SubstrateTypes} from "./SubstrateTypes.sol"; diff --git a/contracts/src/Assets.sol b/contracts/src/Assets.sol index 5a312c9cba..ed489fddca 100644 --- a/contracts/src/Assets.sol +++ b/contracts/src/Assets.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {IERC20} from "./interfaces/IERC20.sol"; import {IGateway} from "./interfaces/IGateway.sol"; @@ -17,12 +17,6 @@ library Assets { using Address for address; using SafeTokenTransferFrom for IERC20; - /// @dev Emitted once the funds are locked and a message is successfully queued. - event TokenSent( - address indexed token, address indexed sender, ParaID destinationChain, bytes destinationAddress, uint128 amount - ); - event TokenRegistrationSent(address token); - /* Errors */ error InvalidToken(); error InvalidAmount(); @@ -55,7 +49,7 @@ library Assets { } extraFee = $.sendTokenFee; - emit TokenSent(sender, token, destinationChain, abi.encodePacked(destinationAddress), amount); + emit IGateway.TokenSent(sender, token, destinationChain, abi.encodePacked(destinationAddress), amount); } function sendToken( @@ -77,7 +71,7 @@ library Assets { payload = SubstrateTypes.SendToken(address(this), token, destinationChain, destinationAddress, amount); extraFee = $.sendTokenFee; - emit TokenSent(sender, token, destinationChain, abi.encodePacked(destinationAddress), amount); + emit IGateway.TokenSent(sender, token, destinationChain, abi.encodePacked(destinationAddress), amount); } /// @dev transfer tokens from the sender to the specified @@ -105,6 +99,6 @@ library Assets { payload = SubstrateTypes.RegisterToken(token); extraFee = $.registerTokenFee; - emit TokenRegistrationSent(token); + emit IGateway.TokenRegistrationSent(token); } } diff --git a/contracts/src/BeefyClient.sol b/contracts/src/BeefyClient.sol index 7aa5bcf10b..58656fff0b 100644 --- a/contracts/src/BeefyClient.sol +++ b/contracts/src/BeefyClient.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {ECDSA} from "openzeppelin/utils/cryptography/ECDSA.sol"; import {SubstrateMerkleProof} from "./utils/SubstrateMerkleProof.sol"; diff --git a/contracts/src/DeployScript.sol b/contracts/src/DeployScript.sol index 98f9947ca2..2efddbe9f9 100644 --- a/contracts/src/DeployScript.sol +++ b/contracts/src/DeployScript.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {WETH9} from "canonical-weth/WETH9.sol"; import {Script} from "forge-std/Script.sol"; diff --git a/contracts/src/FundAgent.sol b/contracts/src/FundAgent.sol index 4a5546c98f..bd8daaa62f 100644 --- a/contracts/src/FundAgent.sol +++ b/contracts/src/FundAgent.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {WETH9} from "canonical-weth/WETH9.sol"; import {Script} from "forge-std/Script.sol"; diff --git a/contracts/src/Gateway.sol b/contracts/src/Gateway.sol index 73aeab97b1..6609f4d8cc 100644 --- a/contracts/src/Gateway.sol +++ b/contracts/src/Gateway.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {MerkleProof} from "openzeppelin/utils/cryptography/MerkleProof.sol"; import {Verification} from "./Verification.sol"; diff --git a/contracts/src/GatewayProxy.sol b/contracts/src/GatewayProxy.sol index ff81879c01..ca728c3268 100644 --- a/contracts/src/GatewayProxy.sol +++ b/contracts/src/GatewayProxy.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {ERC1967} from "./utils/ERC1967.sol"; import {IInitializable} from "./interfaces/IInitializable.sol"; diff --git a/contracts/src/SubstrateTypes.sol b/contracts/src/SubstrateTypes.sol index b962c63d60..36d0257aaf 100644 --- a/contracts/src/SubstrateTypes.sol +++ b/contracts/src/SubstrateTypes.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {ScaleCodec} from "./utils/ScaleCodec.sol"; import {ParaID} from "./Types.sol"; diff --git a/contracts/src/Types.sol b/contracts/src/Types.sol index 4ef0d9f0df..cb0fae8266 100644 --- a/contracts/src/Types.sol +++ b/contracts/src/Types.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; type ParaID is uint256; diff --git a/contracts/src/Verification.sol b/contracts/src/Verification.sol index c247a18b38..e9e71829f2 100644 --- a/contracts/src/Verification.sol +++ b/contracts/src/Verification.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {SubstrateMerkleProof} from "./utils/SubstrateMerkleProof.sol"; import {BeefyClient} from "./BeefyClient.sol"; diff --git a/contracts/src/interfaces/IERC20.sol b/contracts/src/interfaces/IERC20.sol index 58b4f3a8aa..b0169083ee 100644 --- a/contracts/src/interfaces/IERC20.sol +++ b/contracts/src/interfaces/IERC20.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2023 Axelar Network -pragma solidity ^0.8.20; +pragma solidity 0.8.22; /** * @dev Interface of the ERC20 standard as defined in the EIP. diff --git a/contracts/src/interfaces/IGateway.sol b/contracts/src/interfaces/IGateway.sol index 10dc8ec70c..c94b5fc261 100644 --- a/contracts/src/interfaces/IGateway.sol +++ b/contracts/src/interfaces/IGateway.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {OperatingMode, InboundMessage, ParaID} from "../Types.sol"; import {Verification} from "../Verification.sol"; @@ -34,6 +34,12 @@ interface IGateway { // Emitted when funds are withdrawn from an agent event AgentFundsWithdrawn(bytes32 indexed agentID, address indexed recipient, uint256 amount); + /// @dev Emitted once the funds are locked and a message is successfully queued. + event TokenSent( + address indexed token, address indexed sender, ParaID destinationChain, bytes destinationAddress, uint128 amount + ); + event TokenRegistrationSent(address token); + /** * Getters */ diff --git a/contracts/src/interfaces/IInitializable.sol b/contracts/src/interfaces/IInitializable.sol index e191a8a55f..2421d63b47 100644 --- a/contracts/src/interfaces/IInitializable.sol +++ b/contracts/src/interfaces/IInitializable.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; /** * @title Initialization of gateway contracts diff --git a/contracts/src/storage/AssetsStorage.sol b/contracts/src/storage/AssetsStorage.sol index 816db9a110..110e20f9b1 100644 --- a/contracts/src/storage/AssetsStorage.sol +++ b/contracts/src/storage/AssetsStorage.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; library AssetsStorage { struct Layout { diff --git a/contracts/src/storage/CoreStorage.sol b/contracts/src/storage/CoreStorage.sol index cea0719bf6..79a63d0d03 100644 --- a/contracts/src/storage/CoreStorage.sol +++ b/contracts/src/storage/CoreStorage.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {Channel, OperatingMode, ParaID} from "../Types.sol"; diff --git a/contracts/src/utils/Address.sol b/contracts/src/utils/Address.sol index acddf38d73..f2cb9ac1ba 100644 --- a/contracts/src/utils/Address.sol +++ b/contracts/src/utils/Address.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: 2023 Axelar Network // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity ^0.8.20; +pragma solidity 0.8.22; library Address { // Checks whether `account` is a contract diff --git a/contracts/src/utils/Bitfield.sol b/contracts/src/utils/Bitfield.sol index 63be99218f..2e60fd9d2c 100644 --- a/contracts/src/utils/Bitfield.sol +++ b/contracts/src/utils/Bitfield.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {Bits} from "./Bits.sol"; diff --git a/contracts/src/utils/Bits.sol b/contracts/src/utils/Bits.sol index 115d5a7560..d4b67c94d6 100644 --- a/contracts/src/utils/Bits.sol +++ b/contracts/src/utils/Bits.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork // Code from https://github.com/ethereum/solidity-examples -pragma solidity 0.8.20; +pragma solidity 0.8.22; library Bits { uint256 internal constant ONE = uint256(1); diff --git a/contracts/src/utils/Call.sol b/contracts/src/utils/Call.sol index 02e80c5674..48120c1751 100644 --- a/contracts/src/utils/Call.sol +++ b/contracts/src/utils/Call.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2023 OpenZeppelin // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; // Derived from OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) library Call { diff --git a/contracts/src/utils/Counter.sol b/contracts/src/utils/Counter.sol index d025d20e8b..44fdfdbe63 100644 --- a/contracts/src/utils/Counter.sol +++ b/contracts/src/utils/Counter.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; /** * @title A utility library for 16 bit counters packed in 256 bit array. diff --git a/contracts/src/utils/ERC1967.sol b/contracts/src/utils/ERC1967.sol index 1cba006be0..22870d4174 100644 --- a/contracts/src/utils/ERC1967.sol +++ b/contracts/src/utils/ERC1967.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; /// @title Minimal implementation of ERC1967 storage slot library ERC1967 { diff --git a/contracts/src/utils/MMRProof.sol b/contracts/src/utils/MMRProof.sol index a560c78413..bdff0cab52 100644 --- a/contracts/src/utils/MMRProof.sol +++ b/contracts/src/utils/MMRProof.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; library MMRProof { error ProofSizeExceeded(); diff --git a/contracts/src/utils/Math.sol b/contracts/src/utils/Math.sol index e27340c96e..ca6215e382 100644 --- a/contracts/src/utils/Math.sol +++ b/contracts/src/utils/Math.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: 2023 OpenZeppelin // SPDX-FileCopyrightText: 2023 Snowfork // Code from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/Math.sol -pragma solidity ^0.8.20; +pragma solidity 0.8.22; /** * @dev Standard math utilities missing in the Solidity language. diff --git a/contracts/src/utils/SafeTransfer.sol b/contracts/src/utils/SafeTransfer.sol index 4cec84caf9..0611bb4b0d 100644 --- a/contracts/src/utils/SafeTransfer.sol +++ b/contracts/src/utils/SafeTransfer.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: 2023 Axelar Network // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import {IERC20} from "../interfaces/IERC20.sol"; diff --git a/contracts/src/utils/ScaleCodec.sol b/contracts/src/utils/ScaleCodec.sol index 57a4388e48..2790543538 100644 --- a/contracts/src/utils/ScaleCodec.sol +++ b/contracts/src/utils/ScaleCodec.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; library ScaleCodec { error UnsupportedCompactEncoding(); diff --git a/contracts/src/utils/SubstrateMerkleProof.sol b/contracts/src/utils/SubstrateMerkleProof.sol index 7626fe1112..b5683da42a 100644 --- a/contracts/src/utils/SubstrateMerkleProof.sol +++ b/contracts/src/utils/SubstrateMerkleProof.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; // Used to verify merkle proofs generated by https://github.com/paritytech/substrate/tree/master/utils/binary-merkle-tree library SubstrateMerkleProof { diff --git a/contracts/test/Agent.t.sol b/contracts/test/Agent.t.sol index 44bc55aacd..eb7fcae689 100644 --- a/contracts/test/Agent.t.sol +++ b/contracts/test/Agent.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/contracts/test/BeefyClient.t.sol b/contracts/test/BeefyClient.t.sol index 8835bab3f1..2c68d02681 100644 --- a/contracts/test/BeefyClient.t.sol +++ b/contracts/test/BeefyClient.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import {Strings} from "openzeppelin/utils/Strings.sol"; import {Test} from "forge-std/Test.sol"; diff --git a/contracts/test/Counter.t.sol b/contracts/test/Counter.t.sol index 048af28c6d..87518caa3f 100644 --- a/contracts/test/Counter.t.sol +++ b/contracts/test/Counter.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/contracts/test/Gateway.t.sol b/contracts/test/Gateway.t.sol index 3076cfdbf6..ba49b37244 100644 --- a/contracts/test/Gateway.t.sol +++ b/contracts/test/Gateway.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import {Test} from "forge-std/Test.sol"; import {Strings} from "openzeppelin/utils/Strings.sol"; @@ -156,7 +156,7 @@ contract GatewayTest is Test { // Expect the gateway to emit `InboundMessageDispatched` vm.expectEmit(true, false, false, false); - emit InboundMessageDispatched(bridgeHubParaID, 1, true); + emit IGateway.InboundMessageDispatched(bridgeHubParaID, 1, true); hoax(relayer, 1 ether); IGateway(address(gateway)).submitInbound( @@ -337,7 +337,7 @@ contract GatewayTest is Test { Gateway.CreateAgentParams memory params = Gateway.CreateAgentParams({agentID: agentID}); vm.expectEmit(false, false, false, false, address(gateway)); - emit AgentCreated(agentID, address(0)); + emit IGateway.AgentCreated(agentID, address(0)); GatewayMock(address(gateway)).createAgentPublic(abi.encode(params)); } @@ -361,7 +361,7 @@ contract GatewayTest is Test { Gateway.CreateChannelParams memory params = Gateway.CreateChannelParams({paraID: paraID, agentID: agentID}); vm.expectEmit(true, false, false, true); - emit ChannelCreated(paraID); + emit IGateway.ChannelCreated(paraID); GatewayMock(address(gateway)).createChannelPublic(abi.encode(params)); } @@ -400,7 +400,7 @@ contract GatewayTest is Test { ); vm.expectEmit(true, false, false, true); - emit ChannelUpdated(assetHubParaID); + emit IGateway.ChannelUpdated(assetHubParaID); GatewayMock(address(gateway)).updateChannelPublic(params); uint256 fee = IGateway(address(gateway)).channelFeeOf(assetHubParaID); @@ -447,7 +447,7 @@ contract GatewayTest is Test { // Expect the gateway to emit `Upgraded` vm.expectEmit(true, false, false, false); - emit Upgraded(address(newLogic)); + emit IGateway.Upgraded(address(newLogic)); GatewayMock(address(gateway)).upgradePublic(abi.encode(params)); @@ -470,7 +470,7 @@ contract GatewayTest is Test { // Expect the gateway to emit `Initialized` vm.expectEmit(true, false, false, true); - emit Initialized(d0, d1); + emit GatewayUpgradeMock.Initialized(d0, d1); GatewayMock(address(gateway)).upgradePublic(abi.encode(params)); } @@ -535,17 +535,17 @@ contract GatewayTest is Test { emit TokenRegistrationSent(address(token)); vm.expectEmit(true, false, false, false); - emit OutboundMessageAccepted(assetHubParaID, 1, SubstrateTypes.RegisterToken(address(token))); + emit IGateway.OutboundMessageAccepted(assetHubParaID, 1, SubstrateTypes.RegisterToken(address(token))); IGateway(address(gateway)).registerToken{value: 2 ether}(address(token)); } function testRegisterTokenReimbursesExcessFees() public { vm.expectEmit(false, false, false, true); - emit TokenRegistrationSent(address(token)); + emit IGateway.TokenRegistrationSent(address(token)); vm.expectEmit(true, false, false, false); - emit OutboundMessageAccepted(assetHubParaID, 1, SubstrateTypes.RegisterToken(address(token))); + emit IGateway.OutboundMessageAccepted(assetHubParaID, 1, SubstrateTypes.RegisterToken(address(token))); uint256 totalFee = baseFee + registerNativeTokenFee; uint256 balanceBefore = address(this).balance; @@ -567,11 +567,11 @@ contract GatewayTest is Test { bytes32 destAddress = keccak256("/Alice"); vm.expectEmit(true, true, false, true); - emit TokenSent(address(this), address(token), destPara, abi.encodePacked(destAddress), 1); + emit IGateway.TokenSent(address(this), address(token), destPara, abi.encodePacked(destAddress), 1); // Expect the gateway to emit `OutboundMessageAccepted` vm.expectEmit(true, false, false, false); - emit OutboundMessageAccepted( + emit IGateway.OutboundMessageAccepted( assetHubParaID, 1, SubstrateTypes.SendToken(address(token), destPara, destAddress, 1) ); @@ -587,11 +587,13 @@ contract GatewayTest is Test { bytes32 destAddress = keccak256("/Alice"); vm.expectEmit(true, true, false, true); - emit TokenSent(address(this), address(token), destPara, abi.encodePacked(destAddress), 1); + emit IGateway.TokenSent(address(this), address(token), destPara, abi.encodePacked(destAddress), 1); // Expect the gateway to emit `OutboundMessageAccepted` vm.expectEmit(true, false, false, false); - emit OutboundMessageAccepted(assetHubParaID, 1, SubstrateTypes.SendToken(address(token), destAddress, 1)); + emit IGateway.OutboundMessageAccepted( + assetHubParaID, 1, SubstrateTypes.SendToken(address(token), destAddress, 1) + ); IGateway(address(gateway)).sendToken{value: 2 ether}(address(token), destPara, destAddress, 1); } @@ -605,11 +607,11 @@ contract GatewayTest is Test { address destAddress = makeAddr("/Alice"); vm.expectEmit(true, true, false, true); - emit TokenSent(address(this), address(token), destPara, abi.encodePacked(destAddress), 1); + emit IGateway.TokenSent(address(this), address(token), destPara, abi.encodePacked(destAddress), 1); // Expect the gateway to emit `OutboundMessageAccepted` vm.expectEmit(true, false, false, false); - emit OutboundMessageAccepted(assetHubParaID, 1, hex""); + emit IGateway.OutboundMessageAccepted(assetHubParaID, 1, hex""); IGateway(address(gateway)).sendToken{value: 2 ether}(address(token), destPara, destAddress, 1); } @@ -741,7 +743,7 @@ contract GatewayTest is Test { vm.expectEmit(true, false, false, true); // Expect dispatch result as false for `OutOfGas` - emit InboundMessageDispatched(bridgeHubParaID, 1, false); + emit IGateway.InboundMessageDispatched(bridgeHubParaID, 1, false); // maxDispatchGas as 1 for `create_agent` is definitely not enough IGateway(address(gateway)).submitInbound( InboundMessage(bridgeHubParaID, 1, command, params, 1, maxRefund, reward), proof, makeMockProof() diff --git a/contracts/test/MMRProof.t.sol b/contracts/test/MMRProof.t.sol index 0fa64c6f58..df32f90956 100644 --- a/contracts/test/MMRProof.t.sol +++ b/contracts/test/MMRProof.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import {Test} from "forge-std/Test.sol"; import {console} from "forge-std/console.sol"; diff --git a/contracts/test/Math.t.sol b/contracts/test/Math.t.sol index 2b3ac97b14..df61c8cd5c 100644 --- a/contracts/test/Math.t.sol +++ b/contracts/test/Math.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/contracts/test/ScaleCodec.t.sol b/contracts/test/ScaleCodec.t.sol index 51a8918183..e5f6a156e8 100644 --- a/contracts/test/ScaleCodec.t.sol +++ b/contracts/test/ScaleCodec.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import "forge-std/Test.sol"; import "forge-std/console.sol"; diff --git a/contracts/test/Verification.t.sol b/contracts/test/Verification.t.sol index e6eef51682..7e6ce46478 100644 --- a/contracts/test/Verification.t.sol +++ b/contracts/test/Verification.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import "openzeppelin/utils/Strings.sol"; import "forge-std/Test.sol"; diff --git a/contracts/test/mocks/BeefyClientMock.sol b/contracts/test/mocks/BeefyClientMock.sol index 7d16494574..8d35a2a2e0 100644 --- a/contracts/test/mocks/BeefyClientMock.sol +++ b/contracts/test/mocks/BeefyClientMock.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import {BeefyClient} from "../../src/BeefyClient.sol"; import {Counter} from "../../src/utils/Counter.sol"; diff --git a/contracts/test/mocks/GatewayMock.sol b/contracts/test/mocks/GatewayMock.sol index c265c440b6..0c44cc7cfe 100644 --- a/contracts/test/mocks/GatewayMock.sol +++ b/contracts/test/mocks/GatewayMock.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import {Gateway} from "../../src/Gateway.sol"; import {ParaID, OperatingMode} from "../../src/Types.sol"; diff --git a/contracts/test/mocks/GatewayUpgradeMock.sol b/contracts/test/mocks/GatewayUpgradeMock.sol index fcd7065150..952956ef0f 100644 --- a/contracts/test/mocks/GatewayUpgradeMock.sol +++ b/contracts/test/mocks/GatewayUpgradeMock.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pragma solidity 0.8.20; +pragma solidity 0.8.22; import {Channel, InboundMessage, OperatingMode, ParaID, Config, Command} from "../../src/Types.sol"; import {IGateway} from "../../src/interfaces/IGateway.sol"; diff --git a/contracts/test/mocks/MMRProofWrapper.sol b/contracts/test/mocks/MMRProofWrapper.sol index d6d9c6fe93..6c4e141382 100644 --- a/contracts/test/mocks/MMRProofWrapper.sol +++ b/contracts/test/mocks/MMRProofWrapper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import {MMRProof} from "../../src/utils/MMRProof.sol"; diff --git a/contracts/test/mocks/VerificationWrapper.sol b/contracts/test/mocks/VerificationWrapper.sol index d08b9426c6..8aee920d9c 100644 --- a/contracts/test/mocks/VerificationWrapper.sol +++ b/contracts/test/mocks/VerificationWrapper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.20; +pragma solidity 0.8.22; import {Verification} from "../../src/Verification.sol"; diff --git a/flake.lock b/flake.lock index cfc607bc64..d2cf413115 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1688462028, - "narHash": "sha256-+43L9rwbNC1cO0LrinxjaolmyIH/STpL67uf2s6+6C0=", + "lastModified": 1699089190, + "narHash": "sha256-t9W8eIeJBUVt6n8sfDrG9J/t0B4KZ73M3ARis+DwQhM=", "owner": "shazow", "repo": "foundry.nix", - "rev": "e8fb5553c880942ac5215fb210ada54841605c62", + "rev": "fc064153ac002e825724ff2091cd91e7d501ffef", "type": "github" }, "original": { diff --git a/relayer/contracts/gateway.go b/relayer/contracts/gateway.go index b3d656e0ea..75c8d29c0f 100644 --- a/relayer/contracts/gateway.go +++ b/relayer/contracts/gateway.go @@ -84,7 +84,7 @@ type VerificationProof struct { // GatewayMetaData contains all meta data concerning the Gateway contract. var GatewayMetaData = &bind.MetaData{ - ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"agentID\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"agent\",\"type\":\"address\"}],\"name\":\"AgentCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"agentID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"AgentFundsWithdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"ChannelCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"ChannelUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"ParaID\",\"name\":\"origin\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"name\":\"InboundMessageDispatched\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"enumOperatingMode\",\"name\":\"mode\",\"type\":\"uint8\"}],\"name\":\"OperatingModeChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"ParaID\",\"name\":\"destination\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"}],\"name\":\"OutboundMessageAccepted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"agentID\",\"type\":\"bytes32\"}],\"name\":\"agentOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"channelFeeOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"channelNoncesOf\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"channelOperatingModeOf\",\"outputs\":[{\"internalType\":\"enumOperatingMode\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"operatingMode\",\"outputs\":[{\"internalType\":\"enumOperatingMode\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"registerToken\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"ParaID\",\"name\":\"destinationChain\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"destinationAddress\",\"type\":\"bytes32\"},{\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"sendToken\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"ParaID\",\"name\":\"destinationChain\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"sendToken\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"ParaID\",\"name\":\"origin\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"nonce\",\"type\":\"uint64\"},{\"internalType\":\"enumCommand\",\"name\":\"command\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"params\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"maxDispatchGas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxRefund\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"internalType\":\"structInboundMessage\",\"name\":\"message\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"leafProof\",\"type\":\"bytes32[]\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"parentHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"number\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"extrinsicsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"kind\",\"type\":\"uint256\"},{\"internalType\":\"bytes4\",\"name\":\"consensusEngineID\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"structVerification.DigestItem[]\",\"name\":\"digestItems\",\"type\":\"tuple[]\"}],\"internalType\":\"structVerification.ParachainHeader\",\"name\":\"header\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pos\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"width\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"internalType\":\"structVerification.HeadProof\",\"name\":\"headProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"parentNumber\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"parentHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"nextAuthoritySetID\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"nextAuthoritySetLen\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"nextAuthoritySetRoot\",\"type\":\"bytes32\"}],\"internalType\":\"structVerification.MMRLeafPartial\",\"name\":\"leafPartial\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"leafProof\",\"type\":\"bytes32[]\"},{\"internalType\":\"uint256\",\"name\":\"leafProofOrder\",\"type\":\"uint256\"}],\"internalType\":\"structVerification.Proof\",\"name\":\"headerProof\",\"type\":\"tuple\"}],\"name\":\"submitInbound\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"agentID\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"agent\",\"type\":\"address\"}],\"name\":\"AgentCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"agentID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"AgentFundsWithdrawn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"ChannelCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"ChannelUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"ParaID\",\"name\":\"origin\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"name\":\"InboundMessageDispatched\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"enumOperatingMode\",\"name\":\"mode\",\"type\":\"uint8\"}],\"name\":\"OperatingModeChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"ParaID\",\"name\":\"destination\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"}],\"name\":\"OutboundMessageAccepted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"TokenRegistrationSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"ParaID\",\"name\":\"destinationChain\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"destinationAddress\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"TokenSent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"agentID\",\"type\":\"bytes32\"}],\"name\":\"agentOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"channelFeeOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"channelNoncesOf\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"ParaID\",\"name\":\"paraID\",\"type\":\"uint256\"}],\"name\":\"channelOperatingModeOf\",\"outputs\":[{\"internalType\":\"enumOperatingMode\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"operatingMode\",\"outputs\":[{\"internalType\":\"enumOperatingMode\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"registerToken\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"ParaID\",\"name\":\"destinationChain\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"destinationAddress\",\"type\":\"bytes32\"},{\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"sendToken\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"ParaID\",\"name\":\"destinationChain\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"destinationAddress\",\"type\":\"address\"},{\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"sendToken\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"ParaID\",\"name\":\"origin\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"nonce\",\"type\":\"uint64\"},{\"internalType\":\"enumCommand\",\"name\":\"command\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"params\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"maxDispatchGas\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"maxRefund\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"internalType\":\"structInboundMessage\",\"name\":\"message\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"leafProof\",\"type\":\"bytes32[]\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"parentHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"number\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"stateRoot\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"extrinsicsRoot\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"kind\",\"type\":\"uint256\"},{\"internalType\":\"bytes4\",\"name\":\"consensusEngineID\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"structVerification.DigestItem[]\",\"name\":\"digestItems\",\"type\":\"tuple[]\"}],\"internalType\":\"structVerification.ParachainHeader\",\"name\":\"header\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"pos\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"width\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"internalType\":\"structVerification.HeadProof\",\"name\":\"headProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"},{\"internalType\":\"uint32\",\"name\":\"parentNumber\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"parentHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"nextAuthoritySetID\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"nextAuthoritySetLen\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"nextAuthoritySetRoot\",\"type\":\"bytes32\"}],\"internalType\":\"structVerification.MMRLeafPartial\",\"name\":\"leafPartial\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"leafProof\",\"type\":\"bytes32[]\"},{\"internalType\":\"uint256\",\"name\":\"leafProofOrder\",\"type\":\"uint256\"}],\"internalType\":\"structVerification.Proof\",\"name\":\"headerProof\",\"type\":\"tuple\"}],\"name\":\"submitInbound\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", } // GatewayABI is the input ABI used to generate the binding from. @@ -1507,6 +1507,296 @@ func (_Gateway *GatewayFilterer) ParseOutboundMessageAccepted(log types.Log) (*G return event, nil } +// GatewayTokenRegistrationSentIterator is returned from FilterTokenRegistrationSent and is used to iterate over the raw logs and unpacked data for TokenRegistrationSent events raised by the Gateway contract. +type GatewayTokenRegistrationSentIterator struct { + Event *GatewayTokenRegistrationSent // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *GatewayTokenRegistrationSentIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(GatewayTokenRegistrationSent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(GatewayTokenRegistrationSent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *GatewayTokenRegistrationSentIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *GatewayTokenRegistrationSentIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// GatewayTokenRegistrationSent represents a TokenRegistrationSent event raised by the Gateway contract. +type GatewayTokenRegistrationSent struct { + Token common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTokenRegistrationSent is a free log retrieval operation binding the contract event 0xf78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7e. +// +// Solidity: event TokenRegistrationSent(address token) +func (_Gateway *GatewayFilterer) FilterTokenRegistrationSent(opts *bind.FilterOpts) (*GatewayTokenRegistrationSentIterator, error) { + + logs, sub, err := _Gateway.contract.FilterLogs(opts, "TokenRegistrationSent") + if err != nil { + return nil, err + } + return &GatewayTokenRegistrationSentIterator{contract: _Gateway.contract, event: "TokenRegistrationSent", logs: logs, sub: sub}, nil +} + +// WatchTokenRegistrationSent is a free log subscription operation binding the contract event 0xf78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7e. +// +// Solidity: event TokenRegistrationSent(address token) +func (_Gateway *GatewayFilterer) WatchTokenRegistrationSent(opts *bind.WatchOpts, sink chan<- *GatewayTokenRegistrationSent) (event.Subscription, error) { + + logs, sub, err := _Gateway.contract.WatchLogs(opts, "TokenRegistrationSent") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(GatewayTokenRegistrationSent) + if err := _Gateway.contract.UnpackLog(event, "TokenRegistrationSent", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTokenRegistrationSent is a log parse operation binding the contract event 0xf78bb28d4b1d7da699e5c0bc2be29c2b04b5aab6aacf6298fe5304f9db9c6d7e. +// +// Solidity: event TokenRegistrationSent(address token) +func (_Gateway *GatewayFilterer) ParseTokenRegistrationSent(log types.Log) (*GatewayTokenRegistrationSent, error) { + event := new(GatewayTokenRegistrationSent) + if err := _Gateway.contract.UnpackLog(event, "TokenRegistrationSent", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// GatewayTokenSentIterator is returned from FilterTokenSent and is used to iterate over the raw logs and unpacked data for TokenSent events raised by the Gateway contract. +type GatewayTokenSentIterator struct { + Event *GatewayTokenSent // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *GatewayTokenSentIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(GatewayTokenSent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(GatewayTokenSent) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *GatewayTokenSentIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *GatewayTokenSentIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// GatewayTokenSent represents a TokenSent event raised by the Gateway contract. +type GatewayTokenSent struct { + Token common.Address + Sender common.Address + DestinationChain *big.Int + DestinationAddress []byte + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTokenSent is a free log retrieval operation binding the contract event 0x37ae4af9ee081dc143413d47231db2ed06e556615d5164b33c40142e1d4c46f5. +// +// Solidity: event TokenSent(address indexed token, address indexed sender, uint256 destinationChain, bytes destinationAddress, uint128 amount) +func (_Gateway *GatewayFilterer) FilterTokenSent(opts *bind.FilterOpts, token []common.Address, sender []common.Address) (*GatewayTokenSentIterator, error) { + + var tokenRule []interface{} + for _, tokenItem := range token { + tokenRule = append(tokenRule, tokenItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Gateway.contract.FilterLogs(opts, "TokenSent", tokenRule, senderRule) + if err != nil { + return nil, err + } + return &GatewayTokenSentIterator{contract: _Gateway.contract, event: "TokenSent", logs: logs, sub: sub}, nil +} + +// WatchTokenSent is a free log subscription operation binding the contract event 0x37ae4af9ee081dc143413d47231db2ed06e556615d5164b33c40142e1d4c46f5. +// +// Solidity: event TokenSent(address indexed token, address indexed sender, uint256 destinationChain, bytes destinationAddress, uint128 amount) +func (_Gateway *GatewayFilterer) WatchTokenSent(opts *bind.WatchOpts, sink chan<- *GatewayTokenSent, token []common.Address, sender []common.Address) (event.Subscription, error) { + + var tokenRule []interface{} + for _, tokenItem := range token { + tokenRule = append(tokenRule, tokenItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Gateway.contract.WatchLogs(opts, "TokenSent", tokenRule, senderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(GatewayTokenSent) + if err := _Gateway.contract.UnpackLog(event, "TokenSent", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTokenSent is a log parse operation binding the contract event 0x37ae4af9ee081dc143413d47231db2ed06e556615d5164b33c40142e1d4c46f5. +// +// Solidity: event TokenSent(address indexed token, address indexed sender, uint256 destinationChain, bytes destinationAddress, uint128 amount) +func (_Gateway *GatewayFilterer) ParseTokenSent(log types.Log) (*GatewayTokenSent, error) { + event := new(GatewayTokenSent) + if err := _Gateway.contract.UnpackLog(event, "TokenSent", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // GatewayUpgradedIterator is returned from FilterUpgraded and is used to iterate over the raw logs and unpacked data for Upgraded events raised by the Gateway contract. type GatewayUpgradedIterator struct { Event *GatewayUpgraded // Event containing the contract specifics and raw log diff --git a/smoketest/Cargo.lock b/smoketest/Cargo.lock index c07954495c..6d737b6665 100644 --- a/smoketest/Cargo.lock +++ b/smoketest/Cargo.lock @@ -3796,6 +3796,7 @@ dependencies = [ "hex", "hex-literal", "parity-scale-codec", + "serde", "sp-core 16.0.0", "staging-xcm", "subxt", diff --git a/smoketest/Cargo.toml b/smoketest/Cargo.toml index 5f3a950724..f82f1af784 100644 --- a/smoketest/Cargo.toml +++ b/smoketest/Cargo.toml @@ -11,6 +11,7 @@ tokio = { version = "1.28.2", features = ["rt-multi-thread", "macros", "time"] } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] } hex = "0.4.3" hex-literal = "0.4.1" +serde = { version = "1.0", features = ["derive"] } subxt = { git = "https://github.com/paritytech/subxt.git", tag = "v0.27.1" } ethers = { git = "https://github.com/gakonst/ethers-rs", default-features = false, features = ["abigen", "ws"] } sp-core = "16.0.0"