Skip to content

Commit 0ada318

Browse files
committed
Update from upstream
2 parents 8549e41 + 9985c26 commit 0ada318

File tree

93 files changed

+1815
-1480
lines changed

Some content is hidden

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

93 files changed

+1815
-1480
lines changed

.github/workflows/ci-zk-toolbox-reusable.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,30 @@ jobs:
9090
9191
- name: Run server
9292
run: |
93-
ci_run zk_inception server --ignore-prerequisites -a --verbose &>server.log &
93+
ci_run zk_inception server --ignore-prerequisites &>server.log &
9494
ci_run sleep 5
9595
9696
- name: Run integration tests
9797
run: |
9898
ci_run zk_supervisor integration-tests --ignore-prerequisites --verbose
9999
100+
101+
- name: Run external node server
102+
run: |
103+
ci_run zk_inception external-node configs --db-url=postgres://postgres:notsecurepassword@postgres:5432 \
104+
--db-name=zksync_en_localhost_era --l1-rpc-url=http://reth:8545
105+
ci_run zk_inception external-node init --ignore-prerequisites
106+
ci_run zk_inception external-node run --ignore-prerequisites &>external_node.log &
107+
ci_run sleep 5
108+
109+
- name: Run integration tests en
110+
run: |
111+
ci_run zk_supervisor integration-tests --ignore-prerequisites --verbose --external-node
112+
100113
- name: Show server.log logs
101114
if: always()
102115
run: ci_run cat server.log || true
116+
- name: Show external_node.log logs
117+
if: always()
118+
run: ci_run cat external_node.log || true
119+

bin/zkt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
cd $(dirname $0)
4+
cd ../zk_toolbox
5+
6+
cargo install --path ./crates/zk_inception --force
7+
cargo install --path ./crates/zk_supervisor --force

chains/era/ZkStack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ chain_id: 271
44
prover_version: NoProofs
55
configs: ./chains/era/configs/
66
rocks_db_path: ./chains/era/db/
7+
external_node_config_path: ./chains/era/configs/external_node
78
l1_batch_commit_data_generator_mode: Rollup
89
base_token:
910
address: '0x0000000000000000000000000000000000000001'

