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

feat: add rkyv support #1378

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ade6eb5
add rkyv support
lightsing Jul 22, 2024
3a1b418
add exports
lightsing Jul 22, 2024
1db5f2e
enable validation
lightsing Jul 23, 2024
10a15f7
fix check bytes
lightsing Jul 23, 2024
c061977
fix related
lightsing Jul 25, 2024
cde6a66
serde default
lispc Jul 26, 2024
7a13af6
serde default
lispc Jul 26, 2024
b26363c
re-export ethers-core types
roynalnaruto Aug 12, 2024
00f2bfc
Merge branch 'refs/heads/develop' into feat/rkyv
lightsing Aug 14, 2024
babe58b
patch for rkyv
lightsing Aug 14, 2024
0b6dcef
fix BlockTraceV2
lightsing Aug 15, 2024
31a6668
Merge branch 'develop' into fix/trace-v2-withdraw-root
lightsing Aug 15, 2024
415e963
Merge branch 'refs/heads/fix/trace-v2-withdraw-root' into feat/rkyv
lightsing Aug 15, 2024
262cc62
fix ChunkInfo::from_block_traces
lightsing Aug 15, 2024
4eef333
Merge branch 'refs/heads/fix/aggregator-chunk' into feat/rkyv
lightsing Aug 15, 2024
75b6a84
Merge remote-tracking branch 'refs/remotes/origin/develop' into feat/…
lightsing Aug 27, 2024
e63fe2b
use poseidon-bn254
lightsing Aug 28, 2024
c9773d1
keep using halo2curves
lightsing Aug 28, 2024
defb544
Merge branch 'refs/heads/feat/poseidon-bn254' into feat/rkyv
lightsing Aug 28, 2024
0d91d0b
typo
lightsing Aug 28, 2024
6c5d935
Merge branch 'refs/heads/feat/poseidon-bn254' into feat/rkyv
lightsing Aug 28, 2024
7038d1a
fix
lightsing Aug 28, 2024
f93a720
upgrade
lightsing Aug 28, 2024
2892f38
fix
lightsing Aug 28, 2024
35c04c1
Merge branch 'refs/heads/feat/poseidon-bn254' into feat/rkyv
lightsing Aug 28, 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
342 changes: 274 additions & 68 deletions Cargo.lock

Large diffs are not rendered by default.

50 changes: 38 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ base64 = "0.13.0"
bincode = "1"
ctor = "0.1"
env_logger = "0.10"
ethers = { version = "=2.0.7", features = ["ethers-solc"] }
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7", features = ["scroll"] }
ethers-providers = "=2.0.7"
ethers-signers = "=2.0.7"
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv", features = ["rkyv", "scroll"] }
ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" }
ethers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" }
ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" }
ff = "0.13"
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
halo2curves = { version = "0.1.0", features = [ "derive_serde" ] }
poseidon-base = { package = "poseidon-base", git = "https://github.com/scroll-tech/poseidon-circuit.git", branch = "main" }
poseidon-bn254 = { git = "https://github.com/scroll-tech/poseidon-bn254", branch = "master" }
hash-circuit = { package = "poseidon-circuit", git = "https://github.com/scroll-tech/poseidon-circuit.git", branch = "main" }
halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop", default-features=false, features=["halo2-pse","display"] }
halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop", default-features=false, features=["halo2-pse","display"] }
Expand All @@ -53,6 +53,7 @@ rand_chacha = "0.3"
rand_xorshift = "0.3"
rayon = "1.5"
regex = "1.5"
rkyv = { version = "0.7.44", features = ["validation"] }
serde = {version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_stacker = "0.1"
Expand All @@ -64,18 +65,43 @@ strum_macros = "0.25"
subtle = "2.4"
tokio = { version = "1.13", features = ["macros", "rt-multi-thread"] }
url = "2.2"
revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v40", default-features = false, features = ["std"] } # v40
revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v40", default-features = false, features = ["std"] } # v40
revm-precompile = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v41", default-features = false, features = ["std"] } # v40
revm-primitives = { git = "https://github.com/scroll-tech/revm", branch = "scroll-evm-executor/v41", default-features = false, features = ["std"] } # v40
c-kzg = "1.0.2"
primitive-types = { git = "https://github.com/scroll-tech/parity-common.git", branch = "feat/rkyv", features = ["rkyv"] }
ethereum-types = { git = "https://github.com/scroll-tech/parity-common.git", branch = "feat/rkyv", features = ["rkyv"] }

# for local development
#ethers-core = { path = "../ethers-rs/ethers-core", features = ["rkyv", "scroll"] }
#ethers-providers = { path = "../ethers-rs/ethers-providers" }
#ethers = { path = "../ethers-rs/ethers" }
#ethers-signers = { path = "../ethers-rs/ethers-signers" }
#primitive-types = { path = "../parity-common/primitive-types", features = ["rkyv"] }
#ethereum-types = { path = "../parity-common/ethereum-types", features = ["rkyv"] }
#snark-verifier = { path = "../snark-verifier/snark-verifier" }
#snark-verifier-sdk = { path = "../snark-verifier/snark-verifier-sdk", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] }


[patch.crates-io]
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
ethers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" }
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" }
ethers-providers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" }
ethers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" }
ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" }
ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "feat/rkyv" }
gobuild = { git = "https://github.com/scroll-tech/gobuild.git" }
halo2curves = { git = "https://github.com/scroll-tech/halo2curves", branch = "v0.1.0" }
primitive-types = { git = "https://github.com/scroll-tech/parity-common.git", branch = "feat/rkyv" }
ethereum-types = { git = "https://github.com/scroll-tech/parity-common.git", branch = "feat/rkyv" }

