Struct cfx_executor::state::State
source · pub struct State { /* private fields */ }
Expand description
A caching and checkpoint layer built upon semantically meaningful database interfaces, providing interfaces and logics for managing accounts and global statistics to the execution engine.
Implementations§
source§impl State
impl State
pub fn new_contract_with_admin( &mut self, contract: &AddressWithSpace, admin: &Address, balance: U256, storage_layout: Option<StorageLayout>, cip107: bool ) -> DbResult<()>
sourcepub fn remove_contract(&mut self, address: &AddressWithSpace) -> DbResult<()>
pub fn remove_contract(&mut self, address: &AddressWithSpace) -> DbResult<()>
Kill a contract
sourcepub fn genesis_special_remove_account(
&mut self,
address: &Address
) -> DbResult<()>
pub fn genesis_special_remove_account( &mut self, address: &Address ) -> DbResult<()>
A special implementation to achieve the backward compatible for the genesis (incorrect) behaviour.
source§impl State
impl State
pub fn exists(&self, address: &AddressWithSpace) -> DbResult<bool>
pub fn exists_and_not_null(&self, address: &AddressWithSpace) -> DbResult<bool>
pub fn balance(&self, address: &AddressWithSpace) -> DbResult<U256>
pub fn add_balance( &mut self, address: &AddressWithSpace, by: &U256, cleanup_mode: CleanupMode<'_> ) -> DbResult<()>
pub fn sub_balance( &mut self, address: &AddressWithSpace, by: &U256, cleanup_mode: &mut CleanupMode<'_> ) -> DbResult<()>
pub fn transfer_balance( &mut self, from: &AddressWithSpace, to: &AddressWithSpace, by: &U256, cleanup_mode: CleanupMode<'_> ) -> DbResult<()>
pub fn nonce(&self, address: &AddressWithSpace) -> DbResult<U256>
pub fn inc_nonce(&mut self, address: &AddressWithSpace) -> DbResult<()>
pub fn set_nonce( &mut self, address: &AddressWithSpace, nonce: &U256 ) -> DbResult<()>
pub fn is_contract_with_code( &self, address: &AddressWithSpace ) -> DbResult<bool>
pub fn code_hash(&self, address: &AddressWithSpace) -> DbResult<H256>
pub fn code_size(&self, address: &AddressWithSpace) -> DbResult<usize>
pub fn code_owner(&self, address: &AddressWithSpace) -> DbResult<Address>
pub fn code(&self, address: &AddressWithSpace) -> DbResult<Option<Arc<Vec<u8>>>>
pub fn init_code( &mut self, address: &AddressWithSpace, code: Bytes, owner: Address ) -> DbResult<()>
pub fn admin(&self, address: &Address) -> DbResult<Address>
pub fn set_admin( &mut self, contract_address: &Address, admin: &Address ) -> DbResult<()>
source§impl State
impl State
sourcepub fn write_account_lock(
&self,
address: &AddressWithSpace
) -> DbResult<MappedRwLockWriteGuard<'_, OverlayAccount>>
pub fn write_account_lock( &self, address: &AddressWithSpace ) -> DbResult<MappedRwLockWriteGuard<'_, OverlayAccount>>
A convenience function of write_account_ext_lock
source§impl State
impl State
pub fn collateral_for_storage(&self, address: &Address) -> DbResult<U256>
pub fn token_collateral_for_storage(&self, address: &Address) -> DbResult<U256>
pub fn available_storage_points_for_collateral( &self, address: &Address ) -> DbResult<U256>
sourcepub fn add_collateral_for_storage(
&mut self,
address: &Address,
by: &U256
) -> DbResult<U256>
pub fn add_collateral_for_storage( &mut self, address: &Address, by: &U256 ) -> DbResult<U256>
Caller should make sure that staking_balance for this account is sufficient enough.
pub fn sub_collateral_for_storage( &mut self, address: &Address, by: &U256 ) -> DbResult<U256>
pub fn check_storage_limit( &self, original_sender: &Address, storage_limit: &U256, dry_run: bool ) -> DbResult<Result<(), CollateralCheckError>>
pub fn storage_point_prop(&self) -> DbResult<U256>
source§impl State
impl State
sourcepub fn commit(
self,
epoch_id: EpochId,
debug_record: Option<&mut ComputeEpochDebugRecord>
) -> DbResult<StateCommitResult>
pub fn commit( self, epoch_id: EpochId, debug_record: Option<&mut ComputeEpochDebugRecord> ) -> DbResult<StateCommitResult>
Commit everything to the storage.
sourcepub fn compute_state_root_for_genesis(
&mut self,
debug_record: Option<&mut ComputeEpochDebugRecord>
) -> DbResult<StateRootWithAuxInfo>
pub fn compute_state_root_for_genesis( &mut self, debug_record: Option<&mut ComputeEpochDebugRecord> ) -> DbResult<StateRootWithAuxInfo>
Commit to the statedb and compute state root. Only called in the genesis
source§impl State
impl State
pub fn total_issued_tokens(&self) -> U256
sourcepub fn add_total_issued(&mut self, v: U256)
pub fn add_total_issued(&mut self, v: U256)
Maintain total_issued_tokens
.
sourcepub fn sub_total_issued(&mut self, v: U256)
pub fn sub_total_issued(&mut self, v: U256)
Maintain total_issued_tokens
. This is only used in the extremely
unlikely case that there are a lot of partial invalid blocks.
pub fn add_total_pos_staking(&mut self, v: U256)
pub fn add_total_evm_tokens(&mut self, v: U256)
pub fn sub_total_evm_tokens(&mut self, v: U256)
pub fn total_staking_tokens(&self) -> U256
pub fn total_storage_tokens(&self) -> U256
pub fn total_espace_tokens(&self) -> U256
pub fn used_storage_points(&self) -> U256
pub fn converted_storage_points(&self) -> U256
pub fn total_pos_staking_tokens(&self) -> U256
pub fn sub_total_pos_staking(&mut self, v: U256)
pub fn total_circulating_tokens(&self) -> DbResult<U256>
pub fn add_converted_storage_point( &mut self, from_balance: U256, from_collateral: U256 )
source§impl State
impl State
pub fn inc_distributable_pos_interest( &mut self, current_block_number: u64 ) -> DbResult<()>
pub fn pos_locked_staking(&self, address: &Address) -> DbResult<U256>
pub fn add_pos_interest( &mut self, address: &Address, interest: &U256, cleanup_mode: CleanupMode<'_> ) -> DbResult<()>
source§impl State
impl State
pub fn sponsor_info(&self, address: &Address) -> DbResult<Option<SponsorInfo>>
pub fn sponsor_for_gas(&self, address: &Address) -> DbResult<Option<Address>>
pub fn set_sponsor_for_gas( &self, address: &Address, sponsor: &Address, sponsor_balance: &U256, upper_bound: &U256 ) -> DbResult<()>
pub fn sponsor_balance_for_gas(&self, address: &Address) -> DbResult<U256>
pub fn add_sponsor_balance_for_gas( &mut self, address: &Address, by: &U256 ) -> DbResult<()>
pub fn sub_sponsor_balance_for_gas( &mut self, address: &Address, by: &U256 ) -> DbResult<()>
pub fn sponsor_gas_bound(&self, address: &Address) -> DbResult<U256>
pub fn sponsor_for_collateral( &self, address: &Address ) -> DbResult<Option<Address>>
pub fn set_sponsor_for_collateral( &mut self, address: &Address, sponsor: &Address, sponsor_balance: &U256, is_cip107: bool ) -> DbResult<U256>
pub fn sponsor_balance_for_collateral( &self, address: &Address ) -> DbResult<U256>
pub fn add_sponsor_balance_for_collateral( &mut self, address: &Address, by: &U256 ) -> DbResult<()>
pub fn sub_sponsor_balance_for_collateral( &mut self, address: &Address, by: &U256 ) -> DbResult<()>
pub fn check_contract_whitelist( &self, contract_address: &Address, user: &Address ) -> DbResult<bool>
pub fn add_to_contract_whitelist( &mut self, contract_address: Address, storage_owner: Address, user: Address, substate: &mut Substate ) -> DbResult<()>
pub fn remove_from_contract_whitelist( &mut self, contract_address: Address, storage_owner: Address, user: Address, substate: &mut Substate ) -> DbResult<()>
pub fn record_storage_and_whitelist_entries_release( &mut self, address: &Address, substate: &mut Substate, cip131: bool ) -> DbResult<()>
source§impl State
impl State
pub fn staking_balance(&self, address: &Address) -> DbResult<U256>
pub fn withdrawable_staking_balance( &self, address: &Address, current_block_number: u64 ) -> DbResult<U256>
pub fn locked_staking_balance_at_block_number( &self, address: &Address, block_number: u64 ) -> DbResult<U256>
pub fn vote_stake_list_length(&self, address: &Address) -> DbResult<usize>
pub fn vote_lock( &mut self, address: &Address, amount: &U256, unlock_block_number: u64 ) -> DbResult<()>
pub fn remove_expired_vote_stake_info( &mut self, address: &Address, current_block_number: u64 ) -> DbResult<()>
pub fn deposit_list_length(&self, address: &Address) -> DbResult<usize>
pub fn deposit( &mut self, address: &Address, amount: &U256, current_block_number: u64, cip_97: bool ) -> DbResult<()>
pub fn withdraw( &mut self, address: &Address, amount: &U256, cip_97: bool ) -> DbResult<U256>
source§impl State
impl State
pub fn get_system_storage(&self, key: &[u8]) -> DbResult<U256>
pub fn set_system_storage(&mut self, key: Vec<u8>, value: U256) -> DbResult<()>
pub fn storage_at( &self, address: &AddressWithSpace, key: &[u8] ) -> DbResult<U256>
pub fn transient_storage_at( &self, address: &AddressWithSpace, key: &[u8] ) -> DbResult<U256>
pub fn storage_entry_at( &self, address: &AddressWithSpace, key: &[u8] ) -> DbResult<StorageValue>
pub fn set_storage( &mut self, address: &AddressWithSpace, key: Vec<u8>, value: U256, owner: Address, substate: &mut Substate ) -> DbResult<()>
pub fn transient_set_storage( &mut self, address: &AddressWithSpace, key: Vec<u8>, value: U256 ) -> DbResult<()>
pub fn is_fresh_storage(&self, address: &AddressWithSpace) -> DbResult<bool>
source§impl State
impl State
sourcepub fn bump_block_number_accumulate_interest(&mut self)
pub fn bump_block_number_accumulate_interest(&mut self)
Calculate the secondary reward for the next block number.
pub fn secondary_reward(&self) -> U256
pub fn pow_base_reward(&self) -> U256
pub fn distributable_pos_interest(&self) -> U256
pub fn last_distribute_block(&self) -> u64
pub fn reset_pos_distribute_info(&mut self, current_block_number: u64)
pub fn burn_by_cip1559(&mut self, by: U256)
pub fn get_base_price_prop(&self) -> U256
pub fn set_base_fee_prop(&mut self, val: U256)
pub fn burnt_gas_price(&self, base_price: U256) -> U256
Auto Trait Implementations§
impl !RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl !UnwindSafe for State
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Conv for T
impl<T> Conv for T
source§impl<T> ElementSatisfy<ElementNoConstrain> for T
impl<T> ElementSatisfy<ElementNoConstrain> for T
fn to_constrain_object(&self) -> &ElementNoConstrain
fn to_constrain_object_mut(&mut self) -> &mut ElementNoConstrain
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.