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

Sync taiko 2024-03-27 #5

Merged
merged 8 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
rust: ["stable", "beta", "nightly"]
flags: ["--no-default-features", "", "--all-features"]
flags: ["--no-default-features", "", "--features taiko"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
components: rust-docs
- run: cargo doc --workspace --all-features --no-deps --document-private-items
- run: cargo doc --workspace --features taiko --no-deps --document-private-items
env:
RUSTDOCFLAGS: "--cfg docsrs -D warnings"

Expand Down
48 changes: 37 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions bins/revme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ microbench = "0.5"
plain_hasher = "0.2"
revm = { path = "../../crates/revm", version = "7.2.0", default-features = false, features = [
"ethersdb",
"std",
"serde-json",
"c-kzg",
] }
alloy-rlp = { version = "0.3", default-features = false, features = [
"arrayvec",
"derive",
] }
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
serde = { version = "1.0", default-features = false, features = ["derive", "rc"] }
serde_json = { version = "1.0", default-features = false, features = ["alloc"]}
structopt = "0.3"
thiserror = "1.0"
triehash = "0.8"
walkdir = "2.5"
k256 = { version = "0.13.3", features = ["ecdsa"] }

[features]
default = ["std"]
std = ["serde/std", "serde_json/std", "alloy-rlp/std", "revm/std"]
14 changes: 7 additions & 7 deletions crates/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ arbitrary = ["std", "revm-primitives/arbitrary"]
asm-keccak = ["revm-primitives/asm-keccak"]
portable = ["revm-primitives/portable"]

optimism = ["revm-primitives/optimism"]
# Optimism default handler enabled Optimism handler register by default in EvmBuilder.
optimism-default-handler = [
"optimism",
"revm-primitives/optimism-default-handler",
taiko = ["revm-primitives/taiko"]
# taiko default handler enabled taiko handler register by default in EvmBuilder.
taiko-default-handler = [
"taiko",
"revm-primitives/taiko-default-handler",
]
negate-optimism-default-handler = [
"revm-primitives/negate-optimism-default-handler",
negate-taiko-default-handler = [
"revm-primitives/negate-taiko-default-handler",
]

dev = [
Expand Down
2 changes: 0 additions & 2 deletions crates/interpreter/src/instruction_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ impl From<HaltReason> for InstructionResult {
HaltReason::CallNotAllowedInsideStatic => Self::CallNotAllowedInsideStatic,
HaltReason::OutOfFunds => Self::OutOfFunds,
HaltReason::CallTooDeep => Self::CallTooDeep,
#[cfg(feature = "optimism")]
HaltReason::FailedDeposit => Self::FatalExternalError,
}
}
}
Expand Down
21 changes: 3 additions & 18 deletions crates/interpreter/src/instructions/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,24 +934,9 @@ pub const fn spec_opcode_gas(spec_id: SpecId) -> &'static [OpInfo; 256] {
TABLE
}
)*
#[cfg(feature = "optimism")]
SpecId::BEDROCK => {
const TABLE: &[OpInfo;256] = &make_gas_table(SpecId::BEDROCK);
TABLE
}
#[cfg(feature = "optimism")]
SpecId::REGOLITH => {
const TABLE: &[OpInfo;256] = &make_gas_table(SpecId::REGOLITH);
TABLE
}
#[cfg(feature = "optimism")]
SpecId::CANYON => {
const TABLE: &[OpInfo;256] = &make_gas_table(SpecId::CANYON);
TABLE
}
#[cfg(feature = "optimism")]
SpecId::ECOTONE => {
const TABLE: &[OpInfo;256] = &make_gas_table(SpecId::ECOTONE);
#[cfg(feature = "taiko")]
SpecId::KATLA => {
const TABLE: &[OpInfo;256] = &make_gas_table(SpecId::KATLA);
TABLE
}
}
Expand Down
16 changes: 9 additions & 7 deletions crates/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ secp256k1 = { version = "0.28.2", default-features = false, features = [
"rand",
"global-context",
], optional = true }
sp1-precompiles = { git = "https://github.com/succinctlabs/sp1.git" }


