Skip to content

Commit 24eef01

Browse files
sync with draft-v30 + make server compile
2 parents a49c2ab + 5fdb6f2 commit 24eef01

File tree

109 files changed

+1401
-564
lines changed

Some content is hidden

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

109 files changed

+1401
-564
lines changed

.github/workflows/ci-core-reusable.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ jobs:
6363
- name: Install yarn
6464
run: |
6565
npm install -g yarn
66-
6766
- name: Check contracts hashes
6867
working-directory: contracts
6968
run: |
@@ -151,7 +150,7 @@ jobs:
151150
# ----------------------------------------------
152151
matrix:
153152
use_gateway_chain: [ "WITH_GATEWAY", "WITHOUT_GATEWAY" ]
154-
tested_chain_type: [ "era", "validium", "custom_token"]
153+
tested_chain_type: [ "era", "validium", "custom_token" ]
155154
# In some cases it's useful to continue one job even if another fails.
156155
fail-fast: false
157156
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ tags
1717
*.orig
1818
.direnv
1919
.cache
20+
cache
2021

2122
# Yarn files
2223
.yarn/

bin/build_and_init_ecosystem

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ initialize_ecosystem() {
1919
echo "[initialize_ecosystem] started"
2020
zkstack ecosystem init \
2121
--deploy-paymaster --deploy-erc20 --deploy-ecosystem \
22-
--l1-rpc-url=http://localhost:8545 \
22+
--l1-rpc-url=http://127.0.0.1:8545 \
2323
--server-db-url=postgres://postgres:notsecurepassword@localhost:5432 \
2424
--server-db-name=zksync_server_localhost_era \
2525
--ignore-prerequisites --verbose \

chains/era/ZkStack.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ name: era
33
chain_id: 271
44
prover_version: NoProofs
55
l1_network: Localhost
6-
link_to_code: .
76
configs: ./chains/era/configs/
87
rocks_db_path: ./chains/era/db/
98
external_node_config_path: ./chains/era/configs/external_node

contracts

core/bin/snapshots_creator/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use zksync_dal::{Connection, CoreDal};
1616
use zksync_object_store::{MockObjectStore, ObjectStore};
1717
use zksync_types::{
1818
block::{L1BatchHeader, L1BatchTreeData, L2BlockHeader},
19-
settlement::SettlementLayer,
19+
commitment::PubdataParams,
2020
snapshots::{
2121
SnapshotFactoryDependencies, SnapshotFactoryDependency, SnapshotStorageLog,
2222
SnapshotStorageLogsChunk, SnapshotStorageLogsStorageKey,
@@ -173,7 +173,7 @@ async fn create_l2_block(
173173
base_fee_per_gas: 0,
174174
gas_per_pubdata_limit: 0,
175175
batch_fee_input: Default::default(),
176-
pubdata_params: Default::default(),
176+
pubdata_params: PubdataParams::genesis(),
177177
base_system_contracts_hashes: Default::default(),
178178
protocol_version: Some(Default::default()),
179179
virtual_blocks: 0,

core/bin/zksync_server/src/node_builder.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ use zksync_state_keeper::node::{
7474
};
7575
use zksync_tee_proof_data_handler::node::TeeProofDataHandlerLayer;
7676
use zksync_types::{
77-
commitment::{L1BatchCommitmentMode, PubdataType},
77+
commitment::{L1BatchCommitmentMode, L2DACommitmentScheme, PubdataType},
7878
pubdata_da::PubdataSendingMode,
7979
Address, L2ChainId,
8080
};
@@ -129,6 +129,37 @@ impl MainNodeBuilder {
129129
}
130130
}
131131

132+
pub fn l2_da_commitment_scheme(&self) -> L2DACommitmentScheme {
133+
let use_dummy_inclusion_data = self
134+
.configs
135+
.da_dispatcher_config
136+
.as_ref()
137+
.map(|a| a.use_dummy_inclusion_data)
138+
.unwrap_or_default();
139+
140+
// For DA clients we have two options verify the pubdata inclusion on SL or not.
141+
// If we do not verify it, we can use EmptyNoDA commitment scheme in this case
142+
// use_dummy_inclusion_data is true.
143+
// If the DA client is not specified, we assume that we publish all data to SL
144+
// and we have to verify it
145+
146+
if use_dummy_inclusion_data {
147+
return L2DACommitmentScheme::EmptyNoDA;
148+
}
149+
150+
match &self.configs.da_client_config {
151+
Some(DAClientConfig::NoDA) => L2DACommitmentScheme::EmptyNoDA,
152+
Some(DAClientConfig::ObjectStore(_)) => L2DACommitmentScheme::EmptyNoDA,
153+
Some(DAClientConfig::Avail(_)) => L2DACommitmentScheme::PubdataKeccak256,
154+
Some(DAClientConfig::Celestia(_)) => L2DACommitmentScheme::PubdataKeccak256,
155+
Some(DAClientConfig::Eigen(_)) => L2DACommitmentScheme::PubdataKeccak256,
156+
None => {
157+
tracing::info!("DAClientConfig is not specified, setting L2DACommitmentScheme to BlobsAndPubdataKeccak256");
158+
L2DACommitmentScheme::BlobsAndPubdataKeccak256
159+
}
160+
}
161+
}
162+
132163
fn add_sigint_handler_layer(mut self) -> anyhow::Result<Self> {
133164
self.node.add_layer(SigintHandlerLayer);
134165
Ok(self)
@@ -326,6 +357,7 @@ impl MainNodeBuilder {
326357
.genesis_config
327358
.l1_batch_commit_data_generator_mode,
328359
dummy_verifier: self.genesis_config.dummy_verifier,
360+
config_l2_da_commitment_scheme: self.l2_da_commitment_scheme(),
329361
}));
330362
Ok(self)
331363
}

core/lib/basic_types/src/commitment.rs

Lines changed: 120 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,125 @@ impl FromStr for PubdataType {
9898
}
9999
}
100100

