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

Local Relay #16

Merged
merged 17 commits into from
Jul 11, 2023
Merged

Local Relay #16

merged 17 commits into from
Jul 11, 2023

Conversation

hashcashier
Copy link
Contributor

This PR introduces a local simplified Relay in addition to the foundry integration middleware.

Usage

  1. Start an anvil instance:
anvil
  1. Run the provided deploy script to deploy the local relay and the starter contract:
RELAY_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 forge script script/Deploy.s.sol:Deploy --rpc-url http://localhost:8545 --broadcast
  1. Run the local relay binary:
cargo run relay --relay-contract-address 0x5fbdb2315678afecb367f032d93f642f64180aa3 --eth-node-url ws://localhost:8545 --private-key ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
  1. Send a transaction to the starter contract:
cast send --private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512 'calculateFibonacci(uint256)' 5
  1. Check the relayed result:
cast call 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512 'fibonacci(uint256)' 5

Copy link
Contributor

@mothran mothran left a comment

Choose a reason for hiding this comment

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

I ran things locally and it all makes sense to me. Seems like a good path to get a full local mock of the relay working! Really nice work.

Here are a couple general items I would call out:

  1. clippy warnings across a few files that might be nice to clear up
  2. It would be great to get the relay e2e in the github actions CI
  3. Could we add a new section to the README describing the steps to use the relay that you put in the PR.
  4. In the README steps you might wanna call out which commands have to be run in new terminals (and how to set the BONSAI_PROVER=... for the relay command
  5. Could we add logging to the relay when its running in non-query mode? maybe use the tracing_subscriber system at set the log level when its invoked in relay mode. That way a user could see the requests being processed.

Thanks so much for hacking this together!

Cargo.toml Outdated Show resolved Hide resolved
script/Deploy.s.sol Outdated Show resolved Hide resolved
relay/contracts/BonsaiRelay.sol Show resolved Hide resolved
relay/src/lib.rs Show resolved Hide resolved
script/Deploy.s.sol Show resolved Hide resolved
relay/Cargo.toml Outdated Show resolved Hide resolved
relay/Cargo.toml Outdated Show resolved Hide resolved
@onokatio
Copy link

I noteced that clear build cache (rm target/) is neccessary to run relay. Or we got error:

thread 'main' panicked at 'Failed to resolve guest entry: Unknown guest binary 0000000000000000000000000000000000000000000000000000000000000000, found: ["ee32dd84d935ed8db5221232ab389d77b1e07bde85db192d31fcc673bfd0726f"]', /Users/tmaruyama/script2/github.com/risc0/bonsai-foundry-template/relay/src/lib.rs:174:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@onokatio
Copy link

It may happend from reading old GUEST_LIST.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intentional that these JSON artifacts are included? It seems like they should not be.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the contracts in the relay directory don't get compiled by foundry, but get compiled using ethers-solc when the solidity_compile feature flag is passed in, so using this build cache is a shortcut to that

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure sure, but why does the cache need to be committed to git? By default I would assume it should not be.

@carterbrett carterbrett added the paris Issues related to engineering deliverables for EthCC '23 label Jul 6, 2023
@hashcashier
Copy link
Contributor Author

I've revised the PR but I've left out the CI and the logging/tracing work for a future PR.

* Fixed bonsai-sdk / zkvm versions to match api

* Updated to newest zkvm in staging
@hashcashier hashcashier enabled auto-merge (squash) July 11, 2023 07:58
@hashcashier hashcashier merged commit c71ba91 into main Jul 11, 2023
3 checks passed
@hashcashier hashcashier deleted the rkhalil/open-relay branch July 11, 2023 08:06
jo-es pushed a commit to jo-es/bonsai-lend that referenced this pull request Sep 29, 2023
* move functionalities to methods crate lib

* copy in relay

* trim down relay

* switch default cargo run target

* rename args

* remove todo for chain id label

* forge script and refactoring

* fixes

* fix

* lint

* tokio subtask for alpha

* some clippy lint

* readme modifications

* remove patch from main workspace

* default private key value

* clippy, cargo, docs

* Fixed bonsai-sdk / zkvm versions to match api (risc0#18)

* Fixed bonsai-sdk / zkvm versions to match api

* Updated to newest zkvm in staging

---------

Co-authored-by: Parker Thompson <parker@risczero.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
paris Issues related to engineering deliverables for EthCC '23
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants