state

package
v0.0.0-...-cff1f21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountKey

func AccountKey(addr common.Address) common.Bytes

AccountKey constructs the state key for the given address

func ChainIDKey

func ChainIDKey() common.Bytes

ChainIDKey returns the key for chainID

func CodeKey

func CodeKey(codeHash common.Bytes) common.Bytes

CodeKey constructs the state key for the given code hash

func EliteEdgeNodeKey

func EliteEdgeNodeKey(addr common.Address) common.Bytes

EliteEdgeNodeKey returns the elite edge node key of a given address

func EliteEdgeNodeKeyPrefix

func EliteEdgeNodeKeyPrefix() common.Bytes

EliteEdgeNodeKeyPrefix returns the prefix of the elite edge node key

func EliteEdgeNodeStakeReturnsKey

func EliteEdgeNodeStakeReturnsKey(height uint64) common.Bytes

EliteEdgeNodeStakeReturnsKey returns the EEN stake return key for the given height

func EliteEdgeNodeStakeReturnsKeyPrefix

func EliteEdgeNodeStakeReturnsKeyPrefix() common.Bytes

EliteEdgeNodeStakeReturnsKeyPrefix returns the prefix of the elite edge node stake return key

func EliteEdgeNodesTotalActiveStakeKey

func EliteEdgeNodesTotalActiveStakeKey() common.Bytes

func GuardianCandidatePoolKey

func GuardianCandidatePoolKey() common.Bytes

GuardianCandidatePoolKey returns the state key for the guadian stake holder set

func SplitRuleKey

func SplitRuleKey(resourceID string) common.Bytes

SplitRuleKey constructs the state key for the given resourceID

func SplitRuleKeyPrefix

func SplitRuleKeyPrefix() common.Bytes

SplitRuleKeyPrefix returns the prefix for the split rule key

func StakeRewardDistributionRuleSetKey

func StakeRewardDistributionRuleSetKey(addr common.Address) common.Bytes

StakeRewardDistributionRuleSetKey returns the prefix of the stake reward distribution rule

func StakeRewardDistributionRuleSetKeyPrefix

func StakeRewardDistributionRuleSetKeyPrefix() common.Bytes

StakeRewardDistributionRuleSetKeyPrefix returns the prefix of the stake reward distribution rule

func StakeTransactionHeightListKey

func StakeTransactionHeightListKey() common.Bytes

StakeTransactionHeightListKey returns the state key the heights of blocks that contain stake related transactions (i.e. StakeDeposit, StakeWithdraw, etc)

func StatePruningProgressKey

func StatePruningProgressKey() common.Bytes

StatePruningProgressKey returns the key for the state pruning progress

func ValidatorCandidatePoolKey

func ValidatorCandidatePoolKey() common.Bytes

ValidatorCandidatePoolKey returns the state key for the validator stake holder set

Types

type EliteEdgeNodePool

type EliteEdgeNodePool struct {
	// contains filtered or unexported fields
}

func NewEliteEdgeNodePool

func NewEliteEdgeNodePool(sv *StoreView, readOnly bool) *EliteEdgeNodePool

NewEliteEdgeNodePool creates a new instance of EliteEdgeNodePool.

func (*EliteEdgeNodePool) Contains

func (eenp *EliteEdgeNodePool) Contains(eenAddr common.Address) bool

Contains checks if given address is in the pool.

func (*EliteEdgeNodePool) DepositStake

func (eenp *EliteEdgeNodePool) DepositStake(source common.Address, holder common.Address, amount *big.Int, pubkey *bls.PublicKey, blockHeight uint64) (err error)

func (*EliteEdgeNodePool) Get

func (eenp *EliteEdgeNodePool) Get(eenAddr common.Address) *core.EliteEdgeNode

Get returns the EEN if exists, nil otherwise

func (*EliteEdgeNodePool) GetAll

func (eenp *EliteEdgeNodePool) GetAll(withstake bool) []*core.EliteEdgeNode

