Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

Commit 723f293

Browse files
committed
Merge remote-tracking branch 'scroll/develop' into proof-aggregation-circuit
2 parents a3f4aef + d815e8d commit 723f293

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+8415
-4735
lines changed

Cargo.lock

Lines changed: 26 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ members = [
1515
"aggregator"
1616
]
1717

18+
[patch.crates-io]
19+
ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v0.17.0" }
20+
ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v0.17.0" }
1821
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
1922
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v0.4" }
2023
[patch."https://github.com/privacy-scaling-explorations/poseidon.git"]

bus-mapping/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ rand = "0.8"
4343
[features]
4444
default = ["test"]
4545
test = ["mock", "rand"]
46-
scroll = ["eth-types/scroll"]
46+
scroll = ["eth-types/scroll", "mock?/scroll"]
4747
# Enable shanghai feature of mock only if mock is enabled (by test).
4848
shanghai = ["eth-types/shanghai", "mock?/shanghai"]

bus-mapping/src/circuit_input_builder.rs

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use eth_types::{
3232
};
3333
use ethers_core::{
3434
k256::ecdsa::SigningKey,
35-
types::{Bytes, NameOrAddress, Signature, TransactionRequest},
35+
types::{Bytes, Signature, TransactionRequest},
3636
};
3737
use ethers_providers::JsonRpcClient;
3838
pub use execution::{
@@ -62,6 +62,8 @@ pub struct CircuitsParams {
6262
pub max_txs: usize,
6363
/// Maximum number of bytes from all txs calldata in the Tx Circuit
6464
pub max_calldata: usize,
65+
/// Maximum number of rows that the RLP Circuit can have
66+
pub max_rlp_rows: usize,
6567
/// Max amount of rows that the CopyCircuit can have.
6668
pub max_copy_rows: usize,
6769
/// Maximum number of inner blocks in a batch
@@ -103,6 +105,7 @@ impl Default for CircuitsParams {
103105
max_bytecode: 512,
104106
max_evm_rows: 0,
105107
max_keccak_rows: 0,
108+
max_rlp_rows: 1000,
106109
}
107110
}
108111
}
@@ -584,14 +587,14 @@ pub fn keccak_inputs(block: &Block, code_db: &CodeDB) -> Result<Vec<Vec<u8>>, Er
584587
let mut keccak_inputs = Vec::new();
585588
// Tx Circuit
586589
let txs: Vec<geth_types::Transaction> = block.txs.iter().map(|tx| tx.into()).collect();
587-
keccak_inputs.extend_from_slice(&keccak_inputs_tx_circuit(&txs, block.chain_id().as_u64())?);
590+
keccak_inputs.extend_from_slice(&keccak_inputs_tx_circuit(&txs, block.chain_id())?);
588591
log::debug!(
589592
"keccak total len after txs: {}",
590593
keccak_inputs.iter().map(|i| i.len()).sum::<usize>()
591594
);
592595
// PI circuit
593596
keccak_inputs.push(keccak_inputs_pi_circuit(
594-
block.chain_id().as_u64(),
597+
block.chain_id(),
595598
block.prev_state_root,
596599
block.withdraw_root,
597600
&block.headers,
@@ -740,27 +743,7 @@ pub fn keccak_inputs_tx_circuit(
740743

741744
let hash_datas = txs
742745
.iter()
743-
.map(|tx| {
744-
let sig = Signature {
745-
r: tx.r,
746-
s: tx.s,
747-
v: tx.v,
748-
};
749-
let mut tx: TransactionRequest = tx.into();
750-
if tx.to.is_some() {
751-
let to = tx.to.clone().unwrap();
752-
match to {
753-
NameOrAddress::Name(_) => {}
754-
NameOrAddress::Address(addr) => {
755-
// the rlp of zero addr is 0x80
756-
if addr == Address::zero() {
757-
tx.to = None;
758-
}
759-
}
760-
}
761-
}
762-
tx.rlp_signed(&sig).to_vec()
763-
})
746+
.map(|tx| tx.rlp_bytes.clone())
764747
.collect::<Vec<Vec<u8>>>();
765748
let dummy_hash_data = {
766749
// dummy tx is a legacy tx.
@@ -774,14 +757,23 @@ pub fn keccak_inputs_tx_circuit(
774757
.iter()
775758
.enumerate()
776759
.filter(|(i, tx)| {
777-
if tx.v == 0 && tx.r.is_zero() && tx.s.is_zero() {
778-
warn!("tx {} is not signed, skipping tx circuit keccak input", i);
760+
if !tx.tx_type.is_l1_msg() && tx.v == 0 && tx.r.is_zero() && tx.s.is_zero() {
761+
warn!(
762+
"tx {} is not signed and is not L1Msg, skipping tx circuit keccak input",
763+
i
764+
);
779765
false
780766
} else {
781767
true
782768
}
783769
})
784-
.map(|(_, tx)| tx.sign_data(chain_id))
770+
.map(|(_, tx)| {
771+
if tx.tx_type.is_l1_msg() {
772+
Ok(SignData::default())
773+
} else {
774+
tx.sign_data()
775+
}
776+
})
785777
.try_collect()?;
786778
// Keccak inputs from SignVerify Chip
787779
let sign_verify_inputs = keccak_inputs_sign_verify(&sign_datas);
@@ -795,8 +787,7 @@ pub fn keccak_inputs_tx_circuit(
795787
dummy_tx.rlp().to_vec()
796788
};
797789
inputs.push(dummy_sign_input);
798-
// NOTE: We don't verify the Tx Hash in the circuit yet, so we don't have more
799-
// hash inputs.
790+
800791
Ok(inputs)
801792
}
802793

@@ -836,7 +827,7 @@ type EthBlock = eth_types::Block<eth_types::Transaction>;
836827
/// the necessary information and using the CircuitInputBuilder.
837828
pub struct BuilderClient<P: JsonRpcClient> {
838829
cli: GethClient<P>,
839-
chain_id: Word,
830+
chain_id: u64,
840831
circuits_params: CircuitsParams,
841832
}
842833

@@ -904,7 +895,7 @@ impl<P: JsonRpcClient> BuilderClient<P> {
904895

905896
Ok(Self {
906897
cli: client,
907-
chain_id: chain_id.into(),
898+
chain_id,
908899
circuits_params,
909900
})
910901
}

bus-mapping/src/circuit_input_builder/block.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
operation::{OperationContainer, RWCounter},
88
Error,
99
};
10-
use eth_types::{Address, Hash, ToWord, Word, U256};
10+
use eth_types::{Address, Hash, ToWord, Word};
1111
use std::collections::{BTreeMap, HashMap};
1212

1313
/// Context of a [`Block`] which can mutate in a [`Transaction`].
@@ -70,7 +70,7 @@ impl Default for BlockSteps {
7070
#[derive(Debug, Clone)]
7171
pub struct BlockHead {
7272
/// chain id
73-
pub chain_id: Word,
73+
pub chain_id: u64,
7474
/// history hashes contains most recent 256 block hashes in history, where
7575
/// the lastest one is at history_hashes[history_hashes.len() - 1].
7676
pub history_hashes: Vec<Word>,
@@ -92,7 +92,7 @@ pub struct BlockHead {
9292
impl BlockHead {
9393
/// Create a new block.
9494
pub fn new(
95-
chain_id: Word,
95+
chain_id: u64,
9696
history_hashes: Vec<Word>,
9797
eth_block: &eth_types::Block<eth_types::Transaction>,
9898
) -> Result<Self, Error> {
@@ -160,7 +160,7 @@ pub struct Block {
160160
/// Circuits Setup Paramteres
161161
pub circuits_params: CircuitsParams,
162162
/// chain id
163-
pub chain_id: Word,
163+
pub chain_id: u64,
164164
}
165165

166166
impl Block {
@@ -187,7 +187,7 @@ impl Block {
187187
}
188188
/// Create a new block.
189189
pub fn new<TX>(
190-
chain_id: Word,
190+
chain_id: u64,
191191
history_hashes: Vec<Word>,
192192
eth_block: &eth_types::Block<eth_types::Transaction>,
193193
circuits_params: CircuitsParams,
@@ -219,7 +219,7 @@ impl Block {
219219
}
220220

221221
/// Return the chain id.
222-
pub fn chain_id(&self) -> U256 {
222+
pub fn chain_id(&self) -> u64 {
223223
self.chain_id
224224
}
225225

0 commit comments

Comments
 (0)