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

[DO NOT MERGE] V37 taiko #13

Open
wants to merge 61 commits into
base: v37
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
92c7a18
Squashed commit of the following:
CeciliaZ030 Feb 1, 2024
3b2817c
optimism -> taiko & keep default-handler
CeciliaZ030 Mar 27, 2024
e8d4b68
fix Defualt & fmt
CeciliaZ030 Mar 28, 2024
1c4ffac
fix
CeciliaZ030 Mar 28, 2024
4d02ed6
cleanup comment
CeciliaZ030 Mar 28, 2024
b2a2042
Update result.rs
CeciliaZ030 Mar 28, 2024
2ce3836
Update handler_register.rs
CeciliaZ030 Mar 28, 2024
a7a5e78
last change
CeciliaZ030 Mar 28, 2024
94e8392
Merge pull request #5 from CeciliaZ030/sync-taiko-2024-03-27
CeciliaZ030 Mar 28, 2024
4d6aae4
fix ecrecover on SP1
Brechtpd Mar 29, 2024
501e02e
Merge pull request #6 from taikoxyz/fix-ecrecover
Brechtpd Mar 29, 2024
8d1d50f
update to alloy 0.7
Brechtpd Mar 31, 2024
758b20b
poc compiled
CeciliaZ030 Apr 3, 2024
993541d
wip
CeciliaZ030 Apr 3, 2024
debc9ad
bn256 done
CeciliaZ030 Apr 3, 2024
581d27b
excecpt for kzg other impl done
CeciliaZ030 Apr 3, 2024
9e7e783
what's the best kzg setup input for zkvm?
CeciliaZ030 Apr 4, 2024
87cefad
fix kzg test
CeciliaZ030 Apr 4, 2024
5e29e5a
update to alloy 0.7
Brechtpd Mar 31, 2024
20f363e
just use hashbrown
CeciliaZ030 Apr 4, 2024
e74d97a
remove kzg
CeciliaZ030 Apr 4, 2024
bab7e15
secp256k1_zk
CeciliaZ030 Apr 4, 2024
16b5af8
flag zk-op in primitives
CeciliaZ030 Apr 4, 2024
8e813d2
Debug
CeciliaZ030 Apr 4, 2024
a975d27
Send + Sync + 'static
CeciliaZ030 Apr 4, 2024
f96f422
remove flag
CeciliaZ030 Apr 5, 2024
35f8dee
Merge branch 'feat/zk-op' of https://github.com/taikoxyz/revm into fe…
CeciliaZ030 Apr 5, 2024
123da28
no zk-op flag
CeciliaZ030 Apr 5, 2024
0450c4d
OnceBox
CeciliaZ030 Apr 5, 2024
c648e10
fix
CeciliaZ030 Apr 5, 2024
3db9d22
Merge branch 'feat/zk-op' of https://github.com/taikoxyz/revm into fe…
CeciliaZ030 Apr 5, 2024
bbe3fc2
cleanup comments
CeciliaZ030 Apr 6, 2024
991ea8a
if let
CeciliaZ030 Apr 20, 2024
39b5b95
ZkOperation + remove redundent sp1 precompile
CeciliaZ030 Apr 20, 2024
f2cc49f
Merge branch 'branch_v35' into fix-ecrecover
Brechtpd May 3, 2024
1c909c9
Merge remote-tracking branch 'origin/v35_taiko' into feat/zk-op
CeciliaZ030 May 8, 2024
098be4c
pass checks
CeciliaZ030 May 8, 2024
2733b06
hashbrown -> std
CeciliaZ030 May 11, 2024
6f76fee
refactor to minimize diff
Brechtpd May 18, 2024
ec20417
fix bn128 add/mul gas costs
Brechtpd May 18, 2024
19a0625
minimize diff even more
Brechtpd May 18, 2024
1ae5123
fix compile error
Brechtpd May 18, 2024
a5c01f3
use our own c-kzg fork
Brechtpd May 19, 2024
d248be2
cycle track
CeciliaZ030 Jun 4, 2024
4a7f410
add flag & fmt
CeciliaZ030 Jun 9, 2024
ed006db
indent
CeciliaZ030 Jun 9, 2024
de06198
fmt
CeciliaZ030 Jun 9, 2024
7d23b1c
Merge pull request #8 from taikoxyz/v35_taiko_v2-cycls
CeciliaZ030 Jun 9, 2024
14c846b
secp256k1 patch dependency
CeciliaZ030 Jun 11, 2024
9a1e6db
sp1-cycle-tracker = ["revm-precompile/sp1-cycle-tracker"]
CeciliaZ030 Jun 11, 2024
df642f1
Merge branch 'v36' into v36-taiko
Brechtpd Jun 24, 2024
8dfc65d
fix warnings
Brechtpd Jun 25, 2024
787302e
cleanup diff
Brechtpd Jun 25, 2024
9a2ea94
Merge branch 'v37' of gh_work:taikoxyz/revm into v36-taiko
johntaiko Jul 2, 2024
595d9f8
chore: Update feature flag for taiko in CI workflow
johntaiko Jul 2, 2024
a75e1fe
fix: clippy complain
johntaiko Jul 2, 2024
7328914
chore: Fix clippy complaints and clean up code formatting
johntaiko Jul 2, 2024
3db094f
fix: reserve the optimism feature for reth
johntaiko Jul 3, 2024
3a0e1be
prepare ontake upgrade
smtmfft Jul 25, 2024
901ea6b
impl base fee sharing logic
smtmfft Jul 28, 2024
06118e2
minor refine
smtmfft Aug 10, 2024
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
Empty file added .cargo-ok
Empty file.
6 changes: 3 additions & 3 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 All @@ -38,7 +38,7 @@ jobs:
strategy:
fail-fast: false
matrix:
features: ["", "optimism"]
features: ["", "taiko"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand Down Expand Up @@ -80,7 +80,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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ date: 20.1.2022

# v3 tag

* revm: v1.0.0
* revm: v1.0.0
* revme: v0.1.0

# v2 tag
Expand Down
21 changes: 17 additions & 4 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,7 +17,6 @@ microbench = "0.5"
plain_hasher = "0.2"
revm = { path = "../../crates/revm", version = "10.0.0", default-features = false, features = [
"ethersdb",
"std",
"serde-json",
"c-kzg",
"blst"
Expand All @@ -26,10 +25,14 @@ 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: 5 additions & 9 deletions crates/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ asm-keccak = ["revm-primitives/asm-keccak"]
portable = ["revm-primitives/portable"]
parse = ["dep:paste", "dep:phf"]

optimism = ["revm-primitives/optimism"]
# Optimism default handler enabled Optimism handler register by default in EvmBuilder.
optimism-default-handler = [
"optimism",
"revm-primitives/optimism-default-handler",
]
negate-optimism-default-handler = [
"revm-primitives/negate-optimism-default-handler",
]
optimism = []
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-taiko-default-handler = ["revm-primitives/negate-taiko-default-handler"]

dev = [
"memory_limit",
Expand Down
3 changes: 1 addition & 2 deletions crates/interpreter/src/function_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ impl FunctionStack {

/// Pops a frame from the stack and sets current_code_idx to the popped frame's idx.
pub fn pop(&mut self) -> Option<FunctionReturnFrame> {
self.return_stack.pop().map(|frame| {
self.return_stack.pop().inspect(|frame| {
self.current_code_idx = frame.idx;
frame
})
}

Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/src/gas/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ pub const fn selfdestruct_cost(spec_id: SpecId, res: SelfDestructResult) -> u64
/// * Account access gas. after berlin it can be cold or warm.
/// * Transfer value gas. If value is transferred and balance of target account is updated.
/// * If account is not existing and needs to be created. After Spurious dragon
/// this is only accounted if value is transferred.
/// this is only accounted if value is transferred.
#[inline]
pub const fn call_cost(
spec_id: SpecId,
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 @@ -105,8 +105,6 @@ impl From<HaltReason> for InstructionResult {
HaltReason::EofAuxDataOverflow => Self::EofAuxDataOverflow,
HaltReason::EofAuxDataTooSmall => Self::EofAuxDataTooSmall,
HaltReason::EOFFunctionStackOverflow => Self::EOFFunctionStackOverflow,
#[cfg(feature = "optimism")]
HaltReason::FailedDeposit => Self::FatalExternalError,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/precompile/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ date: 20.1.2022

# v0.3.0

* switch stacks H256 with U256
* switch stacks H256 with U256
* Error type is changed to `Return` in revm so it is in precompiles.
# v0.2.0

Expand Down
28 changes: 14 additions & 14 deletions crates/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ all = "warn"
revm-primitives = { path = "../primitives", version = "5.0.0", default-features = false }
once_cell = { version = "1.19", default-features = false, features = ["alloc"] }

# ecRecover
# Optional KZG point evaluation precompile
c-kzg = { git = "https://github.com/brechtpd/c-kzg-4844", branch = "for-alpha7", default-features = false, optional = true, features = [
"preload-kzg-settings",
"no-threads",
] }

# ecRecover precompile
k256 = { version = "0.13.3", default-features = false, features = ["ecdsa"] }
secp256k1 = { version = ">=0.28, <=0.29", default-features = false, features = [
secp256k1 = { version = "0.29", default-features = false, features = [
"alloc",
"recovery",
"rand",
Expand All @@ -43,9 +49,6 @@ aurora-engine-modexp = { version = "1.1", default-features = false }
# ecAdd, ecMul, ecPairing
bn = { package = "substrate-bn", version = "0.6", default-features = false }

# KZG point evaluation precompile
c-kzg = { version = "1.0.2", default-features = false, optional = true }

# BLS12-381 precompiles
blst = { version = "0.3.12", optional = true }

Expand Down Expand Up @@ -77,15 +80,11 @@ std = [
hashbrown = ["revm-primitives/hashbrown"]
asm-keccak = ["revm-primitives/asm-keccak"]

optimism = ["revm-primitives/optimism", "secp256r1"]
# Optimism default handler enabled Optimism handler register by default in EvmBuilder.
optimism-default-handler = [
"optimism",
"revm-primitives/optimism-default-handler",
]
negate-optimism-default-handler = [
"revm-primitives/negate-optimism-default-handler",
]
optimism = []
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-taiko-default-handler = ["revm-primitives/negate-taiko-default-handler"]

# Enables the p256verify precompile.
secp256r1 = ["dep:p256"]
Expand All @@ -101,6 +100,7 @@ portable = ["revm-primitives/portable", "c-kzg?/portable"]
# In Linux it passes. If you don't require to build wasm on win/mac, it is safe to use it and it is enabled by default.
secp256k1 = ["dep:secp256k1"]

sp1-cycle-tracker = []
# Enables the BLS12-381 precompiles.
blst = ["dep:blst"]

Expand Down
50 changes: 33 additions & 17 deletions crates/precompile/src/blake2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::zk_op::{self, ZkOperation};
use crate::{Error, Precompile, PrecompileResult, PrecompileWithAddress};
use revm_primitives::{Bytes, PrecompileOutput};

Expand All @@ -11,6 +12,9 @@ pub const FUN: PrecompileWithAddress =
/// input format:
/// [4 bytes for rounds][64 bytes for h][128 bytes for m][8 bytes for t_0][8 bytes for t_1][1 byte for f]
pub fn run(input: &Bytes, gas_limit: u64) -> PrecompileResult {
#[cfg(feature = "sp1-cycle-tracker")]
println!("cycle-tracker-start: blake2");

let input = &input[..];

if input.len() != INPUT_LENGTH {
Expand All @@ -30,26 +34,38 @@ pub fn run(input: &Bytes, gas_limit: u64) -> PrecompileResult {
return Err(Error::OutOfGas.into());
}

let mut h = [0u64; 8];
let mut m = [0u64; 16];
let out = if zk_op::contains_operation(&ZkOperation::Blake2) {
zk_op::ZKVM_OPERATOR
.get()
.unwrap()
.blake2_run(input)
.unwrap()
} else {
let mut h = [0u64; 8];
let mut m = [0u64; 16];

for (i, pos) in (4..68).step_by(8).enumerate() {
h[i] = u64::from_le_bytes(input[pos..pos + 8].try_into().unwrap());
}
for (i, pos) in (68..196).step_by(8).enumerate() {
m[i] = u64::from_le_bytes(input[pos..pos + 8].try_into().unwrap());
}
let t = [
u64::from_le_bytes(input[196..196 + 8].try_into().unwrap()),
u64::from_le_bytes(input[204..204 + 8].try_into().unwrap()),
];

for (i, pos) in (4..68).step_by(8).enumerate() {
h[i] = u64::from_le_bytes(input[pos..pos + 8].try_into().unwrap());
}
for (i, pos) in (68..196).step_by(8).enumerate() {
m[i] = u64::from_le_bytes(input[pos..pos + 8].try_into().unwrap());
}
let t = [
u64::from_le_bytes(input[196..196 + 8].try_into().unwrap()),
u64::from_le_bytes(input[204..204 + 8].try_into().unwrap()),
];
algo::compress(rounds, &mut h, m, t, f);

algo::compress(rounds, &mut h, m, t, f);
let mut out = [0u8; 64];
for (i, h) in (0..64).step_by(8).zip(h.iter()) {
out[i..i + 8].copy_from_slice(&h.to_le_bytes());
}

let mut out = [0u8; 64];
for (i, h) in (0..64).step_by(8).zip(h.iter()) {
out[i..i + 8].copy_from_slice(&h.to_le_bytes());
}
out
};
#[cfg(feature = "sp1-cycle-tracker")]
println!("cycle-tracker-end: blake2");

Ok(PrecompileOutput::new(gas_used, out.into()))
}
Expand Down
1 change: 1 addition & 0 deletions crates/precompile/src/bls12_381/pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const INPUT_LENGTH: usize = 384;
/// following structure:
/// * 128 bytes of G1 point encoding
/// * 256 bytes of G2 point encoding
///
/// Each point is expected to be in the subgroup of order q.
/// Output is 32 bytes where first 31 bytes are equal to 0x00 and the last byte
/// is 0x01 if pairing result is equal to the multiplicative identity in a pairing
Expand Down
4 changes: 2 additions & 2 deletions crates/precompile/src/bls12_381/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ pub(super) fn remove_padding(input: &[u8]) -> Result<&[u8; FP_LENGTH], Precompil
///
/// From [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537):
/// * A scalar for the multiplication operation is encoded as 32 bytes by performing BigEndian
/// encoding of the corresponding (unsigned) integer.
/// encoding of the corresponding (unsigned) integer.
///
/// We do not check that the scalar is a canonical Fr element, because the EIP specifies:
/// * The corresponding integer is not required to be less than or equal than main subgroup order
/// `q`.
/// `q`.
pub(super) fn extract_scalar_input(input: &[u8]) -> Result<blst_scalar, PrecompileError> {
if input.len() != SCALAR_LENGTH {
return Err(PrecompileError::Other(format!(
Expand Down
Loading