101-
#[derive(Default, Copy, Debug, Clone, PartialEq, Serialize, Deserialize)]
101+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Display)]
102+
#[repr(u8)]
103+
pub enum L2DACommitmentScheme {
104+
None = 0,
105+
EmptyNoDA = 1,
106+
PubdataKeccak256 = 2,
107+
BlobsAndPubdataKeccak256 = 3,
108+
}
109+
110+
impl TryFrom<u8> for L2DACommitmentScheme {
111+
type Error = &'static str;
112+
fn try_from(value: u8) -> Result<Self, Self::Error> {
113+
match value {
114+
0 => Ok(L2DACommitmentScheme::None),
115+
1 => Ok(L2DACommitmentScheme::EmptyNoDA),
116+
2 => Ok(L2DACommitmentScheme::PubdataKeccak256),
117+
3 => Ok(L2DACommitmentScheme::BlobsAndPubdataKeccak256),
118+
_ => Err("Invalid L2DACommitmentScheme value"),
119+
}
120+
}
121+
}
122+
123+
impl FromStr for L2DACommitmentScheme {
124+
type Err = &'static str;
125+
126+
fn from_str(s: &str) -> Result<Self, Self::Err> {
127+
match s {
128+
"None" => Ok(Self::None),
129+
"EmptyNoDA" => Ok(Self::EmptyNoDA),
130+
"PubdataKeccak256" => Ok(Self::PubdataKeccak256),
131+
"BlobsAndPubdataKeccak256" => Ok(Self::BlobsAndPubdataKeccak256),
132+
_ => Err("Incorrect L2 DA commitment scheme; expected one of `None`, `EmptyNoDA`, `PubdataKeccak256`, `BlobsAndPubdataKeccak256`"),
133+
}
134+
}
135+
}
136+
137+
#[derive(Copy, Debug, Clone, PartialEq, Serialize, Deserialize)]
138+
pub enum L2PubdataValidator {
139+
Address(Address),
140+
CommitmentScheme(L2DACommitmentScheme),
141+
}
142+
143+
impl TryFrom<(Option<Address>, Option<L2DACommitmentScheme>)> for L2PubdataValidator {
144+
type Error = anyhow::Error;
145+
146+
fn try_from(
147+
value: (Option<Address>, Option<L2DACommitmentScheme>),
148+
) -> Result<Self, Self::Error> {
149+
match value {
150+
(None, Some(scheme)) => Ok(L2PubdataValidator::CommitmentScheme(scheme)),
151+
(Some(address), None) => Ok(L2PubdataValidator::Address(address)),
152+
(Some(_), Some(_)) => anyhow::bail!(
153+
"Address and L2DACommitmentScheme are specified, should be chosen only one"
154+
),
155+
(None, None) => anyhow::bail!(
156+
"Address and L2DACommitmentScheme are not specified, should be chosen at least one"
157+
),
158+
}
159+
}
160+
}
161+
162+
impl L2PubdataValidator {
163+
pub fn l2_da_validator(&self) -> Option<Address> {
164+
match self {
165+
L2PubdataValidator::Address(addr) => Some(*addr),
166+
L2PubdataValidator::CommitmentScheme(_) => None,
167+
}
168+
}
169+
170+
pub fn l2_da_commitment_scheme(&self) -> Option<L2DACommitmentScheme> {
171+
match self {
172+
L2PubdataValidator::Address(_) => None,
173+
L2PubdataValidator::CommitmentScheme(scheme) => Some(*scheme),
174+
}
175+
}
176+
}
177+
178+
#[derive(Copy, Debug, Clone, PartialEq, Serialize, Deserialize)]
102179
pub struct PubdataParams {
103-
pub l2_da_validator_address: Address,
104-
pub pubdata_type: PubdataType,
180+
pubdata_validator: L2PubdataValidator,
181+
pubdata_type: PubdataType,
182+
}
183+
184+
impl PubdataParams {
185+
pub fn new(
186+
pubdata_validator: L2PubdataValidator,
187+
pubdata_type: PubdataType,
188+
) -> anyhow::Result<Self> {
189+
if L2PubdataValidator::CommitmentScheme(L2DACommitmentScheme::None) == pubdata_validator {
190+
anyhow::bail!("L2DACommitmentScheme::None is not allowed as a legit pubdata parameter");
191+
};
192+
193+
Ok(PubdataParams {
194+
pubdata_validator,
195+
pubdata_type,
196+
})
197+
}
198+
199+
pub fn pubdata_validator(&self) -> L2PubdataValidator {
200+
self.pubdata_validator
201+
}
202+
203+
pub fn pubdata_type(&self) -> PubdataType {
204+
self.pubdata_type
205+
}
206+
207+
pub fn genesis() -> Self {
208+
PubdataParams {
209+
pubdata_validator: L2PubdataValidator::CommitmentScheme(
210+
L2DACommitmentScheme::BlobsAndPubdataKeccak256,
211+
),
212+
pubdata_type: PubdataType::Rollup,
213+
}
214+
}
215+
216+
pub fn pre_gateway() -> Self {
217+
PubdataParams {
218+
pubdata_validator: L2PubdataValidator::Address(Address::zero()),
219+
pubdata_type: Default::default(),
220+
}
221+
}
105222
}

