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: Verify blob L1 #287

Draft
wants to merge 39 commits into
base: da-eigen-implementation
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ee302ec
Send uncoded commitment
gianbelinche Sep 26, 2024
bc8c30e
Add call to verify
gianbelinche Sep 26, 2024
a8b6258
Add verify blob to eigenda client
gianbelinche Sep 27, 2024
d40d033
Revert "Send uncoded commitment"
gianbelinche Sep 27, 2024
a0b21d8
Update submodule
gianbelinche Sep 27, 2024
66ee57c
Update submodule
gianbelinche Sep 30, 2024
df7be16
Fix submodule
gianbelinche Sep 30, 2024
ebee098
Deploy eigenda verifier
gianbelinche Sep 30, 2024
4dc9e16
Add call to verify
gianbelinche Sep 30, 2024
93fa373
Fix tokenize params
gianbelinche Sep 30, 2024
df8b572
Update contracts
gianbelinche Sep 30, 2024
d7f92c3
Remove panic
gianbelinche Oct 4, 2024
e46b31f
Update contracts
gianbelinche Oct 7, 2024
894ff20
update contracts submodule
juan518munoz Oct 8, 2024
b428234
remove eigen proxy from general setup, add it to doc steps
juan518munoz Oct 8, 2024
5bea05d
Remove formats (#293)
gianbelinche Oct 8, 2024
30fdc59
remove arguments from ecosystem init
juan518munoz Oct 8, 2024
27cebcc
Update queries (#294)
gianbelinche Oct 8, 2024
a9c0b3b
Update contracts
gianbelinche Oct 8, 2024
a6f496b
Format
gianbelinche Oct 8, 2024
9eb946b
Update contracts
gianbelinche Oct 8, 2024
deafa46
feat(vm): EVM emulator support – base (#2979)
slowli Oct 8, 2024
c84e271
Add dashboard step
gianbelinche Oct 8, 2024
8806c09
Merge branch 'main' into m0-merge-main
gianbelinche Oct 8, 2024
6a573c5
Update queries
gianbelinche Oct 8, 2024
bf93f78
Format code
gianbelinche Oct 8, 2024
2e49a43
query changes
juan518munoz Oct 8, 2024
ebf7eca
Merge pull request #295 from lambdaclass/m0-merge-main
juan518munoz Oct 8, 2024
9c612a7
Remove formatting and configs
gianbelinche Oct 8, 2024
d6c4c26
Update contracts
gianbelinche Oct 8, 2024
22da332
add max blob size to doc
juan518munoz Oct 8, 2024
24256c8
Update eigenda-integration.md
juan518munoz Oct 8, 2024
5ca02ea
Merge branch 'da-eigen-implementation-m0' into verify-blob-l1
gianbelinche Oct 10, 2024
65d3a4e
Format code
gianbelinche Oct 10, 2024
70aab5c
Update contracts
gianbelinche Oct 10, 2024
2b7fb1a
Complete merge
gianbelinche Oct 10, 2024
b35a7d8
Send blob info to L1
gianbelinche Oct 10, 2024
672c843
Add blob info
gianbelinche Oct 10, 2024
f8eac20
Update contracts
gianbelinche Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2,928 changes: 1,947 additions & 981 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ tower-http = "0.5.2"
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-opentelemetry = "0.25.0"
time = "0.3.36" # Has to be same as used by `tracing-subscriber`
time = "0.3.36" # Has to be same as used by `tracing-subscriber`
url = "2"
web3 = "0.19.0"
fraction = "0.15.3"
Expand Down
3 changes: 3 additions & 0 deletions backup-ecosystem.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# This script backs up the Postgres databases and chain configuration files for a given ecosystem.
# With it you can make a testnet deployment and save the L2 state for later recovery.

# Check if the ecosystem name was provided as an argument
if [ -z "$1" ]; then
echo "Usage: ./backup-ecosystem ECOSYSTEM_NAME"
Expand Down
1 change: 1 addition & 0 deletions core/bin/genesis_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async fn generate_new_config(
genesis_commitment: None,
bootloader_hash: Some(base_system_contracts.bootloader),
default_aa_hash: Some(base_system_contracts.default_aa),
evm_emulator_hash: base_system_contracts.evm_emulator,
..genesis_config
};

Expand Down
3 changes: 3 additions & 0 deletions core/bin/system-constants-generator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ pub static GAS_TEST_SYSTEM_CONTRACTS: Lazy<BaseSystemContracts> = Lazy::new(|| {

let bytecode = read_sys_contract_bytecode("", "DefaultAccount", ContractLanguage::Sol);
let hash = hash_bytecode(&bytecode);

BaseSystemContracts {
default_aa: SystemContractCode {
code: bytes_to_be_words(bytecode),
hash,
},
bootloader,
evm_emulator: None,
}
});

Expand Down Expand Up @@ -221,6 +223,7 @@ pub(super) fn execute_internal_transfer_test() -> u32 {
let base_system_smart_contracts = BaseSystemContracts {
bootloader,
default_aa,
evm_emulator: None,
};

let system_env = SystemEnv {
Expand Down
5 changes: 4 additions & 1 deletion core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,10 @@ impl MainNodeBuilder {
.add_layer(ObjectStorageClientWiringLayer::new(config));
}
(DAClientConfig::EigenDA(config), _) => {
self.node.add_layer(EigenDAWiringLayer::new(config));
self.node.add_layer(EigenDAWiringLayer::new(
config,
self.contracts_config.eigenda_verifier_addr.unwrap(),
));
}
}

Expand Down
3 changes: 3 additions & 0 deletions core/lib/config/src/configs/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ pub struct StateKeeperConfig {
pub bootloader_hash: Option<H256>,
#[deprecated(note = "Use GenesisConfig::default_aa_hash instead")]
pub default_aa_hash: Option<H256>,
#[deprecated(note = "Use GenesisConfig::evm_emulator_hash instead")]
pub evm_emulator_hash: Option<H256>,
#[deprecated(note = "Use GenesisConfig::l1_batch_commit_data_generator_mode instead")]
#[serde(default)]
pub l1_batch_commit_data_generator_mode: L1BatchCommitmentMode,
Expand Down Expand Up @@ -178,6 +180,7 @@ impl StateKeeperConfig {
protective_reads_persistence_enabled: true,
bootloader_hash: None,
default_aa_hash: None,
evm_emulator_hash: None,
l1_batch_commit_data_generator_mode: L1BatchCommitmentMode::Rollup,
}
}
Expand Down
2 changes: 2 additions & 0 deletions core/lib/config/src/configs/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct ContractsConfig {
// Used by the RPC API and by the node builder in wiring the BaseTokenRatioProvider layer.
pub base_token_addr: Option<Address>,
pub chain_admin_addr: Option<Address>,
pub eigenda_verifier_addr: Option<Address>,
}

impl ContractsConfig {
Expand All @@ -61,6 +62,7 @@ impl ContractsConfig {
base_token_addr: Some(Address::repeat_byte(0x14)),
ecosystem_contracts: Some(EcosystemContracts::for_tests()),
chain_admin_addr: Some(Address::repeat_byte(0x18)),
eigenda_verifier_addr: Some(Address::repeat_byte(0x19)),
}
}
}
2 changes: 2 additions & 0 deletions core/lib/config/src/configs/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct GenesisConfig {
pub genesis_commitment: Option<H256>,
pub bootloader_hash: Option<H256>,
pub default_aa_hash: Option<H256>,
pub evm_emulator_hash: Option<H256>,
pub l1_chain_id: L1ChainId,
pub sl_chain_id: Option<SLChainId>,
pub l2_chain_id: L2ChainId,
Expand Down Expand Up @@ -49,6 +50,7 @@ impl GenesisConfig {
genesis_commitment: Some(H256::repeat_byte(0x17)),
bootloader_hash: Default::default(),
default_aa_hash: Default::default(),
evm_emulator_hash: Default::default(),
l1_chain_id: L1ChainId(9),
sl_chain_id: None,
protocol_version: Some(ProtocolSemanticVersion {
Expand Down
3 changes: 3 additions & 0 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl Distribution<configs::chain::StateKeeperConfig> for EncodeDist {
fee_account_addr: None,
bootloader_hash: None,
default_aa_hash: None,
evm_emulator_hash: None,
l1_batch_commit_data_generator_mode: Default::default(),
}
}
Expand Down Expand Up @@ -261,6 +262,7 @@ impl Distribution<configs::ContractsConfig> for EncodeDist {
ecosystem_contracts: self.sample(rng),
base_token_addr: self.sample_opt(|| rng.gen()),
chain_admin_addr: self.sample_opt(|| rng.gen()),
eigenda_verifier_addr: self.sample_opt(|| rng.gen()),
}
}
}
Expand Down Expand Up @@ -732,6 +734,7 @@ impl Distribution<configs::GenesisConfig> for EncodeDist {
genesis_commitment: Some(rng.gen()),
bootloader_hash: Some(rng.gen()),
default_aa_hash: Some(rng.gen()),
evm_emulator_hash: Some(rng.gen()),
fee_account: rng.gen(),
l1_chain_id: L1ChainId(self.sample(rng)),
sl_chain_id: None,
Expand Down
5 changes: 5 additions & 0 deletions core/lib/constants/src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ pub const CODE_ORACLE_ADDRESS: Address = H160([
0x00, 0x00, 0x80, 0x12,
]);

pub const EVM_GAS_MANAGER_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x13,
]);

/// Note, that the `Create2Factory` is explicitly deployed on a non-system-contract address.
pub const CREATE2_FACTORY_ADDRESS: Address = H160([
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down
29 changes: 27 additions & 2 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const LOADNEXT_CONTRACT_FILE: &str =
"etc/contracts-test-data/artifacts-zk/contracts/loadnext/loadnext_contract.sol/LoadnextContract.json";
const LOADNEXT_SIMPLE_CONTRACT_FILE: &str =
"etc/contracts-test-data/artifacts-zk/contracts/loadnext/loadnext_contract.sol/Foo.json";

const EIGENDA_VERIFIER_CONTRACT_FILE: (&str, &str) =
("eigenda", "EigendaVerifier.sol/EigendaVerifier.json");
fn home_path() -> PathBuf {
Workspace::locate().core()
}
Expand Down Expand Up @@ -163,6 +164,10 @@ pub fn verifier_contract() -> Contract {
load_contract_for_both_compilers(VERIFIER_CONTRACT_FILE)
}

pub fn eigenda_verifier_contract() -> Contract {
load_contract_for_both_compilers(EIGENDA_VERIFIER_CONTRACT_FILE)
}

#[derive(Debug, Clone)]
pub struct TestContract {
/// Contract bytecode to be used for sending deploy transaction.
Expand Down Expand Up @@ -293,6 +298,7 @@ fn read_zbin_bytecode_from_path(bytecode_path: PathBuf) -> Vec<u8> {
fs::read(&bytecode_path)
.unwrap_or_else(|err| panic!("Can't read .zbin bytecode at {:?}: {}", bytecode_path, err))
}

/// Hash of code and code which consists of 32 bytes words
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SystemContractCode {
Expand All @@ -304,18 +310,23 @@ pub struct SystemContractCode {
pub struct BaseSystemContracts {
pub bootloader: SystemContractCode,
pub default_aa: SystemContractCode,
/// Never filled in constructors for now. The only way to get the EVM emulator enabled is to call [`Self::with_evm_emulator()`].
pub evm_emulator: Option<SystemContractCode>,
}

#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq)]
pub struct BaseSystemContractsHashes {
pub bootloader: H256,
pub default_aa: H256,
pub evm_emulator: Option<H256>,
}

impl PartialEq for BaseSystemContracts {
fn eq(&self, other: &Self) -> bool {
self.bootloader.hash == other.bootloader.hash
&& self.default_aa.hash == other.default_aa.hash
&& self.evm_emulator.as_ref().map(|contract| contract.hash)
== other.evm_emulator.as_ref().map(|contract| contract.hash)
}
}

Expand All @@ -339,14 +350,27 @@ impl BaseSystemContracts {
BaseSystemContracts {
bootloader,
default_aa,
evm_emulator: None,
}
}
// BaseSystemContracts with proved bootloader - for handling transactions.

/// BaseSystemContracts with proved bootloader - for handling transactions.
pub fn load_from_disk() -> Self {
let bootloader_bytecode = read_proved_batch_bootloader_bytecode();
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

/// Loads the latest EVM emulator for these base system contracts. Logically, it only makes sense to do for the latest protocol version.
pub fn with_latest_evm_emulator(mut self) -> Self {
let bytecode = read_sys_contract_bytecode("", "EvmInterpreter", ContractLanguage::Yul);
let hash = hash_bytecode(&bytecode);
self.evm_emulator = Some(SystemContractCode {
code: bytes_to_be_words(bytecode),
hash,
});
self
}

/// BaseSystemContracts with playground bootloader - used for handling eth_calls.
pub fn playground() -> Self {
let bootloader_bytecode = read_playground_batch_bootloader_bytecode();
Expand Down Expand Up @@ -475,6 +499,7 @@ impl BaseSystemContracts {
BaseSystemContractsHashes {
bootloader: self.bootloader.hash,
default_aa: self.default_aa.hash,
evm_emulator: self.evm_emulator.as_ref().map(|contract| contract.hash),
}
}
}
Expand Down

This file was deleted.

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

This file was deleted.

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

This file was deleted.

Loading