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

[WIP] Eigenda implementation, zk_toolbox version #274

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
be428a5
initial commit
juan518munoz Sep 17, 2024
0ad4ca9
fix retrieve-blobs in toml
juan518munoz Sep 18, 2024
6feb624
Add eigenda to toolbox
gianbelinche Sep 19, 2024
d3a95a0
feat: Eigen Blob ID in L1 (#275)
gianbelinche Sep 19, 2024
081c1b2
Merge branch 'da-eigen-implementation' into toolbox-eigenda
gianbelinche Sep 19, 2024
5c87565
Update submodule
gianbelinche Sep 19, 2024
d6f7f48
Merge pull request #277 from lambdaclass/toolbox-eigenda
juanbono Sep 20, 2024
869babb
feat: eigenDA more metrics (#281)
juan518munoz Sep 26, 2024
5021488
fix: Get blob from L1 (#282)
gianbelinche Sep 26, 2024
cc954c4
initial commit
juan518munoz Sep 26, 2024
3150e0d
use Notify for a more deterministic approach
juan518munoz Sep 27, 2024
b108adc
replace atomic for mutex
juan518munoz Oct 2, 2024
1286def
move const to config
juan518munoz Oct 2, 2024
3a21329
Merge branch 'main' into da-eigen-merged-main
gianbelinche Oct 4, 2024
d963287
Update contracts
gianbelinche Oct 4, 2024
2394dd5
Finalize merge
gianbelinche Oct 4, 2024
6b0b902
feat: concurrent da_dispatcher (#288)
juan518munoz Oct 7, 2024
e40c06b
Merge branch 'main' into da-eigen-merged-main
gianbelinche Oct 7, 2024
4726372
Update contracts
gianbelinche Oct 7, 2024
aa6ea7d
feat: Da eigen implementation docs & backup scripts (#289)
juan518munoz Oct 7, 2024
a5b7659
Update query jsons
gianbelinche Oct 7, 2024
df6d952
Merge branch 'da-eigen-implementation' into da-eigen-merged-main
gianbelinche Oct 7, 2024
04d2395
Format md
gianbelinche Oct 7, 2024
8a0ed94
Merge branch 'main' into da-eigen-merged-main
gianbelinche Oct 8, 2024
bdb3a82
Refactor secrets
gianbelinche Oct 8, 2024
d06b433
Merge pull request #290 from lambdaclass/da-eigen-merged-main
juan518munoz Oct 8, 2024
f44616e
Update from M0 PR (#296)
gianbelinche Oct 9, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@ configs/*
era-observability/
core/tests/ts-integration/deployments-zk
transactions/

# Ecosystem backups
ecosystem_backups/
2 changes: 2 additions & 0 deletions Cargo.lock

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

54 changes: 54 additions & 0 deletions backup-ecosystem.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/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"
exit 1
fi

# Store the first argument as ECOSYSTEM_NAME
ECOSYSTEM_NAME=$1

# Prompt for the Postgres password and store it in PGPASSWORD
read -sp "Enter Postgres password: " PGPASSWORD
export PGPASSWORD

# Path to the secrets.yaml file
SECRETS_FILE="./chains/${ECOSYSTEM_NAME}/configs/secrets.yaml"

# Check if the secrets.yaml file exists
if [ ! -f "$SECRETS_FILE" ]; then
echo "Error: $SECRETS_FILE does not exist."
exit 1
fi

# Extract server_url and prover_url from the secrets.yaml file
SERVER_DB_NAME=$(grep 'server_url' "$SECRETS_FILE" | awk -F'/' '{print $NF}')
PROVER_DB_NAME=$(grep 'prover_url' "$SECRETS_FILE" | awk -F'/' '{print $NF}')

# Export the database names
echo "Extracted SERVER_DB_NAME: $SERVER_DB_NAME"
echo "Extracted PROVER_DB_NAME: $PROVER_DB_NAME"

# Create backup directory
mkdir -p "./ecosystem_backups/${ECOSYSTEM_NAME}"

# Run pg_dump commands
echo "Running pg_dump for $SERVER_DB_NAME..."
pg_dump -U postgres -h localhost "$SERVER_DB_NAME" > "ecosystem_backups/${ECOSYSTEM_NAME}/${SERVER_DB_NAME}_backup.sql"
echo "Running pg_dump for $PROVER_DB_NAME..."
pg_dump -U postgres -h localhost "$PROVER_DB_NAME" > "ecosystem_backups/${ECOSYSTEM_NAME}/${PROVER_DB_NAME}_backup.sql"

# Unset the PGPASSWORD variable for security
unset PGPASSWORD

# Copy the chain configuration files
cp -r "./chains/${ECOSYSTEM_NAME}" "./ecosystem_backups/${ECOSYSTEM_NAME}/"

# Copy the configs directory
cp -r "./configs" "./ecosystem_backups/${ECOSYSTEM_NAME}/"

echo "Backup completed."
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
14 changes: 10 additions & 4 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use zksync_node_framework::{
consensus::MainNodeConsensusLayer,
contract_verification_api::ContractVerificationApiLayer,
da_clients::{
avail::AvailWiringLayer, no_da::NoDAClientWiringLayer,
avail::AvailWiringLayer, eigen_da::EigenDAWiringLayer, no_da::NoDAClientWiringLayer,
object_store::ObjectStorageClientWiringLayer,
},
da_dispatcher::DataAvailabilityDispatcherLayer,
Expand Down Expand Up @@ -509,17 +509,23 @@ impl MainNodeBuilder {
return Ok(self);
};

let secrets = try_load_config!(self.secrets.data_availability);
let secrets = self.secrets.data_availability.clone();

match (da_client_config, secrets) {
(DAClientConfig::Avail(config), DataAvailabilitySecrets::Avail(secret)) => {
self.node.add_layer(AvailWiringLayer::new(config, secret));
(DAClientConfig::Avail(_), None) => {
anyhow::bail!("Data availability secrets are required for the Avail client");
}

(DAClientConfig::Avail(config), Some(DataAvailabilitySecrets::Avail(secret))) => {
self.node.add_layer(AvailWiringLayer::new(config, secret));
}
(DAClientConfig::ObjectStore(config), _) => {
self.node
.add_layer(ObjectStorageClientWiringLayer::new(config));
}
(DAClientConfig::EigenDA(config), _) => {
self.node.add_layer(EigenDAWiringLayer::new(config));
}
}

Ok(self)
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
8 changes: 8 additions & 0 deletions core/lib/config/src/configs/da_client/eigen_da.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use serde::Deserialize;

#[derive(Clone, Debug, PartialEq, Deserialize, Default)]
pub struct EigenDAConfig {
pub api_node_url: String,
pub custom_quorum_numbers: Option<Vec<u32>>,
pub account_id: Option<String>,
}
6 changes: 6 additions & 0 deletions core/lib/config/src/configs/da_client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use eigen_da::EigenDAConfig;

use crate::{AvailConfig, ObjectStoreConfig};

pub mod avail;
pub mod eigen_da;

pub const EIGENDA_CLIENT_CONFIG_NAME: &str = "EigenDA";

pub const AVAIL_CLIENT_CONFIG_NAME: &str = "Avail";
pub const OBJECT_STORE_CLIENT_CONFIG_NAME: &str = "ObjectStore";
Expand All @@ -9,4 +14,5 @@ pub const OBJECT_STORE_CLIENT_CONFIG_NAME: &str = "ObjectStore";
pub enum DAClientConfig {
Avail(AvailConfig),
ObjectStore(ObjectStoreConfig),
EigenDA(EigenDAConfig),
}
4 changes: 4 additions & 0 deletions core/lib/config/src/configs/da_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub const DEFAULT_POLLING_INTERVAL_MS: u32 = 5000;
pub const DEFAULT_MAX_ROWS_TO_DISPATCH: u32 = 100;
pub const DEFAULT_MAX_RETRIES: u16 = 5;
pub const DEFAULT_USE_DUMMY_INCLUSION_DATA: bool = false;
pub const DEFAULT_MAX_CONCURRENT_REQUESTS: u32 = 100;

#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct DADispatcherConfig {
Expand All @@ -19,6 +20,8 @@ pub struct DADispatcherConfig {
// TODO: run a verification task to check if the L1 contract expects the inclusion proofs to
// avoid the scenario where contracts expect real proofs, and server is using dummy proofs.
pub use_dummy_inclusion_data: Option<bool>,
/// The maximun number of concurrent request to send to the DA server.
pub max_concurrent_requests: Option<u32>,
}

impl DADispatcherConfig {
Expand All @@ -28,6 +31,7 @@ impl DADispatcherConfig {
max_rows_to_dispatch: Some(DEFAULT_MAX_ROWS_TO_DISPATCH),
max_retries: Some(DEFAULT_MAX_RETRIES),
use_dummy_inclusion_data: Some(DEFAULT_USE_DUMMY_INCLUSION_DATA),
max_concurrent_requests: Some(DEFAULT_MAX_CONCURRENT_REQUESTS),
}
}

Expand Down
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 @@ -732,6 +733,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 Expand Up @@ -966,6 +968,7 @@ impl Distribution<configs::da_dispatcher::DADispatcherConfig> for EncodeDist {
max_rows_to_dispatch: self.sample(rng),
max_retries: self.sample(rng),
use_dummy_inclusion_data: self.sample(rng),
max_concurrent_requests: self.sample(rng),
}
}
}
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
22 changes: 21 additions & 1 deletion core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,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 +305,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 +345,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 +494,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

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

Loading
Loading