/evm-protocol-adapter

A protocol adapter contract written in Solidity enabling Anoma Resource Machine transaction settlement on EVM-compatible chains.

Primary LanguageSolidityMIT LicenseMIT

CI

EVM Protocol Adapter

For more information on the EVM protocol adapter, find the related

The EVM Protocol Adapter: Bringing Intent-Centric Apps to Ethereum - Anoma Research Day

Warning

This repo features a prototype and is work in progress. Do NOT use in production.

Project Structure

.
├── bindings
├── contracts
├── LICENSE
└── README.md

The contracts folder contains the contracts written in Solidity contracts as well as Foundry forge tests and deploy scripts.

The bindings folder contains bindings in Rust to convert Rust and RISC Zero types into EVM types using the alloy-rs library.

Prerequisites

  1. Get an up-to-date version of Rust with

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Clone this repo

Solidity Contracts

Installation

Change the directory to the contracts folder with cd contracts and run

forge install

Usage

Build

Build the contracts with following flags: //TODO! confirm this is needed

forge build --ast

Tests

Run

forge test

Linting & Static Analysis

As a pre-requisite, install solhint with

bun install solhint

or

bun install solhint

and slither

via

python3 -m pip install slither-analyzer

Run the linter and analysis with

bunx --bun solhint --config .solhint.json 'src/**/*.sol' && \
bunx --bun solhint --config .solhint.other.json 'script/**/*.sol' 'test/**/*.sol' && \
slither .

or

npx solhint --config .solhint.json 'src/**/*.sol' && \
npx solhint --config .solhint.other.json 'script/**/*.sol' 'test/**/*.sol' && \
slither .

Deployment

To simulate deployment on sepolia, run

forge script script/DeployProtocolAdapter.s.sol:DeployProtocolAdapter --rpc-url sepolia

Append the

  • --broadcast flag to deploy on sepolia
  • --verify --slow flags for subsequent contract verification on Etherscan (--slow adds 15 seconds of waiting time between verification attempts)
  • --account <ACCOUNT_NAME> flag to use a previously imported keystore (see cast wallet --help for more info)
Block Explorer Verification

For post-deployment verification on Etherscan run

forge verify-contract \
   <ADDRESS> \
   src/ProtocolAdapter.sol:ProtocolAdapter \
   --chain sepolia \
   --constructor-args-path script/constructor-args.txt

after replacing <ADDRESS> with the respective contract address.

Benchmarks

Parameters:

  • Commitment accumulator treeDepth = 32

Protocol adapter benchmark for a Merkle tree depth of 32.

Rust Bindings

Installation

Change the directory to the bindings folder with cd bindings and run

  1. Install rzup by running the following command:

    curl -L https://risczero.com/install | bash
  2. Run rzup to install RISC Zero:

    rzup install
  3. Go to the bindings directory with cd bindings and run

    cargo build

Usage

Print a test transaction with

cargo test -- conversion::tests::print_tx --exact --show-output --ignored