Skip to content

Commit

Permalink
Merge pull request #10 from immutable/SMR-1773-axelar-local
Browse files Browse the repository at this point in the history
Smr 1773 axelar local
  • Loading branch information
Benjimmutable authored Oct 26, 2023
2 parents 8ee323f + 1b9ea93 commit 275d3b6
Show file tree
Hide file tree
Showing 167 changed files with 21,613 additions and 29 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ docs/
# Contract addresses
addresses.json

/node_modules
broadcast/**
broadcast/InitializeRootContracts.s.sol/2500/
broadcast/InitializeChildContracts.s.sol/2501/
broadcast/DeployRootContracts.s.sol/2500/
broadcast/DeployChildContracts.s.sol/2501/

node_modules/
60 changes: 58 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ CHILD_GAS_SERVICE_ADDRESS=
ROOT_CHAIN_NAME="ROOT"
CHILD_CHAIN_NAME="CHILD"
ROOT_IMX_ADDRESS=
CHILD_ETH_ADDRESS=
```
where `{ROOT,CHILD}_{GATEWAY,GAS_SERVICE}_ADDRESS` refers to the gateway and gas service addresses used by Axelar.

Expand All @@ -100,4 +99,61 @@ When deploying these contracts on remote networks (i.e. testnets or mainnets), t
- step 1 (deploying the networks) should be skipped.
- in step 2:
- The RPC URLs and Chain IDs should be set for the targetted networks.
- The private keys should be for addresses with which the contracts are to be deployed.
- The private keys should be for addresses with which the contracts are to be deployed.


### Axelar Local Bridge

##### One-time setup

1. install the dependencies
```shell
yarn install
```

2. compile the smart contracts
```shell
forge build
```

##### Start & setup the local blockchains

1. Start the local blockchains and local Axelar network
```shell
yarn start
```

2. Set the following env vars in your `.env` file
```shell
ROOT_RPC_URL="http://localhost:8500/0"
CHILD_RPC_URL="http://localhost:8500/1"
ROOT_CHAIN_ID="2500"
CHILD_CHAIN_ID="2501"
ROOT_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
CHILD_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
ROOT_CHAIN_NAME="Ethereum"
CHILD_CHAIN_NAME="Polygon"
ROOT_IMX_ADDRESS="0x1111111111111111111111111111111111111111"
ROOT_GATEWAY_ADDRESS="0x013459EC3E8Aeced878C5C4bFfe126A366cd19E9"
CHILD_GATEWAY_ADDRESS="0xc7B788E88BAaB770A6d4936cdcCcd5250E1bbAd8"
ROOT_GAS_SERVICE_ADDRESS="0x28f8B50E1Be6152da35e923602a2641491E71Ed8"
CHILD_GAS_SERVICE_ADDRESS="0xC573c722e21eD7fadD38A8f189818433e01Ae466"

```
(Note that `{ROOT,CHILD}_PRIVATE_KEY` can be any of the standard localhost private keys that get funded)
(Note that `ROOT_IMX_ADDRESS` is not currently used in this local environment. Therefore, any non-zero address is fine.)

3. In a separate terminal window, deploy the smart contracts
```shell
./deploy.sh
```

4. Copy the config file with the correct addresses
```shell
cp axelar-local-dev/chain-config/local.template.json axelar-local-dev/chain-config/local.json
```

5. Run the script to execute the `axelar-local-dev/examples/evm/call-contract/index.js` file
```shell
yarn run execute evm/call-contract local Ethereum Polygon
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/1a1e8429d661de5c6565e30a8f74e293.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"_format": "hh-sol-artifact-1",
"contractName": "AxelarExecutable",
"sourceName": "@axelar-network/axelar-gmp-sdk-solidity/contracts/executable/AxelarExecutable.sol",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "gateway_",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [],
"name": "InvalidAddress",
"type": "error"
},
{
"inputs": [],
"name": "NotApprovedByGateway",
"type": "error"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "commandId",
"type": "bytes32"
},
{
"internalType": "string",
"name": "sourceChain",
"type": "string"
},
{
"internalType": "string",
"name": "sourceAddress",
"type": "string"
},
{
"internalType": "bytes",
"name": "payload",
"type": "bytes"
}
],
"name": "execute",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "commandId",
"type": "bytes32"
},
{
"internalType": "string",
"name": "sourceChain",
"type": "string"
},
{
"internalType": "string",
"name": "sourceAddress",
"type": "string"
},
{
"internalType": "bytes",
"name": "payload",
"type": "bytes"
},
{
"internalType": "string",
"name": "tokenSymbol",
"type": "string"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "executeWithToken",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "gateway",
"outputs": [
{
"internalType": "contract IAxelarGateway",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
],
"bytecode": "0x60a060405234801561001057600080fd5b506040516106a33803806106a383398101604081905261002f91610067565b6001600160a01b0381166100565760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b0316608052610097565b60006020828403121561007957600080fd5b81516001600160a01b038116811461009057600080fd5b9392505050565b6080516105e46100bf60003960008181604b01528181610115015261022d01526105e46000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063116191b6146100465780631a98b2e01461009657806349160658146100ab575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100a96100a436600461032e565b6100be565b005b6100a96100b9366004610408565b6101d6565b600085856040516100d09291906104ac565b6040519081900381207f1876eed9000000000000000000000000000000000000000000000000000000008252915073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690631876eed99061015a908e908e908e908e908e9089908d908d908d906004016104e5565b602060405180830381600087803b15801561017457600080fd5b505af1158015610188573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101ac9190610544565b6101c957604051631403112d60e21b815260040160405180910390fd5b5050505050505050505050565b600082826040516101e89291906104ac565b6040519081900381207f5f6970c3000000000000000000000000000000000000000000000000000000008252915073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690635f6970c39061026c908b908b908b908b908b90899060040161056d565b602060405180830381600087803b15801561028657600080fd5b505af115801561029a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102be9190610544565b6102db57604051631403112d60e21b815260040160405180910390fd5b5050505050505050565b60008083601f8401126102f757600080fd5b50813567ffffffffffffffff81111561030f57600080fd5b60208301915083602082850101111561032757600080fd5b9250929050565b60008060008060008060008060008060c08b8d03121561034d57600080fd5b8a35995060208b013567ffffffffffffffff8082111561036c57600080fd5b6103788e838f016102e5565b909b50995060408d013591508082111561039157600080fd5b61039d8e838f016102e5565b909950975060608d01359150808211156103b657600080fd5b6103c28e838f016102e5565b909750955060808d01359150808211156103db57600080fd5b506103e88d828e016102e5565b9150809450508092505060a08b013590509295989b9194979a5092959850565b60008060008060008060006080888a03121561042357600080fd5b87359650602088013567ffffffffffffffff8082111561044257600080fd5b61044e8b838c016102e5565b909850965060408a013591508082111561046757600080fd5b6104738b838c016102e5565b909650945060608a013591508082111561048c57600080fd5b506104998a828b016102e5565b989b979a50959850939692959293505050565b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b89815260c0602082015260006104ff60c083018a8c6104bc565b828103604084015261051281898b6104bc565b9050866060840152828103608084015261052d8186886104bc565b9150508260a08301529a9950505050505050505050565b60006020828403121561055657600080fd5b8151801515811461056657600080fd5b9392505050565b8681526080602082015260006105876080830187896104bc565b828103604084015261059a8186886104bc565b91505082606083015297965050505050505056fea264697066735822122024913ccb54b441ca567a4a85d87048f1edddeeb13f48bcaa8080f7074f03636664736f6c63430008090033",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063116191b6146100465780631a98b2e01461009657806349160658146100ab575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100a96100a436600461032e565b6100be565b005b6100a96100b9366004610408565b6101d6565b600085856040516100d09291906104ac565b6040519081900381207f1876eed9000000000000000000000000000000000000000000000000000000008252915073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690631876eed99061015a908e908e908e908e908e9089908d908d908d906004016104e5565b602060405180830381600087803b15801561017457600080fd5b505af1158015610188573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101ac9190610544565b6101c957604051631403112d60e21b815260040160405180910390fd5b5050505050505050505050565b600082826040516101e89291906104ac565b6040519081900381207f5f6970c3000000000000000000000000000000000000000000000000000000008252915073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690635f6970c39061026c908b908b908b908b908b90899060040161056d565b602060405180830381600087803b15801561028657600080fd5b505af115801561029a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102be9190610544565b6102db57604051631403112d60e21b815260040160405180910390fd5b5050505050505050565b60008083601f8401126102f757600080fd5b50813567ffffffffffffffff81111561030f57600080fd5b60208301915083602082850101111561032757600080fd5b9250929050565b60008060008060008060008060008060c08b8d03121561034d57600080fd5b8a35995060208b013567ffffffffffffffff8082111561036c57600080fd5b6103788e838f016102e5565b909b50995060408d013591508082111561039157600080fd5b61039d8e838f016102e5565b909950975060608d01359150808211156103b657600080fd5b6103c28e838f016102e5565b909750955060808d01359150808211156103db57600080fd5b506103e88d828e016102e5565b9150809450508092505060a08b013590509295989b9194979a5092959850565b60008060008060008060006080888a03121561042357600080fd5b87359650602088013567ffffffffffffffff8082111561044257600080fd5b61044e8b838c016102e5565b909850965060408a013591508082111561046757600080fd5b6104738b838c016102e5565b909650945060608a013591508082111561048c57600080fd5b506104998a828b016102e5565b989b979a50959850939692959293505050565b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b89815260c0602082015260006104ff60c083018a8c6104bc565b828103604084015261051281898b6104bc565b9050866060840152828103608084015261052d8186886104bc565b9150508260a08301529a9950505050505050505050565b60006020828403121561055657600080fd5b8151801515811461056657600080fd5b9392505050565b8681526080602082015260006105876080830187896104bc565b828103604084015261059a8186886104bc565b91505082606083015297965050505050505056fea264697066735822122024913ccb54b441ca567a4a85d87048f1edddeeb13f48bcaa8080f7074f03636664736f6c63430008090033",
"linkReferences": {},
"deployedLinkReferences": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"_format": "hh-sol-dbg-1",
"buildInfo": "../../../../../build-info/1a1e8429d661de5c6565e30a8f74e293.json"
}
Loading

0 comments on commit 275d3b6

Please sign in to comment.