Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add solidity multi protocol xCall #86

Merged
merged 30 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
165943c
WIP: inital conversion into multi-protocol
AntonAndell Jul 20, 2023
d3c2121
feat: setup foundry structure (#79)
sdpisreddevil Sep 18, 2023
0fecbc5
feat: testcase set admin (#80)
sdpisreddevil Sep 18, 2023
c082f15
feat: testcase set protocol fee (#81)
sdpisreddevil Sep 18, 2023
632a3bc
feat: testcase set protocol fee handler (#82)
sdpisreddevil Sep 18, 2023
6227495
fix: add default connection setter (#87)
sdpisreddevil Sep 19, 2023
8959749
fix: rlp encode library encoding fix for protocols (#89)
sdpisreddevil Sep 19, 2023
10d84e8
feat: handle requests multiple testcases (#90)
sdpisreddevil Sep 21, 2023
1237c0f
add successfulResponses record for responses
sdpisreddevil Sep 25, 2023
89b50aa
update successfulResponses variable after response is success
sdpisreddevil Sep 25, 2023
7a96955
feat: execute call testcases (#91)
sdpisreddevil Sep 26, 2023
42b2740
fix: clearing out unused code (#98)
gcranju Sep 26, 2023
e979f07
docs: solidity xcall deployment (#99)
sdpisreddevil Sep 26, 2023
6af358b
feat: rollback testcases (#92)
sdpisreddevil Sep 26, 2023
e1a914e
feat: execute rollback testcases (#93)
sdpisreddevil Sep 26, 2023
d69e2da
fix: testcase for send call message (#88)
sdpisreddevil Sep 26, 2023
665071e
fix: deployment script updated (#100)
gcranju Sep 27, 2023
94d2410
fix: add verify success test cases (#101)
sdpisreddevil Sep 28, 2023
98994e7
tests: Fix testExecuteRollbackMultiProtocol test
sdpisreddevil Oct 11, 2023
b529488
feat: ci add solidity code coverages (#140)
sdpisreddevil Oct 11, 2023
4acea42
refactor: evm folder structure
redlarva Oct 11, 2023
0e901e3
fix: solidity xcall cod coverage
redlarva Oct 11, 2023
e6c5842
feat: added evm multiprotocol dapp
gcranju Oct 11, 2023
086831b
fix: removed unnecessary imports
gcranju Oct 11, 2023
1351c38
fix: remove cache file
redlarva Oct 11, 2023
16c6fb2
fix: add cache to gitignore
redlarva Oct 11, 2023
f683146
Merge pull request #143 from icon-project/refactor/evm-folder-structure
sdpisreddevil Oct 11, 2023
317fb8b
fix: Add full expects of sendMessage to connections
AntonAndell Oct 23, 2023
e2fb483
Merge remote-tracking branch 'origin/main' into feature/add-evm-multi…
AntonAndell Oct 23, 2023
f60af4f
Ignore libraries in solidity code coverage
AntonAndell Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/solidity-contracts-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Solidity Contracts tests

on:
pull_request:
branches:
- "**"
paths:
- "contracts/evm/**"
- ".github/workflows/solidity-cov.yml"
push:
branches:
- "**"

env:
FOUNDRY_PROFILE: ci

defaults:
run:
working-directory: contracts/evm

jobs:
check:
strategy:
fail-fast: true

name: xCall-Multi Solidity Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run Forge build
run: |
forge --version
forge remappings
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge test -vvv
id: test
53 changes: 53 additions & 0 deletions .github/workflows/solidity-cov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Solidity contracts Codecov

env:
FOUNDRY_PROFILE: ci

on:
pull_request:
branches:
- "**"
paths:
- "contracts/evm/**"
- ".github/workflows/solidity-cov.yml"
push:
branches:
- "**"

defaults:
run:
working-directory: contracts/evm

jobs:
code-coverage:
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Build Contracts
run: |
forge remappings
forge build

- name: Generate code coverage
run: |
export PATH=$PATH:$HOME/.config/.foundry/bin
forge coverage --report lcov
sudo apt-get install lcov
lcov --remove lcov.info 'test/*' 'script/*' 'library/*' '**/libraries/**' > lcov2.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov2.info
flags: solidity
fail_ci_if_error: true
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,6 @@ lcov.info


vendor/**
scripts/download_buf.sh
scripts/download_buf.sh

cache/
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "contracts/evm/xcall/lib/forge-std"]
path = contracts/evm/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/evm/xcall/lib/openzeppelin-contracts-upgradeable"]
path = contracts/evm/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "contracts/evm/xcall/lib/openzeppelin-contracts"]
path = contracts/evm/lib/openzeppelin-contracts
url = https://github.com/Openzeppelin/openzeppelin-contracts
23 changes: 23 additions & 0 deletions contracts/evm/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PRIVATE_KEY=""
OWNER_ADDRESS=

PROTOCOL_FEE=0

# BINANCE TESTNET NETWORK SETUP
BINANCE_TESTNET_RPC_URL=http://127.0.0.1:9545/
BSC_NID=*
BSC_SCAN_API_KEY=

# BMC ADDRESS FOR ICON BERLIN TESTNET
ICON_NID=*
BMC_ADDRESS="cx000"


# BINANCE MAINNET NETWORK SETUP
BINANCE_MAINNET_RPC_URL=http://127.0.0.1:9545/
BSC_NID=*
BSC_SCAN_API_KEY=

# BMC ADDRESS FOR ICON MAINNET
ICON_NID=*
BMC_ADDRESS="cx000"
Empty file removed contracts/evm/.gitkeep
Empty file.
149 changes: 149 additions & 0 deletions contracts/evm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
## Foundry

**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**

Foundry consists of:

- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.

## Documentation

https://book.getfoundry.sh/

## Usage

### Build

```shell
$ forge build
```

### Test


```shell
$ forge test -vv
```

To learn more about logs and traces, check out the documentation [here](https://book.getfoundry.sh/forge/tests?highlight=-vv#logs-and-traces).

To view all of the supported logging methods, check out the documentation [here](https://book.getfoundry.sh/reference/ds-test#logging).

### Gas Snapshots

```shell
$ forge snapshot
```

### Anvil
You can start the local EVM test network at any time:

```shell
$ anvil
```

### Deploy

```shell
export PRIVATE_KEY=<your-private-key>

$ forge script script/CallService.s.sol:CallServiceScript --rpc-url <your_rpc_url> --private-key <your_private_key>

For Example: (deploying the contract on localnet)
$ forge script script/CallService.s.sol:CallServiceScript --fork-url http://localhost:8545 \
--private-key $PRIVATE_KEY --broadcast

```


### Cast
Set the CONTRACT_ADDRESS variable in your terminal:

```sh
export CONTRACT_ADDRESS=<your-contract-address>
```

Call initialize on the contract

```sh
cast send $CONTRACT_ADDRESS "initialize(string)" "ENTER Chain NID HERE" --private-key $PRIVATE_KEY
```

We can then use cast to interact with it.

For read operations, we can use cast call: For Example:

```sh
cast call $CONTRACT_ADDRESS "admin()(address)"
```

For transactions, we can use cast send, passing in a private key and any arguments:

```sh
cast send $CONTRACT_ADDRESS "setAdmin(address)" 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc --private-key $PRIVATE_KEY
```

To test that the greeting has been updated, run the `call` command again:

```sh
cast call $CONTRACT_ADDRESS "admin()(address)"
```


## Installing packages

You can install packages using the `forge install` command.

To try this out, let's install OpenZeppelin Contracts, then we'll use them to create an ERC721 token:

> You may need to add and commit any changes to your code to `git` in order to run the install script.

```sh
forge install OpenZeppelin/openzeppelin-contracts
```

Next, create a file named `remappings.txt` in the root of the project and add the following configuration:

```
@openzeppelin/=lib/openzeppelin-contracts/
```

This will allow us to easily import with the following syntax:

```solidity
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
```

You can view all of the automatically inferred remappings for the project by running the following command:

```sh
forge remappings
```


### Test coverage

You can check for test coverage by running the `coverage` command:

```sh
forge coverage
```

To debug in more details what has not been covered, use the `debug` report:

```sh
forge coverage --report debug
```



### Help

```shell
$ forge --help
$ anvil --help
$ cast --help
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.8.0;
pragma abicoder v2;

import "openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";

contract LayerZeroAdapter is Initializable {
}
8 changes: 8 additions & 0 deletions contracts/evm/contracts/adapters/wormhole/WormholeAdapter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.8.0;
pragma abicoder v2;

import "openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol";

contract WormholeAdapter is Initializable {
}
Loading