diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d8a4c30ae7..e5160e9c6a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ Description of the upcoming release here. ### Changed +- [#1302](https://github.com/FuelLabs/fuel-core/pull/1302): Removed the usage of flake and building of the bridge contract ABI. + It simplifies the maintenance and updating of the events, requiring only putting the event definition into the codebase of the relayer. - [#1293](https://github.com/FuelLabs/fuel-core/issues/1293): Parallelized the `estimate_predicates` endpoint to utilize all available threads. #### Breaking diff --git a/crates/services/relayer/README.md b/crates/services/relayer/README.md index 260eaf344c7..37c13ced9c1 100644 --- a/crates/services/relayer/README.md +++ b/crates/services/relayer/README.md @@ -25,22 +25,3 @@ If the state determines that the relayer is out of sync with the DA layer then l The range of blocks is `(last_downloaded_height + 1)..=current_finalized_height`. Logs are paginated into sets of blocks to avoid overloading a single rpc call. - -## Contract Flake -The `flake.nix` in this repo has a tool to fetch, compile and generate the abi for the fuel contracts. -While it is not mandatory to use nix to do this the advantage is the exact versions of the contracts that were used to generate the abi files is pinned in the `flake.lock` file. - -### Usage -To generate the api files run the following from the `fuel-core-relayer` directory. -```bash -nix run .#generate-abi-json abi -``` -To update the version of the contracts that is used run: -```bash -nix flake update -nix run .#generate-abi-json abi -``` -You can see the versions that are pinned by running: -```bash -nix flake info -``` \ No newline at end of file diff --git a/crates/services/relayer/abi/FuelMessagePortal.json b/crates/services/relayer/abi/FuelMessagePortal.json deleted file mode 100644 index 1d686c0d685..00000000000 --- a/crates/services/relayer/abi/FuelMessagePortal.json +++ /dev/null @@ -1,736 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "messageId", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "sender", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "recipient", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint64", - "name": "amount", - "type": "uint64" - } - ], - "name": "MessageRelayed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "sender", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "recipient", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint64", - "name": "amount", - "type": "uint64" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "MessageSent", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Paused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "previousAdminRole", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "newAdminRole", - "type": "bytes32" - } - ], - "name": "RoleAdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleGranted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "account", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "sender", - "type": "address" - } - ], - "name": "RoleRevoked", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "Unpaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "inputs": [], - "name": "DEFAULT_ADMIN_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "ETH_DECIMALS", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "FUEL_BASE_ASSET_DECIMALS", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "MAX_MESSAGE_DATA_SIZE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "PAUSER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "recipient", - "type": "bytes32" - } - ], - "name": "depositETH", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [], - "name": "fuelBaseAssetDecimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [], - "name": "fuelChainConsensusContract", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - } - ], - "name": "getRoleAdmin", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "grantRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "hasRole", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "messageId", - "type": "bytes32" - } - ], - "name": "incomingMessageSuccessful", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract FuelChainConsensus", - "name": "fuelChainConsensus", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "messageSender", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "paused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "proxiableUUID", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes32", - "name": "sender", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "recipient", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "nonce", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "amount", - "type": "uint64" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "internalType": "struct Message", - "name": "message", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "bytes32", - "name": "prevRoot", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "height", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "timestamp", - "type": "uint64" - }, - { - "internalType": "bytes32", - "name": "applicationHash", - "type": "bytes32" - } - ], - "internalType": "struct FuelBlockHeaderLite", - "name": "rootBlockHeader", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "bytes32", - "name": "prevRoot", - "type": "bytes32" - }, - { - "internalType": "uint64", - "name": "height", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "timestamp", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "daHeight", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "txCount", - "type": "uint64" - }, - { - "internalType": "uint64", - "name": "outputMessagesCount", - "type": "uint64" - }, - { - "internalType": "bytes32", - "name": "txRoot", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "outputMessagesRoot", - "type": "bytes32" - } - ], - "internalType": "struct FuelBlockHeader", - "name": "blockHeader", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "key", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "proof", - "type": "bytes32[]" - } - ], - "internalType": "struct MerkleProof", - "name": "blockInHistoryProof", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint256", - "name": "key", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "proof", - "type": "bytes32[]" - } - ], - "internalType": "struct MerkleProof", - "name": "messageInBlockProof", - "type": "tuple" - } - ], - "name": "relayMessage", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "renounceRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "role", - "type": "bytes32" - }, - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "revokeRole", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "recipient", - "type": "bytes32" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "sendMessage", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "unpause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - } -] \ No newline at end of file diff --git a/crates/services/relayer/flake.lock b/crates/services/relayer/flake.lock deleted file mode 100644 index 7170f71583b..00000000000 --- a/crates/services/relayer/flake.lock +++ /dev/null @@ -1,129 +0,0 @@ -{ - "nodes": { - "dapptools": { - "flake": false, - "locked": { - "lastModified": 1663083918, - "narHash": "sha256-JVRKYeHidAdaqzypn4UZvJ/1WGCt8nK7VUm5W7KDZyA=", - "owner": "dapphub", - "repo": "dapptools", - "rev": "01ef8ea418c3fe49089a44d56013d8fcc34a1ec2", - "type": "github" - }, - "original": { - "owner": "dapphub", - "ref": "master", - "repo": "dapptools", - "type": "github" - } - }, - "fuel-v1-contracts": { - "flake": false, - "locked": { - "lastModified": 1659016279, - "narHash": "sha256-naEkyaXa5BROsIDas1sYdJ5mvZPK1j/ftB7i7k5BqzM=", - "owner": "FuelLabs", - "repo": "fuel-merkle-sol", - "rev": "90e8463074d9c038ef7f0b15d3bb91549812bb02", - "type": "github" - }, - "original": { - "owner": "FuelLabs", - "repo": "fuel-merkle-sol", - "type": "github" - } - }, - "fuel-v2-contracts": { - "flake": false, - "locked": { - "lastModified": 1660957336, - "narHash": "sha256-J+jgpJabagUwE6Orlb5kqfBGS11psBBw5SoghUoeQyA=", - "ref": "refs/heads/master", - "rev": "3161ba9a80b827bfbb9fbc9c8f2db421db30d230", - "revCount": 209, - "type": "git", - "url": "ssh://git@github.com/fuellabs/fuel-v2-contracts/" - }, - "original": { - "type": "git", - "url": "ssh://git@github.com/fuellabs/fuel-v2-contracts/" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1664370076, - "narHash": "sha256-NDnIo0nxJozLwEw0VPM+RApMA90uTfbvaNNtC5eB7Os=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "854fdc68881791812eddd33b2fed94b954979a8e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1653917367, - "narHash": "sha256-04MsJC0g9kE01nBuXThMppZK+yvCZECQnUaZKSU+HJo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "437c8e6554911095f0557d524e9d2ffe1c26e33a", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "npm": { - "inputs": { - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1664286682, - "narHash": "sha256-OBdpqW2zpwYF/JWUk013rbMdIC3R17ynX78tQPbfHNw=", - "owner": "serokell", - "repo": "nix-npm-buildpackage", - "rev": "bc0c4989f664ff262d3ab39cad9dc0f6f1c10017", - "type": "github" - }, - "original": { - "owner": "serokell", - "repo": "nix-npm-buildpackage", - "type": "github" - } - }, - "open-zeppelin": { - "flake": false, - "locked": { - "lastModified": 1664402754, - "narHash": "sha256-Yj+YrCTmAcEYrl39YKYg3gL+rHABQi9PAqO01cC9cCc=", - "owner": "OpenZeppelin", - "repo": "openzeppelin-contracts", - "rev": "26dddee1c05ff91264ae24c5c172bd05827cf5d8", - "type": "github" - }, - "original": { - "owner": "OpenZeppelin", - "repo": "openzeppelin-contracts", - "type": "github" - } - }, - "root": { - "inputs": { - "dapptools": "dapptools", - "fuel-v1-contracts": "fuel-v1-contracts", - "fuel-v2-contracts": "fuel-v2-contracts", - "nixpkgs": "nixpkgs", - "npm": "npm", - "open-zeppelin": "open-zeppelin" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/crates/services/relayer/flake.nix b/crates/services/relayer/flake.nix deleted file mode 100644 index d68f9aa6f97..00000000000 --- a/crates/services/relayer/flake.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ - description = '' - A Nix flake for compiling and extracting the fuel contract abi. - ''; - - inputs = { - open-zeppelin = { - url = "github:OpenZeppelin/openzeppelin-contracts"; - flake = false; - }; - fuel-v1-contracts = { - url = "github:FuelLabs/fuel-merkle-sol"; - flake = false; - }; - fuel-v2-contracts.url = "git+ssh://git@github.com/fuellabs/fuel-v2-contracts/"; - fuel-v2-contracts.flake = false; - nixpkgs = { - url = "github:NixOS/nixpkgs/nixos-unstable"; - }; - dapptools = { - url = "github:dapphub/dapptools/master"; - flake = false; - }; - npm.url = "github:/serokell/nix-npm-buildpackage"; - }; - - outputs = inputs: let - system = "x86_64-darwin"; - dapp = import inputs.dapptools {inherit system;}; - solc = dapp.runCommand "solc" {} "mkdir -p $out/bin; ln -s ${dapp.solc-static-versions.solc_0_8_9}/bin/solc-0.8.9 $out/bin/solc"; - overlays = [inputs.npm.overlays.default]; - pkgs = import inputs.nixpkgs {inherit overlays system;}; - in { - packages."x86_64-darwin" = { - add-folder = pkgs.linkFarm "contracts-with-layer" [ - { - name = "merkle-sol"; - path = inputs.fuel-v1-contracts; - } - ]; - build-abi-json = - pkgs.runCommand - "build-abi-json" - {} - '' - ${solc}/bin/solc --abi --pretty-json ${inputs.fuel-v2-contracts}/contracts/sidechain/FuelSidechain.sol @openzeppelin=${inputs.open-zeppelin} @fuel-contracts=${inputs.self.packages."${system}".add-folder} -o $out/build - ''; - generate-abi-json = pkgs.writeShellApplication { - name = "generate-abi-0json"; - runtimeInputs = [solc pkgs.jq inputs.self.packages."${system}".build-abi-json]; - text = '' - if [[ -z $1 ]] - then - echo "Invalid input. Must provide output directoy" >&2; exit 1; - fi - declare -a arr=("FuelMessagePortal") - for i in "''${arr[@]}" - do - (cat ${inputs.self.packages."${system}".build-abi-json}/build/"$i".abi) | jq '.' > "$1"/"$i".json - done - ''; - }; - - - }; - formatter.x86_64-darwin = pkgs.alejandra; - }; -} diff --git a/crates/services/relayer/src/abi.rs b/crates/services/relayer/src/abi.rs index 8eb7ddd5cf5..82ea7c57ab6 100644 --- a/crates/services/relayer/src/abi.rs +++ b/crates/services/relayer/src/abi.rs @@ -2,13 +2,12 @@ use ethers_contract::abigen; pub mod bridge { - // The `FuelMessagePortal.json` file is auto-generated from contracts: - // https://github.com/FuelLabs/fuel-v2-contracts - // - // To re-generate the file: - // 1. Download the repository - // 2. Build the contracts(Check the `README.md` file for details). - // 3. Copy the content of the `abi` field in the - // `artifacts/contracts/fuelchain/FuelMessagePortal.sol/FuelMessagePortal.json` - super::abigen!(MessageSent, "abi/FuelMessagePortal.json"); + // The link to the original event definition: + // https://github.com/FuelLabs/fuel-bridge/blob/05c4d9cced70d262742e20c85c7ef8a5d8898701/packages/portal-contracts/contracts/fuelchain/FuelMessagePortal.sol#L54 + super::abigen!( + MessageSent, + r#"[ + event MessageSent(bytes32 indexed sender, bytes32 indexed recipient, uint256 indexed nonce, uint64 amount, bytes data) + ]"#, + ); }