Skip to content

Commit

Permalink
refactor(bridge-withdrawer): move generated contract bindings to crate (
Browse files Browse the repository at this point in the history
#1237)

## Summary
Moves the generated Rust bindings for Astria's bridge smart contracts to
a free standing crate.

## Background
Breaking out the bindings outside the `astria-bridge-withdrawer` binary
crate is needed to share code with a CLI tool to manually initiate
withdrawals.

This patch also uses the opportunity and makes the process of
re-generating bindings (and committing them to the repo) more similar to
how protobuf-bindings are generated: `tools/solidity-compiler` updates
the git submodule in `astria-bridge-contracts` and then regenerates all
bindings. The bindings are placed in
`astria-bridge-contracts/src/generated` and commited to the repository.

## Changes
- Create `crates/astria-bridge-contracts` crate and move the submodule
of the same name there
- Create `tools/solidity-compiler` tool and use it to generate rust
bindings for the bridge contracts
- Update `astria-bridge-withdrawer` to use `astria-bridge-contracts` as
a dependency
- Add a job `solidity-contracts-compiled` to ensure that the contracts
are up-to-date.

## Testing
Apart from some types being renamed, nothing has changed.
  • Loading branch information
SuperFluffy authored Jul 8, 2024
1 parent c90005d commit c9e4898
Show file tree
Hide file tree
Showing 24 changed files with 1,744 additions and 459 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,31 @@ jobs:
exit 1
fi
solidity-contracts-compiled:
runs-on: ubuntu-22.04
needs: run_checker
if: needs.run_checker.outputs.run_tests == 'true'
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/[email protected]
- uses: Swatinem/[email protected]
with:
cache-provider: "buildjet"
- name: Install just
uses: taiki-e/install-action@just
- name: Check if protobuf specs compile to commited Rust sources
run: |
just compile-solidity-contracts
modified=$(git status --porcelain)
if [[ -n "$modified" ]]; then
echo "ERROR: solidity contracts are out of sync with the commited Rust sources"
echo "Recompile locally with \`just compile-solidity-contracts\` and commit to the repository."
echo "Files that reported differences:"
echo "$modified"
exit 1
fi
compiles:
runs-on: buildjet-4vcpu-ubuntu-2204
needs: run_checker
Expand Down Expand Up @@ -232,7 +257,7 @@ jobs:
test:
if: ${{ always() && !cancelled() }}
needs: [compiles, protos-compiled, rust, doctest, clippy, lockfile, custom-lints]
needs: [compiles, protos-compiled, solidity-contracts-compiled, rust, doctest, clippy, lockfile, custom-lints]
uses: ./.github/workflows/reusable-success.yml
with:
success: ${{ !contains(needs.*.result, 'failure') }}
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "crates/astria-bridge-withdrawer/astria-bridge-contracts"]
path = crates/astria-bridge-withdrawer/astria-bridge-contracts
url = https://github.com/astriaorg/astria-bridge-contracts.git
[submodule "crates/astria-bridge-contracts/astria-bridge-contracts"]
path = crates/astria-bridge-contracts/astria-bridge-contracts
url = https://github.com/astriaorg/astria-bridge-contracts
Loading

0 comments on commit c9e4898

Please sign in to comment.