func (*EliteEdgeNodePool) GetPubKeys

func (eenp *EliteEdgeNodePool) GetPubKeys(eenAddrs []common.Address) []*bls.PublicKey

GetPubKeys returns BLS pubkeys of given addresses.

func (*EliteEdgeNodePool) GetStake

func (eenp *EliteEdgeNodePool) GetStake(source common.Address, holder common.Address, withdrawnOnly bool) (stake *core.Stake, err error)

func (*EliteEdgeNodePool) RandomRewardWeight

func (eenp *EliteEdgeNodePool) RandomRewardWeight(block common.Hash, eenAddr common.Address) int

Contains checks if given address is in the pool.

func (*EliteEdgeNodePool) Remove

func (eenp *EliteEdgeNodePool) Remove(een *core.EliteEdgeNode)

Remove deletes the elite edge node from the pool

func (*EliteEdgeNodePool) ReturnStake

func (eenp *EliteEdgeNodePool) ReturnStake(currentHeight uint64, holder common.Address, returnedStake core.Stake) error

func (*EliteEdgeNodePool) Upsert

func (eenp *EliteEdgeNodePool) Upsert(een *core.EliteEdgeNode)

Upsert update or insert an elite edge node

func (*EliteEdgeNodePool) WithdrawStake

func (eenp *EliteEdgeNodePool) WithdrawStake(source common.Address, holder common.Address, currentHeight uint64) (*core.Stake, error)

type LedgerState

type LedgerState struct {
	// contains filtered or unexported fields
}

func NewLedgerState

func NewLedgerState(chainID string, db database.Database, tagger Tagger) *LedgerState

NewLedgerState creates a new Leger State with given store. NOTE: before using the LedgerState, we need to call LedgerState.ResetState() to set

the proper height and stateRootHash

func (*LedgerState) Checked

func (s *LedgerState) Checked() *StoreView

Checked creates a fresh clone of delivered view to be used for checking transactions.

func (*LedgerState) Commit

func (s *LedgerState) Commit() common.Hash

Commit stores the current delivered view as committed, starts new delivered/checked state and returns the hash for the commit.

func (*LedgerState) DB

func (s *LedgerState) DB() database.Database

DB returns the database instance of the ledger state

func (*LedgerState) Delivered

func (s *LedgerState) Delivered() *StoreView

Delivered returns a view of current state that contains both committed and delivered transactions.

func (*LedgerState) Finalize

func (s *LedgerState) Finalize(height uint64, stateRootHash common.Hash) result.Result

Finalize updates the finalized view.

func (*LedgerState) Finalized

func (s *LedgerState) Finalized() *StoreView

Finalized creates a fresh clone of delivered view to be used for checking transactions.

func (*LedgerState) GetChainID

func (s *LedgerState) GetChainID() string

GetChainID gets chain ID.

func (*LedgerState) Height

func (s *LedgerState) Height() uint64

Height returns the block height corresponding to the ledger state

func (*LedgerState) ParentBlock

func (s *LedgerState) ParentBlock() *core.Block

ParentBlock returns the pointer to the parent block for the current view

func (*LedgerState) ResetState

func (s *LedgerState) ResetState(block *core.Block) result.Result

ResetState resets the height and state root of its storeviews, and clear the in-memory states func (s *LedgerState) ResetState(height uint64, stateRootHash common.Hash) result.Result

func (*LedgerState) Screened

func (s *LedgerState) Screened() *StoreView

Screened creates a fresh clone of delivered view to be used for checking transactions.

type StakeRewardDistributionRuleSet

type StakeRewardDistributionRuleSet struct {
	// contains filtered or unexported fields
}

func NewStakeRewardDistributionRuleSet

func NewStakeRewardDistributionRuleSet(sv *StoreView) *StakeRewardDistributionRuleSet

NewStakeRewardDistributionRuleSet creates a new instance of StakeRewardDistributionRuleSet.

func (*StakeRewardDistributionRuleSet) Get

