Skip to content

Commit 2ede065

Browse files
refactor: rename stateHash to stateRoot (#978)
* Rename stateHash to stateRoot * Empty commit
1 parent 83ec7c3 commit 2ede065

16 files changed

Lines changed: 43 additions & 43 deletions

File tree

packages/configuration-generator/source/generators/genesis-block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ export class GenesisBlockGenerator extends Generator {
332332
proposer,
333333
reward: BigNumber.ZERO,
334334
round: 0,
335-
stateRoot: await this.evm.stateHash(
335+
stateRoot: await this.evm.stateRoot(
336336
commitKey,
337337
options.snapshot?.snapshotHash ??
338338
"0000000000000000000000000000000000000000000000000000000000000000",

packages/contracts/source/contracts/evm/instance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface Instance extends CommitHandler {
3939
calculateRoundValidators(context: CalculateRoundValidatorsContext): Promise<void>;
4040
updateRewardsAndVotes(context: UpdateRewardsAndVotesContext): Promise<void>;
4141
logsBloom(commitKey: CommitKey): Promise<string>;
42-
stateHash(commitKey: CommitKey, currentHash: string): Promise<string>;
42+
stateRoot(commitKey: CommitKey, currentHash: string): Promise<string>;
4343
codeAt(address: string, height?: bigint): Promise<string>;
4444
storageAt(address: string, slot: bigint): Promise<string>;
4545
snapshot(commitKey: CommitKey): Promise<void>;

packages/crypto-block/source/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class ServiceProvider extends Providers.ServiceProvider {
2727
4 + // height
2828
4 + // round
2929
hashByteLength + // previousBlock
30-
hashByteLength + // stateHash
30+
hashByteLength + // stateRoot
3131
256 + // logsBloom
3232
2 + // transactionsCount
3333
4 + // totalGasUsed

packages/crypto-block/test/helpers/prepare-block.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const prepareBlock = async (context) => {
6969
previousBlock: "0000000000000000000000000000000000000000000000000000000000000000",
7070
reward: BigNumber.ZERO,
7171
round: 1,
72-
stateHash: "0000000000000000000000000000000000000000000000000000000000000000",
72+
stateRoot: "0000000000000000000000000000000000000000000000000000000000000000",
7373
timestamp: 1_703_128_709_748,
7474
totalAmount: totals.amount,
7575
totalFee: totals.fee,

packages/crypto-block/test/helpers/prepare-sandbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const prepareSandbox = async (context) => {
3636
4 + // height
3737
4 + // round
3838
hashByteLength + // previousBlock
39-
hashByteLength + // stateHash
39+
hashByteLength + // stateRoot
4040
256 + // logsBloom
4141
2 + // numberOfTransactions
4242
4 + // totalGasUsed

packages/evm-service/source/instances/evm.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ describe<{
720720
const commitKey = { blockNumber: BigInt(0), round: BigInt(0) };
721721
await instance.prepareNextCommit({ commitKey });
722722

723-
const hash = await instance.stateHash(
723+
const hash = await instance.stateRoot(
724724
commitKey,
725725
"0000000000000000000000000000000000000000000000000000000000000000",
726726
);

packages/evm-service/source/instances/evm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ export class EvmInstance implements Contracts.Evm.Instance, Contracts.Evm.Storag
169169
return this.#evm.storageAt(address, slot);
170170
}
171171

172-
public async stateHash(commitKey: Contracts.Evm.CommitKey, currentHash: string): Promise<string> {
173-
return this.#evm.stateHash(commitKey, currentHash);
172+
public async stateRoot(commitKey: Contracts.Evm.CommitKey, currentHash: string): Promise<string> {
173+
return this.#evm.stateRoot(commitKey, currentHash);
174174
}
175175

176176
public async logsBloom(commitKey: Contracts.Evm.CommitKey): Promise<string> {

packages/evm/bindings/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use mainsail_evm_core::{
1616
logs_bloom,
1717
receipt::{TxReceipt, map_execution_result},
1818
state_changes::AccountUpdate,
19-
state_commit, state_hash,
19+
state_commit, state_root,
2020
};
2121
use napi::{JsBigInt, JsObject, JsString, bindgen_prelude::*};
2222
use napi_derive::napi;
@@ -801,7 +801,7 @@ impl EvmInner {
801801
}
802802
}
803803

804-
pub fn state_hash(
804+
pub fn state_root(
805805
&mut self,
806806
commit_key: CommitKey,
807807
current_hash: B256,
@@ -811,12 +811,12 @@ impl EvmInner {
811811
.get_mut(&commit_key)
812812
.expect("pending commit exists");
813813

814-
let result = state_hash::calculate(&mut self.persistent_db, pending_commit, current_hash);
814+
let result = state_root::calculate(&mut self.persistent_db, pending_commit, current_hash);
815815

816816
match result {
817817
Ok(result) => Ok(result.encode_hex()),
818818
Err(err) => Err(EVMError::Database(
819-
format!("state_hash failed: {}", err).into(),
819+
format!("state_root failed: {}", err).into(),
820820
)),
821821
}
822822
}
@@ -1454,7 +1454,7 @@ impl JsEvmWrapper {
14541454
}
14551455

14561456
#[napi(ts_return_type = "Promise<string>")]
1457-
pub fn state_hash(
1457+
pub fn state_root(
14581458
&mut self,
14591459
node_env: Env,
14601460
commit_key: JsCommitKey,
@@ -1463,7 +1463,7 @@ impl JsEvmWrapper {
14631463
let commit_key = CommitKey::try_from(commit_key)?;
14641464
let current_hash = utils::convert_string_to_b256(current_hash)?;
14651465
node_env.execute_tokio_future(
1466-
Self::state_hash_async(self.evm.clone(), commit_key, current_hash),
1466+
Self::state_root_async(self.evm.clone(), commit_key, current_hash),
14671467
|&mut node_env, result| Ok(node_env.create_string_from_std(result)?),
14681468
)
14691469
}
@@ -1786,13 +1786,13 @@ impl JsEvmWrapper {
17861786
}
17871787
}
17881788

1789-
async fn state_hash_async(
1789+
async fn state_root_async(
17901790
evm: Arc<tokio::sync::Mutex<EvmInner>>,
17911791
commit_key: CommitKey,
17921792
current_hash: B256,
17931793
) -> Result<String> {
17941794
let mut lock = evm.lock().await;
1795-
let result = lock.state_hash(commit_key, current_hash);
1795+
let result = lock.state_root(commit_key, current_hash);
17961796

17971797
match result {
17981798
Ok(result) => Result::Ok(result),

packages/evm/core/src/db.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::{
2727
receipt::{TxReceipt, map_execution_result},
2828
state_changes,
2929
state_commit::StateCommit,
30-
state_hash,
30+
state_root,
3131
};
3232

3333
#[derive(Debug)]
@@ -988,9 +988,9 @@ impl PersistentDB {
988988
rwtxn,
989989
&key.0,
990990
&CommitReceipts {
991-
accounts_hash: state_hash::calculate_accounts_hash(&change_set)?,
992-
contracts_hash: state_hash::calculate_contracts_hash(&change_set)?,
993-
storage_hash: state_hash::calculate_storage_hash(&change_set)?,
991+
accounts_hash: state_root::calculate_accounts_hash(&change_set)?,
992+
contracts_hash: state_root::calculate_contracts_hash(&change_set)?,
993+
storage_hash: state_root::calculate_storage_hash(&change_set)?,
994994
tx_receipts,
995995
},
996996
)?;

packages/evm/core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ pub mod logs_bloom;
88
pub mod receipt;
99
pub mod state_changes;
1010
pub mod state_commit;
11-
pub mod state_hash;
11+
pub mod state_root;

0 commit comments

Comments
 (0)