core/lib/basic_types/src/protocol_version.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ impl ProtocolVersionId {
132132
ProtocolVersionId::Version28 => VmVersion::VmEcPrecompiles,
133133
ProtocolVersionId::Version29 => VmVersion::VmInterop,
134134
ProtocolVersionId::Version30 => VmVersion::VmMediumInterop,
135-
136135
// Speculative VM version for the next protocol version to be used in the upgrade integration test etc.
137136
ProtocolVersionId::Version31 => VmVersion::VmMediumInterop,
138137
}

core/lib/basic_types/src/web3/contract.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ pub trait Detokenize: Sized {
2020

2121
impl<T: Tokenizable> Detokenize for T {
2222
fn from_tokens(mut tokens: Vec<ethabi::Token>) -> Result<Self, Error> {
23-
if tokens.len() != 1 {
24-
return Err(Error::InvalidOutputType(format!(
25-
"expected array with 1 token, got {tokens:?}"
26-
)));
23+
if tokens.len() == 1 {
24+
Self::from_token(tokens.pop().unwrap())
25+
} else {
26+
Self::from_token(ethabi::Token::Tuple(tokens))
2727
}
28-
Self::from_token(tokens.pop().unwrap())
2928
}
3029
}
3130

0 commit comments

Comments
 (0)