# for local development
#ethers-core = { path = "../ethers-rs/ethers-core" }
#ethers-providers = { path = "../ethers-rs/ethers-providers" }
#ethers = { path = "../ethers-rs/ethers" }
#ethers-etherscan = { path = "../ethers-rs/ethers-etherscan" }
#ethers-signers = { path = "../ethers-rs/ethers-signers" }
#primitive-types = { path = "../parity-common/primitive-types" }
#ethereum-types = { path = "../parity-common/ethereum-types" }


[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" }
Expand Down
9 changes: 4 additions & 5 deletions bus-mapping/src/circuit_input_builder/l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ impl CircuitInputBuilder {
fn collect_account_proofs(
storage_trace: &StorageTrace,
) -> impl Iterator<Item = (&Address, impl IntoIterator<Item = &[u8]>)> + Clone {
storage_trace.proofs.iter().flat_map(|kv_map| {
kv_map
.iter()
.map(|(k, bts)| (k, bts.iter().map(Bytes::as_ref)))
})
storage_trace
.proofs
.iter()
.map(|(k, bts)| (k, bts.iter().map(Bytes::as_ref)))
}

fn collect_storage_proofs(
Expand Down
11 changes: 8 additions & 3 deletions eth-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ license.workspace = true
ethers-core.workspace = true
ethers-signers.workspace = true
hex.workspace = true
halo2curves.workspace = true
halo2curves = { workspace = true, optional = true }
log.workspace = true
regex.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_with = "1.12"
serde_with = "3.9"
uint = "0.9.1"
itertools.workspace = true
subtle.workspace = true
Expand All @@ -22,17 +22,22 @@ num.workspace = true
num-bigint.workspace = true
strum_macros.workspace = true
strum.workspace = true
poseidon-base.workspace = true
poseidon-bn254.workspace = true
base64.workspace = true
revm-precompile.workspace = true
revm-primitives.workspace = true
rkyv.workspace = true
primitive-types.workspace = true
ethereum-types.workspace = true

[dev-dependencies]
bincode.workspace = true

[features]
default = ["warn-unimplemented"]
warn-unimplemented = []
secp256k1 = ["halo2curves"]
poseidon-bn254 = ["poseidon-bn254/bn254"]
scroll = ["revm-precompile/scroll", "revm-primitives/scroll"]

# trace heap allocation related feature switches
Expand Down
21 changes: 14 additions & 7 deletions eth-types/src/geth_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
#[cfg(feature = "scroll")]
use crate::l2_types::BlockTrace;
use crate::{
sign_types::{biguint_to_32bytes_le, ct_option_ok_or, recover_pk2, SignData, SECP256K1_Q},
AccessList, Address, Block, Bytes, Error, GethExecTrace, Hash, ToBigEndian, ToLittleEndian,
Word, U64,
AccessList, Address, Block, Bytes, Error, GethExecTrace, Hash, ToBigEndian, Word, U64,
};
use ethers_core::types::{
transaction::eip2718::TypedTransaction, Eip1559TransactionRequest, Eip2930TransactionRequest,
NameOrAddress, TransactionRequest, H256,
};
use halo2curves::{group::ff::PrimeField, secp256k1::Fq};
use num::Integer;
use num_bigint::BigUint;
use serde::{Serialize, Serializer};
use serde_with::serde_as;
use sha3::{Digest, Keccak256};
use std::collections::HashMap;
use strum_macros::EnumIter;

#[cfg(feature = "secp256k1")]
use crate::sign_types::{
biguint_to_32bytes_le, ct_option_ok_or, recover_pk2, SignData, SECP256K1_Q,
};
#[cfg(feature = "secp256k1")]
use halo2curves::{group::ff::PrimeField, secp256k1::Fq};

/// Tx type
#[derive(Default, Debug, Copy, Clone, EnumIter, Serialize, PartialEq, Eq)]
pub enum TxType {
Expand Down Expand Up @@ -358,7 +359,13 @@ impl From<&Transaction> for TransactionRequest {

impl Transaction {
/// Return the SignData associated with this Transaction.
#[cfg(feature = "secp256k1")]
pub fn sign_data(&self) -> Result<SignData, Error> {
use crate::ToLittleEndian;
use num::Integer;
use num_bigint::BigUint;
use sha3::{Digest, Keccak256};

let sig_r_le = self.r.to_le_bytes();
let sig_s_le = self.s.to_le_bytes();
let sig_r = ct_option_ok_or(Fq::from_repr(sig_r_le), Error::Signature)?;
Expand Down
Loading
Loading