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(eth-sender): gateway support for eth tx manager #2593

Merged
merged 53 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a2c3a89
wip
StanislavBreadless Jul 30, 2024
830a952
some additional changes
StanislavBreadless Jul 31, 2024
2894721
a few small changes
StanislavBreadless Jul 31, 2024
338eade
fix lint
StanislavBreadless Jul 31, 2024
d1d3beb
remove inconsistency
StanislavBreadless Jul 31, 2024
e9e8b9e
upd pr
StanislavBreadless Jul 31, 2024
d827bbc
hopefully fix lint
StanislavBreadless Jul 31, 2024
fa77803
Merge branch 'main' into sb-rename-sl-chain-id
StanislavBreadless Jul 31, 2024
709b06d
return none on tests
StanislavBreadless Jul 31, 2024
2cfffc6
hopefully fix lint
StanislavBreadless Jul 31, 2024
ba395ec
Merge remote-tracking branch 'origin/sb-rename-sl-chain-id' into sb-r…
StanislavBreadless Jul 31, 2024
8a9d0b4
sync with main
StanislavBreadless Aug 1, 2024
f3d13a2
apply diff for a new gas adjuster
StanislavBreadless Aug 1, 2024
2e2e368
compiles
StanislavBreadless Aug 1, 2024
2961346
use the same zk as in main
StanislavBreadless Aug 1, 2024
b63b26c
prettify code
StanislavBreadless Aug 1, 2024
982b2a0
a bit more polishing
StanislavBreadless Aug 1, 2024
86628e3
resolve more issues
StanislavBreadless Aug 1, 2024
5502eca
hopefully resolve compilation this time
StanislavBreadless Aug 1, 2024
d050125
sync with main
StanislavBreadless Aug 1, 2024
a85eac2
cargo fix
StanislavBreadless Aug 2, 2024
5e22a87
fix lint
StanislavBreadless Aug 2, 2024
6fd3ad4
first round of change
StanislavBreadless Aug 2, 2024
26a2eee
more changes
StanislavBreadless Aug 2, 2024
8ffaf5f
nit
StanislavBreadless Aug 2, 2024
c4091e9
return back old naming for smaller diff
StanislavBreadless Aug 2, 2024
31ad4cc
Merge branch 'main' into sb-track-l2-fees-for-gateway
StanislavBreadless Aug 2, 2024
91b38a3
impl review
StanislavBreadless Aug 5, 2024
31edada
remove most of copypaste
StanislavBreadless Aug 5, 2024
19054b0
almost finalize
StanislavBreadless Aug 5, 2024
1fac151
some final fixes
StanislavBreadless Aug 5, 2024
789f271
some more fixing
StanislavBreadless Aug 5, 2024
1a9b42e
remove more unneeded things
StanislavBreadless Aug 5, 2024
690a0ae
same contracts as main
StanislavBreadless Aug 5, 2024
9a0ecce
Merge branch 'main' into sb-track-l2-fees-for-gateway
StanislavBreadless Aug 5, 2024
09031d9
first version
tomg10 Aug 5, 2024
91d93d0
fix compilation issue
tomg10 Aug 5, 2024
0d9f8cf
fix compilation issue, PR feedback
tomg10 Aug 5, 2024
7ac6f9b
missing sqlx file
tomg10 Aug 5, 2024
97e14eb
missing bound l2 resource
tomg10 Aug 5, 2024
5aa7d07
missing bound l2 resource
tomg10 Aug 5, 2024
b9c5fbf
merge
tomg10 Aug 12, 2024
7d4dd57
merge fix
tomg10 Aug 12, 2024
072e495
merge fix
tomg10 Aug 12, 2024
3c1019b
fix
tomg10 Aug 12, 2024
5ca14a8
fix
tomg10 Aug 12, 2024
c7849fa
fix
tomg10 Aug 12, 2024
78f32f6
lint fixes
tomg10 Aug 12, 2024
4fd3c08
fmt
tomg10 Aug 12, 2024
50f26be
Merge branch 'main' into tjg-gateway-support-for-eth-tx-manager
tomg10 Aug 12, 2024
be87c01
fix
tomg10 Aug 13, 2024
5088b51
Merge branch 'main' into tjg-gateway-support-for-eth-tx-manager
tomg10 Aug 19, 2024
dc38a46
Merge branch 'main' into tjg-gateway-support-for-eth-tx-manager
tomg10 Aug 19, 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
4 changes: 2 additions & 2 deletions core/bin/block_reverter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tokio::{
};
use zksync_block_reverter::{
eth_client::{
clients::{Client, PKSigningClient},
clients::{Client, PKSigningClient, L1},
EthInterface,
},
BlockReverter, BlockReverterEthConfig, NodeRole,
Expand Down Expand Up @@ -251,7 +251,7 @@ async fn main() -> anyhow::Result<()> {
json,
operator_address,
} => {
let eth_client = Client::http(l1_secrets.l1_rpc_url.clone())
let eth_client = Client::<L1>::http(l1_secrets.l1_rpc_url.clone())
.context("Ethereum client")?
.build();

Expand Down
2 changes: 2 additions & 0 deletions core/bin/external_node/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ impl ExternalNodeBuilder {
let query_eth_client_layer = QueryEthClientLayer::new(
self.config.required.settlement_layer_id(),
self.config.required.eth_client_url.clone(),
// TODO(EVM-676): add this config for external node
Default::default(),
);
self.node.add_layer(query_eth_client_layer);
Ok(self)
Expand Down
8 changes: 7 additions & 1 deletion core/bin/external_node/src/tests/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ impl WiringLayer for MockL1ClientLayer {

fn layer_name(&self) -> &'static str {
// We don't care about values, we just want to hijack the layer name.
QueryEthClientLayer::new(SLChainId(1), "https://example.com".parse().unwrap()).layer_name()
// TODO(EVM-676): configure the `settlement_mode` here
QueryEthClientLayer::new(
SLChainId(1),
"https://example.com".parse().unwrap(),
Default::default(),
)
.layer_name()
}

async fn wire(self, _: Self::Input) -> Result<Self::Output, WiringError> {
Expand Down
4 changes: 2 additions & 2 deletions core/bin/external_node/src/tests/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use tempfile::TempDir;
use zksync_dal::CoreDal;
use zksync_db_connection::connection_pool::TestTemplate;
use zksync_eth_client::clients::MockEthereum;
use zksync_eth_client::clients::MockSettlementLayer;
use zksync_node_genesis::{insert_genesis_batch, GenesisBatchParams, GenesisParams};
use zksync_types::{
api, block::L2BlockHeader, ethabi, Address, L2BlockNumber, ProtocolVersionId, H256,
Expand Down Expand Up @@ -119,7 +119,7 @@ pub(super) fn expected_health_components(components: &ComponentsToRun) -> Vec<&'
}

pub(super) fn mock_eth_client(diamond_proxy_addr: Address) -> MockClient<L1> {
let mock = MockEthereum::builder().with_call_handler(move |call, _| {
let mock = MockSettlementLayer::builder().with_call_handler(move |call, _| {
tracing::info!("L1 call: {call:?}");
if call.to == Some(diamond_proxy_addr) {
let packed_semver = ProtocolVersionId::latest().into_packed_semver_with_patch(0);
Expand Down
13 changes: 10 additions & 3 deletions core/bin/zksync_server/src/node_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ use zksync_node_framework::{
},
service::{ZkStackService, ZkStackServiceBuilder},
};
use zksync_types::SHARED_BRIDGE_ETHER_TOKEN_ADDRESS;
use zksync_types::{settlement::SettlementMode, SHARED_BRIDGE_ETHER_TOKEN_ADDRESS};
use zksync_vlog::prometheus::PrometheusExporterConfig;

/// Macro that looks into a path to fetch an optional config,
Expand Down Expand Up @@ -151,8 +151,15 @@ impl MainNodeBuilder {
fn add_query_eth_client_layer(mut self) -> anyhow::Result<Self> {
let genesis = self.genesis_config.clone();
let eth_config = try_load_config!(self.secrets.l1);
let query_eth_client_layer =
QueryEthClientLayer::new(genesis.settlement_layer_id(), eth_config.l1_rpc_url);
let query_eth_client_layer = QueryEthClientLayer::new(
genesis.settlement_layer_id(),
eth_config.l1_rpc_url,
self.configs
.eth
.as_ref()
.and_then(|x| Some(x.gas_adjuster?.settlement_mode))
.unwrap_or(SettlementMode::SettlesToL1),
);
self.node.add_layer(query_eth_client_layer);
Ok(self)
}
Expand Down
1 change: 1 addition & 0 deletions core/lib/basic_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub mod commitment;
pub mod network;
pub mod protocol_version;
pub mod prover_dal;
pub mod settlement;
pub mod tee_types;
pub mod url;
pub mod vm_version;
Expand Down
16 changes: 16 additions & 0 deletions core/lib/basic_types/src/settlement.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use serde::{Deserialize, Serialize};

/// An enum which is used to describe whether a zkSync network settles to L1 or to the gateway.
/// Gateway is an Ethereum-compatible L2 and so it requires different treatment with regards to DA handling.
#[derive(Default, Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum SettlementMode {
#[default]
SettlesToL1,
Gateway,
}

impl SettlementMode {
pub fn is_gateway(&self) -> bool {
matches!(self, Self::Gateway)
}
}
10 changes: 8 additions & 2 deletions core/lib/config/src/configs/eth_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::Duration;

use anyhow::Context as _;
use serde::Deserialize;
use zksync_basic_types::H256;
use zksync_basic_types::{settlement::SettlementMode, H256};
use zksync_crypto_primitives::K256PrivateKey;

use crate::EthWatchConfig;
Expand All @@ -24,7 +24,7 @@ impl EthConfig {
Self {
sender: Some(SenderConfig {
aggregated_proof_sizes: vec![1],
wait_confirmations: Some(1),
wait_confirmations: Some(10),
tx_poll_period: 1,
aggregate_tx_poll_period: 1,
max_txs_in_flight: 30,
Expand Down Expand Up @@ -54,6 +54,7 @@ impl EthConfig {
num_samples_for_blob_base_fee_estimate: 10,
internal_pubdata_pricing_multiplier: 1.0,
max_blob_base_fee: None,
settlement_mode: Default::default(),
}),
watcher: Some(EthWatchConfig {
confirmations_for_eth_event: None,
Expand Down Expand Up @@ -82,6 +83,7 @@ pub enum PubdataSendingMode {
Calldata,
Blobs,
Custom,
RelayedL2Calldata,
}

#[derive(Debug, Deserialize, Clone, PartialEq)]
Expand Down Expand Up @@ -181,6 +183,10 @@ pub struct GasAdjusterConfig {
pub internal_pubdata_pricing_multiplier: f64,
/// Max blob base fee that is allowed to be used.
pub max_blob_base_fee: Option<u64>,
/// Whether the gas adjuster should require that the L2 node is used as a settlement layer.
/// It offers a runtime check for correctly provided values.
#[serde(default)]
pub settlement_mode: SettlementMode,
}

impl GasAdjusterConfig {
Expand Down
2 changes: 2 additions & 0 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ impl Distribution<configs::eth_sender::GasAdjusterConfig> for EncodeDist {
num_samples_for_blob_base_fee_estimate: self.sample(rng),
internal_pubdata_pricing_multiplier: self.sample(rng),
max_blob_base_fee: self.sample(rng),
// TODO(EVM-676): generate it randomly once this value is used
settlement_mode: Default::default(),
}
}
}
Expand Down

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

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

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

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.

Loading
Loading