[dev-dependencies]
criterion = { version = "0.5" }
Expand All @@ -49,14 +51,14 @@ std = [
]
asm-keccak = ["revm-primitives/asm-keccak"]

optimism = ["revm-primitives/optimism"]
# Optimism default handler enabled Optimism handler register by default in EvmBuilder.
optimism-default-handler = [
"optimism",
"revm-primitives/optimism-default-handler",
taiko = ["revm-primitives/taiko"]
# taiko default handler enabled taiko handler register by default in EvmBuilder.
taiko-default-handler = [
"taiko",
"revm-primitives/taiko-default-handler",
]
negate-optimism-default-handler = [
"revm-primitives/negate-optimism-default-handler",
negate-taiko-default-handler = [
"revm-primitives/negate-taiko-default-handler",
]

# These libraries may not work on all no_std platforms as they depend on C.
Expand Down
6 changes: 2 additions & 4 deletions crates/precompile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,8 @@ impl PrecompileSpecId {
BERLIN | LONDON | ARROW_GLACIER | GRAY_GLACIER | MERGE | SHANGHAI => Self::BERLIN,
CANCUN => Self::CANCUN,
LATEST => Self::LATEST,
#[cfg(feature = "optimism")]
BEDROCK | REGOLITH | CANYON => Self::BERLIN,
#[cfg(feature = "optimism")]
ECOTONE => Self::CANCUN,
#[cfg(feature = "taiko")]
KATLA => Self::BERLIN,
}
}
}
Expand Down
28 changes: 25 additions & 3 deletions crates/precompile/src/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,27 @@ pub const ECRECOVER: PrecompileWithAddress = PrecompileWithAddress(
Precompile::Standard(ec_recover_run),
);

pub use self::secp256k1::ecrecover;
#[cfg(all(target_os = "zkvm", target_vendor = "succinct"))]
#[allow(clippy::module_inception)]
mod secp256k1 {
use crate::B256;
use revm_primitives::keccak256;

pub fn ecrecover(sig: &[u8; 65], msg: &B256) -> Result<B256, anyhow::Error> {
let recovered_key = sp1_precompiles::secp256k1::ecrecover(sig, msg)?;

let mut hash = keccak256(&recovered_key[1..]);

// truncate to 20 bytes
hash[..12].fill(0);
Ok(hash)
}
}

#[cfg(not(feature = "secp256k1"))]
#[cfg(all(
not(all(target_os = "zkvm", target_vendor = "succinct")),
not(feature = "secp256k1")
))]
#[allow(clippy::module_inception)]
mod secp256k1 {
use k256::ecdsa::{Error, RecoveryId, Signature, VerifyingKey};
Expand Down Expand Up @@ -40,7 +58,10 @@ mod secp256k1 {
}
}

#[cfg(feature = "secp256k1")]
#[cfg(all(
not(all(target_os = "zkvm", target_vendor = "succinct")),
feature = "secp256k1"
))]
#[allow(clippy::module_inception)]
mod secp256k1 {
use revm_primitives::{alloy_primitives::B512, keccak256, B256};
Expand All @@ -51,6 +72,7 @@ mod secp256k1 {

// Silence the unused crate dependency warning.
use k256 as _;
use sp1_precompiles as _;

pub fn ecrecover(sig: &B512, recid: u8, msg: &B256) -> Result<B256, secp256k1::Error> {
let recid = RecoveryId::from_i32(recid as i32).expect("recovery ID is valid");
Expand Down
8 changes: 4 additions & 4 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ arbitrary = ["std", "alloy-primitives/arbitrary", "bitflags/arbitrary"]
asm-keccak = ["alloy-primitives/asm-keccak"]
portable = ["c-kzg?/portable"]

optimism = []
# Optimism default handler enabled Optimism handler register by default in EvmBuilder.
optimism-default-handler = ["optimism"]
negate-optimism-default-handler = []
taiko = []
# taiko default handler enabled taiko handler register by default in EvmBuilder.
taiko-default-handler = ["taiko"]
negate-taiko-default-handler = []

dev = [
"memory_limit",
Expand Down
Loading
Loading