Skip to content

Commit f0187cb

Browse files
authored
refactor: rename era2 to e2ss (#1656)
1 parent c56bb62 commit f0187cb

File tree

15 files changed

+120
-118
lines changed

15 files changed

+120
-118
lines changed

bin/portal-bridge/src/bridge/state.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66

77
use alloy::{consensus::EMPTY_ROOT_HASH, rlp::Decodable};
88
use anyhow::ensure;
9-
use e2store::utils::get_era2_files;
9+
use e2store::utils::get_e2ss_files;
1010
use eth_trie::{decode_node, node::Node, EthTrie, RootWithTrieDiff, Trie};
1111
use ethportal_api::{
1212
jsonrpsee::http_client::HttpClient,
@@ -41,7 +41,7 @@ use trin_execution::{
4141
account_db::AccountDB, evm_db::EvmDB, execution_position::ExecutionPosition,
4242
utils::setup_rocksdb,
4343
},
44-
subcommands::era2::{
44+
subcommands::e2ss::{
4545
import::StateImporter,
4646
utils::{download_with_progress, percentage_from_address_hash},
4747
},
@@ -177,7 +177,7 @@ impl StateBridge {
177177
async fn launch_snapshot(&self, snapshot_block: u64) -> anyhow::Result<()> {
178178
ensure!(snapshot_block > 0, "Snapshot block must be greater than 0");
179179

180-
// 1. Download the era2 file and import the state snapshot
180+
// 1. Download the e2ss file and import the state snapshot
181181
let data_dir = setup_data_dir(APP_NAME, self.data_dir.clone(), false)?;
182182
let next_block_number = {
183183
let rocks_db = Arc::new(setup_rocksdb(&data_dir)?);
@@ -201,36 +201,36 @@ impl StateBridge {
201201
)]))
202202
.build()?;
203203

204-
let era2_files = get_era2_files(&http_client).await?;
205-
let era2_blocks = era2_files.keys().cloned().collect::<Vec<_>>();
204+
let e2ss_files = get_e2ss_files(&http_client).await?;
205+
let e2ss_blocks = e2ss_files.keys().cloned().collect::<Vec<_>>();
206206

207207
ensure!(
208-
era2_files.contains_key(&snapshot_block),
209-
"Era2 file doesn't exist for requested snapshot block: try these {era2_blocks:?}"
208+
e2ss_files.contains_key(&snapshot_block),
209+
"E2SS file doesn't exist for requested snapshot block: try these {e2ss_blocks:?}"
210210
);
211211

212212
info!(
213-
"Downloading era2 file for snapshot block: {}",
213+
"Downloading e2ss file for snapshot block: {}",
214214
snapshot_block
215215
);
216216

217-
let path_to_era2 = data_dir.join(format!("era2-{snapshot_block}.bin"));
217+
let path_to_e2ss = data_dir.join(format!("e2ss-{snapshot_block}.bin"));
218218
if let Err(e) = download_with_progress(
219219
&http_client,
220-
&era2_files[&snapshot_block],
221-
path_to_era2.clone(),
220+
&e2ss_files[&snapshot_block],
221+
path_to_e2ss.clone(),
222222
)
223223
.await
224224
{
225-
return Err(anyhow::anyhow!("Failed to download era2 file: {e}"));
225+
return Err(anyhow::anyhow!("Failed to download e2ss file: {e}"));
226226
};
227227

228-
let import_state_config = ImportStateConfig { path_to_era2 };
228+
let import_state_config = ImportStateConfig { path_to_e2ss };
229229

230230
let state_importer = StateImporter::new(import_state_config, &data_dir).await?;
231231
let header = state_importer.import().await?;
232232
info!(
233-
"Imported state from era2: {} {}",
233+
"Imported state from e2ss: {} {}",
234234
header.number, header.state_root,
235235
);
236236
}

bin/trin-execution/src/cli.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ pub struct TrinExecutionConfig {
4848
#[derive(Subcommand, Debug, Clone, PartialEq)]
4949
#[allow(clippy::enum_variant_names)]
5050
pub enum TrinExecutionSubCommands {
51-
/// Import a era2 state snapshot from a file, useful for bootstrapping a new node quickly
51+
/// Import a e2ss state snapshot from a file, useful for bootstrapping a new node quickly
5252
ImportState(ImportStateConfig),
53-
/// Export the current state of the node to a era2 file
53+
/// Export the current state of the node to a e2ss file
5454
ExportState(ExportStateConfig),
5555
}
5656

5757
#[derive(Args, Debug, Default, Clone, PartialEq)]
5858
pub struct ImportStateConfig {
59-
#[arg(long, help = "path to where the era2 state snapshot is located")]
60-
pub path_to_era2: PathBuf,
59+
#[arg(long, help = "path to where the e2ss state snapshot is located")]
60+
pub path_to_e2ss: PathBuf,
6161
}
6262

6363
#[derive(Args, Debug, Default, Clone, PartialEq)]
6464
pub struct ExportStateConfig {
65-
#[arg(long, help = "path to where the era2 state snapshot is located")]
66-
pub path_to_era2: PathBuf,
65+
#[arg(long, help = "path to where the e2ss state snapshot is located")]
66+
pub path_to_e2ss: PathBuf,
6767
}

bin/trin-execution/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use tracing::info;
33
use trin_execution::{
44
cli::{TrinExecutionConfig, TrinExecutionSubCommands, APP_NAME},
55
execution::TrinExecution,
6-
subcommands::era2::{export::StateExporter, import::StateImporter},
6+
subcommands::e2ss::{export::StateExporter, import::StateImporter},
77
};
88
use trin_utils::{dir::setup_data_dir, log::init_tracing_logger};
99

@@ -32,7 +32,7 @@ async fn main() -> anyhow::Result<()> {
3232
let state_importer = StateImporter::new(import_state_config, &data_dir).await?;
3333
let header = state_importer.import().await?;
3434
info!(
35-
"Imported state from era2: {} {}",
35+
"Imported state from e2ss: {} {}",
3636
header.number, header.state_root,
3737
);
3838
return Ok(());
@@ -41,7 +41,7 @@ async fn main() -> anyhow::Result<()> {
4141
let state_exporter = StateExporter::new(export_state_config, &data_dir).await?;
4242
state_exporter.export()?;
4343
info!(
44-
"Exported state into era2: {} {}",
44+
"Exported state into e2ss: {} {}",
4545
state_exporter.header().number,
4646
state_exporter.header().state_root,
4747
);

bin/trin-execution/src/subcommands/era2/export.rs renamed to bin/trin-execution/src/subcommands/e2ss/export.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::{
55

66
use alloy::{consensus::EMPTY_ROOT_HASH, rlp::Decodable};
77
use anyhow::ensure;
8-
use e2store::era2::{
9-
AccountEntry, AccountOrStorageEntry, Era2Writer, StorageEntry, StorageItem, MAX_STORAGE_ITEMS,
8+
use e2store::e2ss::{
9+
AccountEntry, AccountOrStorageEntry, E2SSWriter, StorageEntry, StorageItem, MAX_STORAGE_ITEMS,
1010
};
1111
use eth_trie::{EthTrie, Trie};
1212
use ethportal_api::{types::state_trie::account_state::AccountState, Header};
@@ -22,7 +22,7 @@ use crate::{
2222
account_db::AccountDB, evm_db::EvmDB, execution_position::ExecutionPosition,
2323
utils::setup_rocksdb,
2424
},
25-
subcommands::era2::utils::percentage_from_address_hash,
25+
subcommands::e2ss::utils::percentage_from_address_hash,
2626
};
2727

2828
pub struct StateExporter {
@@ -69,8 +69,8 @@ impl StateExporter {
6969
"Exporting state from block number: {} with state root: {}",
7070
self.header.number, self.header.state_root
7171
);
72-
let mut era2 = Era2Writer::create(&self.config.path_to_era2, self.header.clone())?;
73-
info!("Era2 initiated");
72+
let mut e2ss = E2SSWriter::create(&self.config.path_to_e2ss, self.header.clone())?;
73+
info!("E2SS initiated");
7474
info!("Trie leaf iterator initiated");
7575
let mut accounts_exported = 0;
7676
for key_hash_and_leaf_value in self.evm_db.trie.lock().iter() {
@@ -109,15 +109,15 @@ impl StateExporter {
109109
// Get the rounded up storage count
110110
let storage_count = storage.len().div_ceil(MAX_STORAGE_ITEMS);
111111

112-
era2.append_entry(&AccountOrStorageEntry::Account(AccountEntry {
112+
e2ss.append_entry(&AccountOrStorageEntry::Account(AccountEntry {
113113
address_hash: account_hash,
114114
account_state,
115115
bytecode,
116116
storage_count: storage_count as u32,
117117
}))?;
118118

119119
for storage_chunk in storage.chunks(MAX_STORAGE_ITEMS) {
120-
era2.append_entry(&AccountOrStorageEntry::Storage(StorageEntry(
120+
e2ss.append_entry(&AccountOrStorageEntry::Storage(StorageEntry(
121121
storage_chunk.to_vec(),
122122
)))?;
123123
}
@@ -128,11 +128,11 @@ impl StateExporter {
128128
}
129129
}
130130

131-
era2.flush()?;
131+
e2ss.flush()?;
132132

133-
info!("Era2 snapshot exported");
133+
info!("E2SS snapshot exported");
134134

135-
Ok(era2.path().to_path_buf())
135+
Ok(e2ss.path().to_path_buf())
136136
}
137137

138138
pub fn header(&self) -> &Header {

bin/trin-execution/src/subcommands/era2/import.rs renamed to bin/trin-execution/src/subcommands/e2ss/import.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{path::Path, sync::Arc};
22

33
use anyhow::{ensure, Error};
4-
use e2store::era2::{AccountEntry, AccountOrStorageEntry, Era2Reader, StorageItem};
4+
use e2store::e2ss::{AccountEntry, AccountOrStorageEntry, E2SSReader, StorageItem};
55
use eth_trie::{EthTrie, Trie};
66
use ethportal_api::Header;
77
use revm_primitives::{keccak256, B256, U256};
@@ -16,7 +16,7 @@ use crate::{
1616
account_db::AccountDB, evm_db::EvmDB, execution_position::ExecutionPosition,
1717
utils::setup_rocksdb,
1818
},
19-
subcommands::era2::utils::percentage_from_address_hash,
19+
subcommands::e2ss::utils::percentage_from_address_hash,
2020
};
2121

2222
pub struct StateImporter {
@@ -31,7 +31,7 @@ impl StateImporter {
3131
let execution_position = ExecutionPosition::initialize_from_db(rocks_db.clone())?;
3232
ensure!(
3333
execution_position.next_block_number() == 0,
34-
"Cannot import state from .era2, database is not empty",
34+
"Cannot import state from .e2ss, database is not empty",
3535
);
3636

3737
let evm_db = EvmDB::new(StateConfig::default(), rocks_db, &execution_position)
@@ -41,7 +41,7 @@ impl StateImporter {
4141
}
4242

4343
pub async fn import(&self) -> anyhow::Result<Header> {
44-
// Import state from era2 file
44+
// Import state from e2ss file
4545
let header = self.import_state()?;
4646

4747
// Save execution position
@@ -55,12 +55,12 @@ impl StateImporter {
5555
}
5656

5757
fn import_state(&self) -> anyhow::Result<Header> {
58-
info!("Importing state from .era2 file");
58+
info!("Importing state from .e2ss file");
5959

60-
let mut era2 = Era2Reader::open(&self.config.path_to_era2)?;
61-
info!("Era2 reader initiated");
60+
let mut e2ss = E2SSReader::open(&self.config.path_to_e2ss)?;
61+
info!("E2SS reader initiated");
6262
let mut accounts_imported = 0;
63-
while let Some(account) = era2.next() {
63+
while let Some(account) = e2ss.next() {
6464
let AccountOrStorageEntry::Account(account) = account else {
6565
return Err(Error::msg("Expected account, got storage entry"));
6666
};
@@ -75,7 +75,7 @@ impl StateImporter {
7575
let account_db = AccountDB::new(address_hash, self.evm_db.db.clone());
7676
let mut storage_trie = EthTrie::new(Arc::new(account_db));
7777
for _ in 0..storage_count {
78-
let Some(AccountOrStorageEntry::Storage(storage_entry)) = era2.next() else {
78+
let Some(AccountOrStorageEntry::Storage(storage_entry)) = e2ss.next() else {
7979
return Err(Error::msg("Expected storage, got account entry"));
8080
};
8181
for StorageItem {
@@ -92,13 +92,13 @@ impl StateImporter {
9292
}
9393

9494
if storage_trie.root_hash()? != account_state.storage_root {
95-
return Err(Error::msg("Failed importing account storage trie: storage roots don't match expect value, .era2 import failed"));
95+
return Err(Error::msg("Failed importing account storage trie: storage roots don't match expect value, .e2ss import failed"));
9696
}
9797

9898
// Insert contract if available
9999
ensure!(
100100
account_state.code_hash == keccak256(&bytecode),
101-
"Code hash mismatch, .era2 import failed"
101+
"Code hash mismatch, .e2ss import failed"
102102
);
103103
if !bytecode.is_empty() {
104104
self.evm_db.db.put(keccak256(&bytecode), bytecode.clone())?;
@@ -125,15 +125,15 @@ impl StateImporter {
125125
}
126126
}
127127

128-
// Check if the state root matches, if this fails it means either the .era2 is wrong or we
128+
// Check if the state root matches, if this fails it means either the .e2ss is wrong or we
129129
// imported the state wrong
130-
if era2.header.header.state_root != self.evm_db.trie.lock().root_hash()? {
131-
return Err(Error::msg("State root mismatch, .era2 import failed"));
130+
if e2ss.header.header.state_root != self.evm_db.trie.lock().root_hash()? {
131+
return Err(Error::msg("State root mismatch, .e2ss import failed"));
132132
}
133133

134-
info!("Done importing State from .era2 file");
134+
info!("Done importing State from .e2ss file");
135135

136-
Ok(era2.header.header)
136+
Ok(e2ss.header.header)
137137
}
138138

139139
/// insert the last 256 block hashes into the database
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub mod era2;
1+
pub mod e2ss;

bin/trin-execution/tests/export_import.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ use trin_execution::{
44
cli::{ExportStateConfig, ImportStateConfig},
55
config::StateConfig,
66
execution::TrinExecution,
7-
subcommands::era2::{export::StateExporter, import::StateImporter},
7+
subcommands::e2ss::{export::StateExporter, import::StateImporter},
88
};
99
use trin_utils::dir::create_temp_test_dir;
1010

11-
/// Tests that exporting/importing to/from era2 files works.
11+
/// Tests that exporting/importing to/from e2ss files works.
1212
///
1313
/// This test does the following:
1414
/// 1. executes first `blocks` blocks
15-
/// 2. exports state to the era2
16-
/// 3. imports state from era2 file into new directory
15+
/// 2. exports state to the e2ss
16+
/// 3. imports state from e2ss file into new directory
1717
/// 4. executes another `blocks` blocks
1818
///
1919
/// Following command can be used to run the test for different number of blocks (e.g. 10000):
@@ -32,7 +32,7 @@ async fn execute_export_import_execute() -> anyhow::Result<()> {
3232
info!("Running test for {blocks} blocks");
3333

3434
let temp_directory = create_temp_test_dir()?;
35-
let era2_dir = temp_directory.path().join("era");
35+
let e2ss_dir = temp_directory.path().join("era");
3636
let dir_1 = temp_directory.path().join("dir_1");
3737
let dir_2 = temp_directory.path().join("dir_2");
3838

@@ -44,21 +44,21 @@ async fn execute_export_import_execute() -> anyhow::Result<()> {
4444
assert_eq!(trin_execution.next_block_number(), blocks + 1);
4545
drop(trin_execution);
4646

47-
// 2. export from dir_1 into era2
47+
// 2. export from dir_1 into e2ss
4848
let exporter = StateExporter::new(
4949
ExportStateConfig {
50-
path_to_era2: era2_dir,
50+
path_to_e2ss: e2ss_dir,
5151
},
5252
&dir_1,
5353
)
5454
.await?;
55-
let era2_file = exporter.export()?;
55+
let e2ss_file = exporter.export()?;
5656
drop(exporter);
5757

58-
// 3. import from era2 into dir_2
58+
// 3. import from e2ss into dir_2
5959
let importer = StateImporter::new(
6060
ImportStateConfig {
61-
path_to_era2: era2_file,
61+
path_to_e2ss: e2ss_file,
6262
},
6363
&dir_2,
6464
)

crates/e2store/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ tokio.workspace = true
3333
trin-utils.workspace = true
3434

3535
[features]
36-
era2-stats-binary = ["clap", "tracing", "trin-utils"]
36+
e2ss-stats-binary = ["clap", "tracing", "trin-utils"]
3737

3838
[[bin]]
39-
name = "era2-stats"
40-
required-features = ["era2-stats-binary"]
39+
name = "e2ss-stats"
40+
required-features = ["e2ss-stats-binary"]

0 commit comments

Comments
 (0)