core/bin/external_node/src/config/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ pub(crate) struct OptionalENConfig {
421421
#[serde(default = "OptionalENConfig::default_snapshots_recovery_postgres_max_concurrency")]
422422
pub snapshots_recovery_postgres_max_concurrency: NonZeroUsize,
423423

424+
#[serde(default)]
425+
pub snapshots_recovery_object_store: Option<ObjectStoreConfig>,
426+
424427
/// Enables pruning of the historical node state (Postgres and Merkle tree). The node will retain
425428
/// recent state and will continuously remove (prune) old enough parts of the state in the background.
426429
#[serde(default)]
@@ -619,6 +622,10 @@ impl OptionalENConfig {
619622
.as_ref()
620623
.map(|a| a.enabled)
621624
.unwrap_or_default(),
625+
snapshots_recovery_object_store: load_config!(
626+
general_config.snapshot_recovery,
627+
object_store
628+
),
622629
pruning_chunk_size: load_optional_config_or_default!(
623630
general_config.pruning,
624631
chunk_size,
@@ -798,9 +805,11 @@ impl OptionalENConfig {
798805
}
799806

800807
fn from_env() -> anyhow::Result<Self> {
801-
envy::prefixed("EN_")
808+
let mut result: OptionalENConfig = envy::prefixed("EN_")
802809
.from_env()
803-
.context("could not load external node config")
810+
.context("could not load external node config")?;
811+
result.snapshots_recovery_object_store = snapshot_recovery_object_store_config().ok();
812+
Ok(result)
804813
}
805814

806815
pub fn polling_interval(&self) -> Duration {

core/bin/external_node/src/config/observability.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub(crate) struct ObservabilityENConfig {
2626
/// Log format to use: either `plain` (default) or `json`.
2727
#[serde(default)]
2828
pub log_format: LogFormat,
29+
// Log directives in format that is used in `RUST_LOG`
30+
pub log_directives: Option<String>,
2931
}
3032

3133
impl ObservabilityENConfig {
@@ -80,6 +82,9 @@ impl ObservabilityENConfig {
8082

8183
pub fn build_observability(&self) -> anyhow::Result<zksync_vlog::ObservabilityGuard> {
8284
let mut builder = zksync_vlog::ObservabilityBuilder::new().with_log_format(self.log_format);
85+
if let Some(log_directives) = self.log_directives.clone() {
86+
builder = builder.with_log_directives(log_directives)
87+
};
8388
// Some legacy deployments use `unset` as an equivalent of `None`.
8489
let sentry_url = self.sentry_url.as_deref().filter(|&url| url != "unset");
8590
if let Some(sentry_url) = sentry_url {
@@ -100,7 +105,7 @@ impl ObservabilityENConfig {
100105
}
101106

102107
pub(crate) fn from_configs(general_config: &GeneralConfig) -> anyhow::Result<Self> {
103-
let (sentry_url, sentry_environment, log_format) =
108+
let (sentry_url, sentry_environment, log_format, log_directives) =
104109
if let Some(observability) = general_config.observability.as_ref() {
105110
(
106111
observability.sentry_url.clone(),
@@ -109,9 +114,10 @@ impl ObservabilityENConfig {
109114
.log_format
110115
.parse()
111116
.context("Invalid log format")?,
117+
observability.log_directives.clone(),
112118
)
113119
} else {
114-
(None, None, LogFormat::default())
120+
(None, None, LogFormat::default(), None)
115121
};
116122
let (prometheus_port, prometheus_pushgateway_url, prometheus_push_interval_ms) =
117123
if let Some(prometheus) = general_config.prometheus_config.as_ref() {
@@ -130,6 +136,7 @@ impl ObservabilityENConfig {
130136
sentry_url,
131137
sentry_environment,
132138
log_format,
139+
log_directives,
133140
})
134141
}
135142
}

core/bin/external_node/src/init.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::time::Instant;
44

55
use anyhow::Context as _;
6+
use zksync_config::ObjectStoreConfig;
67
use zksync_dal::{ConnectionPool, Core, CoreDal};
78
use zksync_health_check::AppHealthCheck;
89
use zksync_node_sync::genesis::perform_genesis_if_needed;
@@ -12,13 +13,12 @@ use zksync_snapshots_applier::{SnapshotsApplierConfig, SnapshotsApplierTask};
1213
use zksync_types::{L1BatchNumber, L2ChainId};
1314
use zksync_web3_decl::client::{DynClient, L2};
1415

15-
use crate::config::snapshot_recovery_object_store_config;
16-
1716
#[derive(Debug)]
1817
pub(crate) struct SnapshotRecoveryConfig {
1918
/// If not specified, the latest snapshot will be used.
2019
pub snapshot_l1_batch_override: Option<L1BatchNumber>,
2120
pub drop_storage_key_preimages: bool,
21+
pub object_store_config: Option<ObjectStoreConfig>,
2222
}
2323

2424
#[derive(Debug)]
@@ -91,7 +91,9 @@ pub(crate) async fn ensure_storage_initialized(
9191
)?;
9292

9393
tracing::warn!("Proceeding with snapshot recovery. This is an experimental feature; use at your own risk");
94-
let object_store_config = snapshot_recovery_object_store_config()?;
94+
let object_store_config = recovery_config.object_store_config.context(
95+
"Snapshot object store must be presented if snapshot recovery is activated",
96+
)?;
9597
let object_store = ObjectStoreFactory::new(object_store_config)
9698
.create_store()
9799
.await?;

core/bin/external_node/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ async fn run_node(
974974
drop_storage_key_preimages: config
975975
.experimental
976976
.snapshots_recovery_drop_storage_key_preimages,
977+
object_store_config: config.optional.snapshots_recovery_object_store.clone(),
977978
});
978979
ensure_storage_initialized(
979980
connection_pool.clone(),

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,21 +827,33 @@ pub enum TransactionCondition {
827827
}
828828

829829
// `FeeHistory`: from `web3::types::fee_history`
830+
// Adapted to support blobs.
830831

831832
/// The fee history type returned from `eth_feeHistory` call.
832833
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
833834
#[serde(rename_all = "camelCase")]
834835
pub struct FeeHistory {
835836
/// Lowest number block of the returned range.
836837
pub oldest_block: BlockNumber,
837-
/// A vector of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.
838+
/// A vector of block base fees per gas. This includes the next block after the newest of the returned range,
839+
/// because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.
838840
#[serde(default)] // some node implementations skip empty lists
839841
pub base_fee_per_gas: Vec<U256>,
840842
/// A vector of block gas used ratios. These are calculated as the ratio of gas used and gas limit.
841843
#[serde(default)] // some node implementations skip empty lists
842844
pub gas_used_ratio: Vec<f64>,
843-
/// A vector of effective priority fee per gas data points from a single block. All zeroes are returned if the block is empty. Returned only if requested.
845+
/// A vector of effective priority fee per gas data points from a single block. All zeroes are returned if
846+
/// the block is empty. Returned only if requested.
844847
pub reward: Option<Vec<Vec<U256>>>,
848+
/// An array of base fees per blob gas for blocks. This includes the next block following the newest in the
849+
/// returned range, as this value can be derived from the latest block. For blocks before EIP-4844, zeroes
850+
/// are returned.
851+
#[serde(default)] // some node implementations skip empty lists
852+
pub base_fee_per_blob_gas: Vec<U256>,
853+
/// An array showing the ratios of blob gas used in blocks. These ratios are calculated by dividing blobGasUsed
854+
/// by the maximum blob gas per block.
855+
#[serde(default)] // some node implementations skip empty lists
856+
pub blob_gas_used_ratio: Vec<f64>,
845857
}
846858

847859
// `SyncInfo`, `SyncState`: from `web3::types::sync_state`

core/lib/eth_client/src/clients/http/query.rs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use zksync_web3_decl::error::{ClientRpcContext, EnrichedClientError, EnrichedCli
88
use super::{decl::L1EthNamespaceClient, Method, COUNTERS, LATENCIES};
99
use crate::{
1010
types::{ExecutedTxStatus, FailureInfo},
11-
EthInterface, RawTransactionBytes,
11+
BaseFees, EthInterface, RawTransactionBytes,
1212
};
1313

1414
#[async_trait]
@@ -78,7 +78,15 @@ where
7878
&self,
7979
upto_block: usize,
8080
block_count: usize,
81-
) -> EnrichedClientResult<Vec<u64>> {
81+
) -> EnrichedClientResult<Vec<BaseFees>> {
82+
// Non-panicking conversion to u64.
83+
fn cast_to_u64(value: U256, tag: &str) -> EnrichedClientResult<u64> {
84+
u64::try_from(value).map_err(|_| {
85+
let err = ClientError::Custom(format!("{tag} value does not fit in u64"));
86+
EnrichedClientError::new(err, "cast_to_u64").with_arg("value", &value)
87+
})
88+
}
89+
8290
const MAX_REQUEST_CHUNK: usize = 1024;
8391

8492
COUNTERS.call[&(Method::BaseFeeHistory, self.component())].inc();
@@ -103,11 +111,34 @@ where
103111
.with_arg("chunk_size", &chunk_size)
104112
.with_arg("block", &chunk_end)
105113
.await?;
106-
history.extend(fee_history.base_fee_per_gas);
114+
115+
// Check that the lengths are the same.
116+
// Per specification, the values should always be provided, and must be 0 for blocks
117+
// prior to EIP-4844.
118+
// https://ethereum.github.io/execution-apis/api-documentation/
119+
if fee_history.base_fee_per_gas.len() != fee_history.base_fee_per_blob_gas.len() {
120+
tracing::error!(
121+
"base_fee_per_gas and base_fee_per_blob_gas have different lengths: {} and {}",
122+
fee_history.base_fee_per_gas.len(),
123+
fee_history.base_fee_per_blob_gas.len()
124+
);
125+
}
126+
127+
for (base, blob) in fee_history
128+
.base_fee_per_gas
129+
.into_iter()
130+
.zip(fee_history.base_fee_per_blob_gas)
131+
{
132+
let fees = BaseFees {
133+
base_fee_per_gas: cast_to_u64(base, "base_fee_per_gas")?,
134+
base_fee_per_blob_gas: blob,
135+
};
136+
history.push(fees)
137+
}
107138
}
108139

109140
latency.observe();
110-
Ok(history.into_iter().map(|fee| fee.as_u64()).collect())
141+
Ok(history)
111142
}
112143

113144
async fn get_pending_block_base_fee_per_gas(&self) -> EnrichedClientResult<U256> {

0 commit comments

Comments
 (0)