Skip to content

Commit a388df2

Browse files
author
Flatt
committed
Updated one third of doc comments
1 parent 65dad46 commit a388df2

File tree

23 files changed

+253
-202
lines changed

23 files changed

+253
-202
lines changed

crates/context/interface/src/result.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,9 @@ pub enum SuccessReason {
427427
EofReturnContract,
428428
}
429429

430-
/// Indicates that the EVM has experienced an exceptional halt. This causes execution to
431-
/// immediately end with all gas being consumed.
430+
/// Indicates that the EVM has experienced an exceptional halt.
431+
///
432+
/// This causes execution to immediately end with all gas being consumed.
432433
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
433434
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
434435
pub enum HaltReason {

crates/context/interface/src/transaction/access_list.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use primitives::{Address, B256};
44
/// Access list type is introduced in EIP-2930, and every
55
/// transaction after it contains access list.
66
///
7-
/// Note
8-
///
9-
/// Iterator over access list returns account address and storage slot keys that
7+
/// **Note**: Iterator over access list returns account address and storage slot keys that
108
/// are warm loaded before transaction execution.
119
///
1210
/// Number of account and storage slots is used to calculate initial tx gas cost.

crates/context/interface/src/transaction/eip7702.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub trait Eip7702Tx: Eip1559Tx {
1212
/// Returns length of the authorization list.
1313
///
1414
/// # Note
15-
///
1615
/// Transaction is considered invalid if list is empty.
1716
fn authorization_list_len(&self) -> usize;
1817

@@ -28,10 +27,9 @@ pub trait Eip7702Tx: Eip1559Tx {
2827
/// Authorization trait.
2928
#[auto_impl(&, Arc)]
3029
pub trait Authorization: Clone {
31-
/// Authority address.
30+
/// Authority address
3231
///
3332
/// # Note
34-
///
3533
/// Authority signature can be invalid, so this method returns None if the authority
3634
/// could not be recovered.
3735
///
@@ -45,7 +43,6 @@ pub trait Authorization: Clone {
4543
/// Returns the nonce.
4644
///
4745
/// # Note
48-
///
4946
/// If nonce is not same as the nonce of the signer account,
5047
/// the authorization is skipped.
5148
fn nonce(&self) -> u64;
@@ -78,7 +75,6 @@ impl Authorization for RecoveredAuthorization {
7875
/// Returns the nonce.
7976
///
8077
/// # Note
81-
///
8278
/// If nonce is not same as the nonce of the signer account,
8379
/// authorization is skipped and considered invalidated.
8480
fn nonce(&self) -> u64 {

crates/context/src/journaled_state.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,12 @@ impl<DB: Database> JournaledStateTrait for JournaledState<DB> {
175175
}
176176

177177
impl<DB: Database> JournaledState<DB> {
178-
/// Create new JournaledState.
178+
/// Creates new JournaledState.
179179
///
180-
/// warm_preloaded_addresses is used to determine if address is considered warm loaded.
180+
/// `warm_preloaded_addresses` is used to determine if address is considered warm loaded.
181181
/// In ordinary case this is precompile or beneficiary.
182182
///
183183
/// # Note
184-
///
185184
/// This function will journal state after Spurious Dragon fork.
186185
/// And will not take into account if account is not existing or empty.
187186
pub fn new(spec: SpecId, database: DB) -> JournaledState<DB> {
@@ -259,8 +258,9 @@ impl<DB: Database> JournaledState<DB> {
259258
account.info.code = Some(code);
260259
}
261260

262-
/// use it only if you know that acc is warm
263-
/// Assume account is warm
261+
/// Use it only if you know that acc is warm.
262+
///
263+
/// Assume account is warm.
264264
#[inline]
265265
pub fn set_code(&mut self, address: Address, code: Bytecode) {
266266
let hash = code.hash_slow();
@@ -336,7 +336,7 @@ impl<DB: Database> JournaledState<DB> {
336336
Ok(None)
337337
}
338338

339-
/// Create account or return false if collision is detected.
339+
/// Creates account or returns false if collision is detected.
340340
///
341341
/// There are few steps done:
342342
/// 1. Make created account warm loaded (AccessList) and this should
@@ -421,7 +421,7 @@ impl<DB: Database> JournaledState<DB> {
421421
Ok(checkpoint)
422422
}
423423

424-
/// Revert all changes that happened in given journal entries.
424+
/// Reverts all changes that happened in given journal entries.
425425
#[inline]
426426
fn journal_revert(
427427
state: &mut EvmState,
@@ -540,7 +540,7 @@ impl<DB: Database> JournaledState<DB> {
540540
checkpoint
541541
}
542542

543-
/// Commit the checkpoint.
543+
/// Commits the checkpoint.
544544
#[inline]
545545
pub fn checkpoint_commit(&mut self) {
546546
self.depth -= 1;
@@ -572,14 +572,14 @@ impl<DB: Database> JournaledState<DB> {
572572
self.journal.truncate(checkpoint.journal_i);
573573
}
574574

575-
/// Performances selfdestruct action.
575+
/// Performs selfdestruct action.
576576
/// Transfers balance from address to target. Check if target exist/is_cold
577577
///
578578
/// Note: Balance will be lost if address and target are the same BUT when
579579
/// current spec enables Cancun, this happens only when the account associated to address
580580
/// is created in the same tx
581581
///
582-
/// references:
582+
/// # References:
583583
/// * <https://github.com/ethereum/go-ethereum/blob/141cd425310b503c5678e674a8c3872cf46b7086/core/vm/instructions.go#L832-L833>
584584
/// * <https://github.com/ethereum/go-ethereum/blob/141cd425310b503c5678e674a8c3872cf46b7086/core/state/statedb.go#L449>
585585
/// * <https://eips.ethereum.org/EIPS/eip-6780>
@@ -675,7 +675,7 @@ impl<DB: Database> JournaledState<DB> {
675675
Ok(account)
676676
}
677677

678-
/// load account into memory. return if it is cold or warm accessed
678+
/// Loads account into memory. return if it is cold or warm accessed
679679
#[inline]
680680
pub fn load_account(&mut self, address: Address) -> Result<StateLoad<&mut Account>, DB::Error> {
681681
self.load_account_optional(address, false)
@@ -707,7 +707,7 @@ impl<DB: Database> JournaledState<DB> {
707707
self.load_account_optional(address, true)
708708
}
709709

710-
/// Loads code.
710+
/// Loads code
711711
#[inline]
712712
pub fn load_account_optional(
713713
&mut self,
@@ -762,7 +762,7 @@ impl<DB: Database> JournaledState<DB> {
762762
Ok(load)
763763
}
764764

765-
/// Load storage slot
765+
/// Loads storage slot.
766766
///
767767
/// # Panics
768768
///
@@ -805,11 +805,10 @@ impl<DB: Database> JournaledState<DB> {
805805
}
806806

807807
/// Stores storage slot.
808-
/// And returns (original,present,new) slot value.
809808
///
810-
/// Note:
809+
/// And returns (original,present,new) slot value.
811810
///
812-
/// account should already be present in our state.
811+
/// **Note**: Account should already be present in our state.
813812
#[inline]
814813
pub fn sstore(
815814
&mut self,
@@ -909,7 +908,7 @@ impl<DB: Database> JournaledState<DB> {
909908
}
910909
}
911910

912-
/// push log into subroutine
911+
/// Pushes log into subroutine.
913912
#[inline]
914913
pub fn log(&mut self, log: Log) {
915914
self.logs.push(log);

crates/database/interface/src/async_db.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<T> WrapDatabaseAsync<T> {
9898
Some(Self { db, rt })
9999
}
100100

101-
/// Wrap a [DatabaseAsync] or [DatabaseAsyncRef] instance, with a runtime.
101+
/// Wraps a [DatabaseAsync] or [DatabaseAsyncRef] instance, with a runtime.
102102
///
103103
/// Refer to [tokio::runtime::Builder] on how to create a runtime if you are in synchronous world.
104104
/// If you are already using something like [tokio::main], call [WrapDatabaseAsync::new] instead.
@@ -107,7 +107,7 @@ impl<T> WrapDatabaseAsync<T> {
107107
Self { db, rt }
108108
}
109109

110-
/// Wrap a [DatabaseAsync] or [DatabaseAsyncRef] instance, with a runtime handle.
110+
/// Wraps a [DatabaseAsync] or [DatabaseAsyncRef] instance, with a runtime handle.
111111
///
112112
/// This generally allows you to pass any valid runtime handle, refer to [tokio::runtime::Handle] on how
113113
/// to obtain a handle. If you are already in asynchronous world, like [tokio::main], use [WrapDatabaseAsync::new]

crates/database/interface/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ pub trait Database {
3636
type Error: DBErrorMarker;
3737
//type Bytecode: BytecodeTrait;
3838

39-
/// Get basic account information.
39+
/// Gets basic account information.
4040
fn basic(&mut self, address: Address) -> Result<Option<AccountInfo>, Self::Error>;
4141

42-
/// Get account code by its hash.
42+
/// Gets account code by its hash.
4343
fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error>;
4444

45-
/// Get storage value of address at index.
45+
/// Gets storage value of address at index.
4646
fn storage(&mut self, address: Address, index: U256) -> Result<U256, Self::Error>;
4747

48-
/// Get block hash by block number.
48+
/// Gets block hash by block number.
4949
fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error>;
5050
}
5151

@@ -67,16 +67,16 @@ pub trait DatabaseRef {
6767
/// The database error type.
6868
type Error: DBErrorMarker;
6969

70-
/// Get basic account information.
70+
/// Gets basic account information.
7171
fn basic_ref(&self, address: Address) -> Result<Option<AccountInfo>, Self::Error>;
7272

73-
/// Get account code by its hash.
73+
/// Gets account code by its hash.
7474
fn code_by_hash_ref(&self, code_hash: B256) -> Result<Bytecode, Self::Error>;
7575

76-
/// Get storage value of address at index.
76+
/// Gets storage value of address at index.
7777
fn storage_ref(&self, address: Address, index: U256) -> Result<U256, Self::Error>;
7878

79-
/// Get block hash by block number.
79+
/// Gets block hash by block number.
8080
fn block_hash_ref(&self, number: u64) -> Result<B256, Self::Error>;
8181
}
8282

crates/database/src/alloydb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct AlloyDB<T: Transport + Clone, N: Network, P: Provider<T, N>> {
3535
}
3636

3737
impl<T: Transport + Clone, N: Network, P: Provider<T, N>> AlloyDB<T, N, P> {
38-
/// Create a new AlloyDB instance, with a [Provider] and a block.
38+
/// Creates a new AlloyDB instance, with a [Provider] and a block.
3939
pub fn new(provider: P, block_number: BlockId) -> Self {
4040
Self {
4141
provider,
@@ -44,7 +44,7 @@ impl<T: Transport + Clone, N: Network, P: Provider<T, N>> AlloyDB<T, N, P> {
4444
}
4545
}
4646

47-
/// Set the block number on which the queries will be based on.
47+
/// Sets the block number on which the queries will be based on.
4848
pub fn set_block_number(&mut self, block_number: BlockId) {
4949
self.block_number = block_number;
5050
}

crates/database/src/in_memory_db.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<ExtDB: Default> Default for CacheDB<ExtDB> {
3939
}
4040

4141
impl<ExtDb> CacheDB<CacheDB<ExtDb>> {
42-
/// Flatten a nested cache by applying the outer cache to the inner cache.
42+
/// Flattens a nested cache by applying the outer cache to the inner cache.
4343
///
4444
/// The behavior is as follows:
4545
/// - Accounts are overridden with outer accounts
@@ -62,14 +62,14 @@ impl<ExtDb> CacheDB<CacheDB<ExtDb>> {
6262
inner
6363
}
6464

65-
/// Discard the outer cache and return the inner cache.
65+
/// Discards the outer cache and return the inner cache.
6666
pub fn discard_outer(self) -> CacheDB<ExtDb> {
6767
self.db
6868
}
6969
}
7070

7171
impl<ExtDB> CacheDB<ExtDB> {
72-
/// Create a new cache with the given external database.
72+
/// Creates a new cache with the given external database.
7373
pub fn new(db: ExtDB) -> Self {
7474
let mut contracts = HashMap::default();
7575
contracts.insert(KECCAK_EMPTY, Bytecode::default());
@@ -104,13 +104,13 @@ impl<ExtDB> CacheDB<ExtDB> {
104104
}
105105
}
106106

107-
/// Insert account info but not override storage
107+
/// Inserts account info but not override storage
108108
pub fn insert_account_info(&mut self, address: Address, mut info: AccountInfo) {
109109
self.insert_contract(&mut info);
110110
self.accounts.entry(address).or_default().info = info;
111111
}
112112

113-
/// Wrap the cache in a [CacheDB], creating a nested cache.
113+
/// Wraps the cache in a [CacheDB], creating a nested cache.
114114
pub fn nest(self) -> CacheDB<Self> {
115115
CacheDB::new(self)
116116
}
@@ -135,7 +135,7 @@ impl<ExtDB: DatabaseRef> CacheDB<ExtDB> {
135135
}
136136
}
137137

138-
/// insert account storage without overriding account info
138+
/// Inserts account storage without overriding account info
139139
pub fn insert_account_storage(
140140
&mut self,
141141
address: Address,
@@ -147,7 +147,7 @@ impl<ExtDB: DatabaseRef> CacheDB<ExtDB> {
147147
Ok(())
148148
}
149149

150-
/// replace account storage without overriding account info
150+
/// Replaces account storage without overriding account info
151151
pub fn replace_account_storage(
152152
&mut self,
153153
address: Address,
@@ -329,7 +329,7 @@ pub struct DbAccount {
329329
pub info: AccountInfo,
330330
/// If account is selfdestructed or newly created, storage will be cleared.
331331
pub account_state: AccountState,
332-
/// storage slots
332+
/// Storage slots
333333
pub storage: HashMap<U256, U256>,
334334
}
335335

crates/database/src/states/account_status.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@ impl AccountStatus {
198198
/// Transition to other state while preserving invariance of this state.
199199
///
200200
/// It this account was Destroyed and other account is not:
201-
/// we should mark extended account as destroyed too.
202-
/// and as other account had some changes, extended account
203-
/// should be marked as DestroyedChanged.
201+
/// - We should mark extended account as destroyed too.
202+
/// - And as other account had some changes, extended account
203+
/// should be marked as DestroyedChanged.
204204
///
205205
/// If both account are not destroyed and if this account is in memory:
206-
/// this means that extended account is in memory too.
206+
/// - This means that extended account is in memory too.
207207
///
208208
/// Otherwise, if both are destroyed or other is destroyed:
209-
/// set other status to extended account.
209+
/// - Sets other status to extended account.
210210
pub fn transition(&mut self, other: Self) {
211211
*self = match (self.was_destroyed(), other.was_destroyed()) {
212212
(true, false) => Self::DestroyedChanged,

crates/database/src/states/bundle_account.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use state::AccountInfo;
1111
/// Status is needed as to know from what state we are applying the TransitionAccount.
1212
///
1313
/// Original account info is needed to know if there was a change.
14+
///
1415
/// Same thing for storage with original value.
1516
///
1617
/// On selfdestruct storage original value is ignored.
@@ -46,6 +47,7 @@ impl BundleAccount {
4647
}
4748

4849
/// The approximate size of changes needed to store this account.
50+
///
4951
/// `1 + storage_len`
5052
pub fn size_hint(&self) -> usize {
5153
1 + self.storage.len()
@@ -127,7 +129,9 @@ impl BundleAccount {
127129
}
128130

129131
/// Update to new state and generate AccountRevert that if applied to new state will
130-
/// revert it to previous state. If no revert is present, update is noop.
132+
/// revert it to previous state.
133+
///
134+
/// If no revert is present, update is noop.
131135
pub fn update_and_create_revert(
132136
&mut self,
133137
transition: TransitionAccount,

0 commit comments

Comments
 (0)