Get returns the reward distribution of a stake holder address in the pool. Returns nil if not found.

func (*StakeRewardDistributionRuleSet) GetAll

GetAll returns all the reward distribution rules

func (*StakeRewardDistributionRuleSet) Remove

func (srdr *StakeRewardDistributionRuleSet) Remove(stakeHolder common.Address)

Remove removes an elite edge node from the pool; returns false if guardian is not found.

func (*StakeRewardDistributionRuleSet) Upsert

Upsert update or inserts a stake reward distribution to the rule set

type StakeWithHolder

type StakeWithHolder struct {
	Holder common.Address
	Stake  core.Stake
}

type StoreView

type StoreView struct {
	// contains filtered or unexported fields
}

func NewStoreView

func NewStoreView(height uint64, root common.Hash, db database.Database) *StoreView

NewStoreView creates an instance of the StoreView

func (*StoreView) AddBalance

func (sv *StoreView) AddBalance(addr common.Address, amount *big.Int)

func (*StoreView) AddLog

func (sv *StoreView) AddLog(l *types.Log)

func (*StoreView) AddRefund

func (sv *StoreView) AddRefund(gas uint64)

func (*StoreView) AddSlashIntent

func (sv *StoreView) AddSlashIntent(slashIntent types.SlashIntent)

AddSlashIntent adds slashIntent

func (*StoreView) AddSplitRule

func (sv *StoreView) AddSplitRule(splitRule *types.SplitRule) bool

AddSplitRule adds a split rule

func (*StoreView) AddThetaBalance

func (sv *StoreView) AddThetaBalance(addr common.Address, amount *big.Int)

func (*StoreView) ClearSlashIntents

func (sv *StoreView) ClearSlashIntents()

ClearSlashIntents clears all the slashIntents

func (*StoreView) CoinbaseTransactinProcessed

func (sv *StoreView) CoinbaseTransactinProcessed() bool

CoinbaseTransactinProcessed returns whether the coinbase transaction for the current block has been processed

func (*StoreView) Copy

func (sv *StoreView) Copy() (*StoreView, error)

Copy returns a copy of the StoreView

func (*StoreView) CreateAccount

func (sv *StoreView) CreateAccount(addr common.Address)

func (*StoreView) CreateAccountWithPreviousBalance

func (sv *StoreView) CreateAccountWithPreviousBalance(addr common.Address)

func (*StoreView) Delete

func (sv *StoreView) Delete(key common.Bytes)

Delete removes the value corresponding to the key

func (*StoreView) DeleteAccount

func (sv *StoreView) DeleteAccount(addr common.Address)

DeleteAccount deletes an account.

func (*StoreView) DeleteExpiredSplitRules

func (sv *StoreView) DeleteExpiredSplitRules(currentBlockHeight uint64) bool

DeleteExpiredSplitRules deletes a split rule.

func (*StoreView) DeleteSplitRule

func (sv *StoreView) DeleteSplitRule(resourceID string) bool

DeleteSplitRule deletes a split rule.

func (*StoreView) Empty

func (sv *StoreView) Empty(addr common.Address) bool

Empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).

func (*StoreView) Exist

func (sv *StoreView) Exist(addr common.Address) bool

Exist reports whether the given account exists in state. Notably this should also return true for suicided accounts.

func (*StoreView) Get

func (sv *StoreView) Get(key common.Bytes) common.Bytes

Get returns the value corresponding to the key

func (*StoreView) GetAccount

func (sv *StoreView) GetAccount(addr common.Address) *types.Account

GetAccount returns an account.

func (*StoreView) GetBalance

func (sv *StoreView) GetBalance(addr common.Address) *big.Int

func (*StoreView) GetBlockHeight

func (sv *StoreView) GetBlockHeight() uint64

func (*StoreView) GetCode

func (sv *StoreView) GetCode(addr common.Address) []byte

func (*StoreView) GetCodeByHash

