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: use abi encoding of ICS20Transfer payload #117

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c8b932f
start abi-encoding
sangier Nov 13, 2024
0d643e0
fix transfer tests
sangier Nov 14, 2024
b6f5619
fix test, del json related code
sangier Nov 14, 2024
36d0194
rm try catch
sangier Nov 15, 2024
1f7c77a
lint
sangier Nov 15, 2024
01ef938
Merge branch 'main' into stefano/95-abi-encoding
gjermundgaraba Nov 21, 2024
13d95a1
rename PacketDataJSON
gjermundgaraba Nov 21, 2024
a61644d
lint
gjermundgaraba Nov 22, 2024
569bb1c
fixtures and update benchmark
gjermundgaraba Nov 22, 2024
3e2c74b
move generated types into abigen folder
gjermundgaraba Nov 24, 2024
62d4be5
add comment on abi decoding
gjermundgaraba Nov 24, 2024
1a0be5c
document abigen additions more
gjermundgaraba Nov 24, 2024
9c5952c
remove unused ics20lib errors
gjermundgaraba Nov 24, 2024
938fca4
Merge branch 'main' into gjermund/116-use-abi-encoding-in-ics20transf…
gjermundgaraba Nov 24, 2024
69f2e14
add lint and test to abigen CI workflow
gjermundgaraba Nov 24, 2024
afc5fee
clean up abigen workflow
gjermundgaraba Nov 24, 2024
3eaeb64
clean up more in abigen workflow
gjermundgaraba Nov 24, 2024
f917257
use yml instead of yaml
gjermundgaraba Nov 24, 2024
5cebb4c
rename
gjermundgaraba Nov 24, 2024
df69446
fix syntax
gjermundgaraba Nov 24, 2024
2f49530
fix syntax
gjermundgaraba Nov 24, 2024
7a74b4d
generate abi
gjermundgaraba Nov 24, 2024
1da63c9
Merge branch 'main' into gjermund/116-use-abi-encoding-in-ics20transf…
gjermundgaraba Nov 24, 2024
07163f2
clean up ICS20TransferTest
gjermundgaraba Nov 24, 2024
965faec
clean up more tests
gjermundgaraba Nov 24, 2024
2977ae9
clean up IntegrationTest
gjermundgaraba Nov 24, 2024
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
32 changes: 32 additions & 0 deletions .github/workflows/abigen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,35 @@ jobs:
uses: nickcharlton/diff-check@main
with:
command: just generate-abi

golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: "1.23"
cache-dependency-path: abigen/go.sum

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
working-directory: abigen

test:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: "1.23"
cache-dependency-path: abigen/go.sum

- name: "Unit test abigen"
run: cd abigen && go test -v ./...
3 changes: 3 additions & 0 deletions .github/workflows/foundry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
push:
branches:
- "main"
paths:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really related to this, so can take it out. I just figure it would be good limit runs of this when it's not necessary.

- "src/**"
- "test/**"

jobs:
lint:
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This project is structered as a [foundry](https://getfoundry.sh/) project with t
- `test/`: Contains the Solidity tests.
- `scripts/`: Contains the Solidity scripts.
- `abi/`: Contains the ABIs of the contracts needed for end-to-end tests.
- `abigen/`: Contains the abi generated go files for the Solidity contracts.
- `e2e/`: Contains the end-to-end tests, powered by [interchaintest](https://github.com/strangelove-ventures/interchaintest).

### Contracts
Expand Down Expand Up @@ -131,11 +132,11 @@ The following benchmarks are for a single packet transfer without aggregation.

| **Contract** | **Method** | **Description** | **Gas (groth16)** | **Gas (plonk)** |
|:---:|:---:|:---:|:---:|:---:|
| `ICS26Router.sol` | `sendPacket` | Initiating an IBC transfer with an `ERC20`. | ~225,000 | ~225,000 |
| `ICS26Router.sol` | `recvPacket` | Receiving _back_ an `ERC20` token. | ~510,000 | ~588,000 |
| `ICS26Router.sol` | `recvPacket` | Receiving a _new_ Cosmos token for the first time. (Deploying an `ERC20` contract) | ~1,439,000 | ~1,527,000 |
| `ICS26Router.sol` | `ackPacket` | Acknowledging an ICS20 packet. | ~455,000 | ~533,000 |
| `ICS26Router.sol` | `timeoutPacket` | Timing out an ICS20 packet | ~480,000 | ~571,000 |
| `ICS26Router.sol` | `sendPacket` | Initiating an IBC transfer with an `ERC20`. | ~210,000 | ~210,000 |
| `ICS26Router.sol` | `recvPacket` | Receiving _back_ an `ERC20` token. | ~491,000 | ~570,000 |
| `ICS26Router.sol` | `recvPacket` | Receiving a _new_ Cosmos token for the first time. (Deploying an `ERC20` contract) | ~1,426,000 | ~1,514,000 |
| `ICS26Router.sol` | `ackPacket` | Acknowledging an ICS20 packet. | ~377,000 | ~455,000 |
| `ICS26Router.sol` | `timeoutPacket` | Timing out an ICS20 packet | ~465,000 | ~552,000 |

### Aggregated Packet Benchmarks

Expand All @@ -144,8 +145,8 @@ Since there is no meaningful difference in gas costs between plonk and groth16 i

| **ICS26Router Method** | **Description** | **Avg Gas (25 packets)** | **Avg Gas (50 packets)** |
|:---:|:---:|:---:|:---:|
| `multicall/recvPacket` | Receiving _back_ an `ERC20` token. | ~228,000 | ~220,000 |
| `multicall/ackPacket` | Acknowledging an ICS20 packet. | ~141,000 | ~135,000 |
| `multicall/recvPacket` | Receiving _back_ an `ERC20` token. | ~208,000 | ~201,000 |
| `multicall/ackPacket` | Acknowledging an ICS20 packet. | ~121,000 | ~115,000 |

## License

Expand Down
180 changes: 180 additions & 0 deletions abi/ICS20Lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
[
{
"type": "function",
"name": "DEFAULT_PORT_ID",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "FAILED_ACKNOWLEDGEMENT_JSON",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bytes",
"internalType": "bytes"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "IBC_DENOM_PREFIX",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "ICS20_ENCODING",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "ICS20_VERSION",
"inputs": [],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "SUCCESSFUL_ACKNOWLEDGEMENT_JSON",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bytes",
"internalType": "bytes"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "decodePayload",
"inputs": [
{
"name": "data",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [
{
"name": "",
"type": "tuple",
"internalType": "struct ICS20Lib.FungibleTokenPacketData",
"components": [
{
"name": "denom",
"type": "string",
"internalType": "string"
},
{
"name": "sender",
"type": "string",
"internalType": "string"
},
{
"name": "receiver",
"type": "string",
"internalType": "string"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "memo",
"type": "string",
"internalType": "string"
}
]
}
],
"stateMutability": "pure"
},
{
"type": "function",
"name": "toHexHash",
"inputs": [
{
"name": "str",
"type": "string",
"internalType": "string"
}
],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "pure"
},
{
"type": "function",
"name": "toIBCDenom",
"inputs": [
{
"name": "fullDenomPath",
"type": "string",
"internalType": "string"
}
],
"outputs": [
{
"name": "",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "pure"
},
{
"type": "error",
"name": "StringsInsufficientHexLength",
"inputs": [
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "length",
"type": "uint256",
"internalType": "uint256"
}
]
}
]
Loading
Loading