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

WEB3-107: fix: Specific error when Contract::preflight was missed. #239

Merged
merged 7 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions steel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.

### ⚡️ Features

### 🛠 Fixes

- Return specific error, when no `Contract::preflight` was called.

### 🚨 Breaking Changes

## [0.13.0](https://github.com/risc0/risc0-ethereum/releases/tag/steel-v0.13.0) - 2024-09-10
Expand Down
6 changes: 5 additions & 1 deletion steel/src/host/db/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ impl<T: Transport + Clone, N: Network, P: Provider<T, N>> ProofDb<AlloyDb<T, N,
/// Returns the merkle proofs (sparse [MerkleTrie]) for the state and all storage queries
/// recorded by the [Database].
pub async fn state_proof(&mut self) -> Result<(MerkleTrie, Vec<MerkleTrie>)> {
let proofs = &mut self.proofs;
ensure!(
!self.accounts.is_empty(),
"no accounts accessed: use Contract::preflight"
);

let proofs = &mut self.proofs;
for (address, storage_keys) in &self.accounts {
let account_proof = proofs.get(address);
let storage_keys: Vec<_> = storage_keys
Expand Down
17 changes: 17 additions & 0 deletions steel/tests/steel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,23 @@ async fn call_eoa() {
.expect_err("calling an EOA should fail");
}

#[test(tokio::test)]
async fn no_preflight() {
let env = EthEvmEnv::builder()
.provider(test_provider().await)
.build()
.await
.unwrap()
.with_chain_spec(&ANVIL_CHAIN_SPEC);
match env.into_input().await {
Ok(_) => panic!("calling into_input without a preflight should fail"),
Err(err) => assert_eq!(
err.to_string(),
"no accounts accessed: use Contract::preflight"
),
}
}

alloy::sol!(
// docker run -i ethereum/solc:0.8.26 - --optimize --bin
#[sol(rpc, bytecode="60a0604052348015600e575f80fd5b5060405161012a38038061012a833981016040819052602b91604b565b60808190525f5b6080518110156045576001808255016032565b50506061565b5f60208284031215605a575f80fd5b5051919050565b60805160b46100765f395f6047015260b45ff3fe6080604052348015600e575f80fd5b50600436106026575f3560e01c8063380eb4e014602a575b5f80fd5b60306042565b60405190815260200160405180910390f35b5f805b7f0000000000000000000000000000000000000000000000000000000000000000811015607a57805491909101906001016045565b509056fea26469706673582212203687b75eefdd9cc7ceedb243aa360bd9e1b4cab1930149a371efef74ce18bdf164736f6c634300081a0033")]
Expand Down
Loading