func (sv *StoreView) GetCodeByHash(codeHash common.Hash) []byte

func (*StoreView) GetCodeHash

func (sv *StoreView) GetCodeHash(addr common.Address) common.Hash

func (*StoreView) GetCodeSize

func (sv *StoreView) GetCodeSize(addr common.Address) int

func (*StoreView) GetCommittedState

func (sv *StoreView) GetCommittedState(addr common.Address, key common.Hash) common.Hash

func (*StoreView) GetDB

func (sv *StoreView) GetDB() database.Database

GetDB returns the underlying database.

func (*StoreView) GetEliteEdgeNodeStakeReturns

func (sv *StoreView) GetEliteEdgeNodeStakeReturns(height uint64) []StakeWithHolder

GetEliteEdgeNodeStakeReturns gets the elite edge node stake returns

func (*StoreView) GetGuardianCandidatePool

func (sv *StoreView) GetGuardianCandidatePool() *core.GuardianCandidatePool

GetGuardianCandidatePool gets the guardian candidate pool.

func (*StoreView) GetNonce

func (sv *StoreView) GetNonce(addr common.Address) uint64

func (*StoreView) GetOrCreateAccount

func (sv *StoreView) GetOrCreateAccount(addr common.Address) *types.Account

func (*StoreView) GetRefund

func (sv *StoreView) GetRefund() uint64

func (*StoreView) GetSlashIntents

func (sv *StoreView) GetSlashIntents() []types.SlashIntent

GetSlashIntents retrieves all the slashIntents

func (*StoreView) GetSplitRule

func (sv *StoreView) GetSplitRule(resourceID string) *types.SplitRule

GetSplitRule gets split rule.

func (*StoreView) GetStakeTransactionHeightList

func (sv *StoreView) GetStakeTransactionHeightList() *types.HeightList

GetStakeTransactionHeightList gets the heights of blocks that contain stake related transactions

func (*StoreView) GetState

func (sv *StoreView) GetState(addr common.Address, key common.Hash) common.Hash

func (*StoreView) GetStore

func (sv *StoreView) GetStore() *treestore.TreeStore

func (*StoreView) GetThetaBalance

func (sv *StoreView) GetThetaBalance(addr common.Address) *big.Int

GetThetaBalance returns the ThetaWei balance of the given address

func (*StoreView) GetThetaStake

func (sv *StoreView) GetThetaStake(addr common.Address) *big.Int

GetThetaStake returns the total amount of ThetaWei the address staked to validators and/or guardians

func (*StoreView) GetTotalEENStake

func (sv *StoreView) GetTotalEENStake() *big.Int

GetTotalEENStake retrives the total active EEN stakes

func (*StoreView) GetValidatorCandidatePool

func (sv *StoreView) GetValidatorCandidatePool() *core.ValidatorCandidatePool

GetValidatorCandidatePool gets the validator candidate pool.

func (*StoreView) HasSuicided

func (sv *StoreView) HasSuicided(addr common.Address) bool

func (*StoreView) Hash

func (sv *StoreView) Hash() common.Hash

Hash returns the root hash of the tree store

func (*StoreView) Height

func (sv *StoreView) Height() uint64

Height returns the block height corresponding to the stored state

func (*StoreView) IncrementHeight

func (sv *StoreView) IncrementHeight()

IncrementHeight increments the block height by 1

func (*StoreView) PopBalanceChanges

func (sv *StoreView) PopBalanceChanges() []*types.BalanceChange

func (*StoreView) PopLogs

func (sv *StoreView) PopLogs() []*types.Log

func (*StoreView) ProveVCP

func (sv *StoreView) ProveVCP(vcpKey []byte, vp *core.VCPProof) error

func (*StoreView) Prune

func (sv *StoreView) Prune() error

func (*StoreView) RemoveEliteEdgeNodeStakeReturns

func (sv *StoreView) RemoveEliteEdgeNodeStakeReturns(height uint64)

RemoveEliteEdgeNodeStakeReturns removes the elite edge node stake returns for the given height

func (*StoreView) ResetBalanceChanges

func (sv *StoreView) ResetBalanceChanges()

func (*StoreView) ResetLogs

func (sv *StoreView) ResetLogs()

func (*StoreView) ResetRefund

func (sv *StoreView) ResetRefund()

func (*StoreView) RevertToSnapshot

func (sv *StoreView) RevertToSnapshot(root common.Hash)

func (*StoreView) Save

func (sv *StoreView) Save() common.Hash

Save saves the StoreView to the persistent storage, and return the root hash

func (*StoreView) Set

func (sv *StoreView) Set(key common.Bytes, value common.Bytes)

Set returns the value corresponding to the key

func (*StoreView) SetAccount

func (sv *StoreView) SetAccount(addr common.Address, acc *types.Account)

SetAccount sets an account.

func (*StoreView) SetCode

func (sv *StoreView) SetCode(addr common.Address, code []byte)

func (*StoreView) SetCoinbaseTransactionProcessed

func (sv *StoreView) SetCoinbaseTransactionProcessed(processed bool)

SetCoinbaseTransactionProcessed sets whether the coinbase transaction for the current block has been processed

func (*StoreView) SetEliteEdgeNodeStakeReturns

func (sv *StoreView) SetEliteEdgeNodeStakeReturns(height uint64, stakeReturns []StakeWithHolder)

GetEliteEdgeNodeStakeReturns saves the elite edge node stake returns for the given height

func (*StoreView) SetNonce

func (sv *StoreView) SetNonce(addr common.Address, nonce uint64)

func (*StoreView) SetSplitRule

func (sv *StoreView) SetSplitRule(resourceID string, splitRule *types.SplitRule)

SetSplitRule sets split rule.

func (*StoreView) SetState

func (sv *StoreView) SetState(addr common.Address, key, val common.Hash)

func (*StoreView) SetTotalEENStake

func (sv *StoreView) SetTotalEENStake(amount *big.Int)

SetTotalEENStake sets the total active EEN stakes

func (*StoreView) Snapshot

func (sv *StoreView) Snapshot() common.Hash

func (*StoreView) SplitRuleExists

func (sv *StoreView) SplitRuleExists(resourceID string) bool

SplitRuleExists checks if a split rule associated with the given resourceID already exists

func (*StoreView) SubBalance

func (sv *StoreView) SubBalance(addr common.Address, amount *big.Int)

func (*StoreView) SubRefund

func (sv *StoreView) SubRefund(gas uint64)

func (*StoreView) SubThetaBalance

func (sv *StoreView) SubThetaBalance(addr common.Address, amount *big.Int)

func (*StoreView) Suicide

func (sv *StoreView) Suicide(addr common.Address) bool

func (*StoreView) Traverse

func (sv *StoreView) Traverse(prefix common.Bytes, cb func(k, v common.Bytes) bool) bool

Traverse traverses the trie and calls cb callback func on every key/value pair with key having prefix

func (*StoreView) UpdateGuardianCandidatePool

func (sv *StoreView) UpdateGuardianCandidatePool(gcp *core.GuardianCandidatePool)

UpdateGuardianCandidatePool updates the guardian candidate pool.

func (*StoreView) UpdateSplitRule

func (sv *StoreView) UpdateSplitRule(splitRule *types.SplitRule) bool

UpdateSplitRule updates a split rule

func (*StoreView) UpdateStakeTransactionHeightList

func (sv *StoreView) UpdateStakeTransactionHeightList(hl *types.HeightList)

UpdateStakeTransactionHeightList updates the heights of blocks that contain stake related transactions

func (*StoreView) UpdateValidatorCandidatePool

func (sv *StoreView) UpdateValidatorCandidatePool(vcp *core.ValidatorCandidatePool)

UpdateValidatorCandidatePool updates the validator candidate pool.

type Tagger

type Tagger interface {
	Tag(height uint64, root common.Hash)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL