Documentation ¶
Overview ¶
Package keeper specifies the keeper for the cvm module.
Index ¶
- Constants
- Variables
- func NewEventSink(ctx sdk.Context) *eventSink
- func NewGasMeter(limit uint64) sdk.GasMeter
- func NewQuerier(keeper Keeper) sdk.Querier
- func RegisterGlobalPermissionAcc(ctx sdk.Context, k Keeper)
- func WrapLogger(l log.Logger) *logging.Logger
- type Blockchain
- type CertificateCallable
- type Keeper
- func (k Keeper) AuthKeeper() types.AccountKeeper
- func (k *Keeper) Call(ctx sdk.Context, caller, callee sdk.AccAddress, value uint64, data []byte, ...) ([]byte, error)
- func (k Keeper) GetAllContracts(ctx sdk.Context) []types.Contract
- func (k Keeper) GetAllMetas(ctx sdk.Context) []types.Metadata
- func (k Keeper) GetCode(ctx sdk.Context, addr crypto.Address) ([]byte, error)
- func (k *Keeper) GetGasRate(ctx sdk.Context) uint64
- func (k Keeper) GetStorage(ctx sdk.Context, address crypto.Address, key binary.Word256) ([]byte, error)
- func (k Keeper) NewState(ctx sdk.Context) *State
- func (k Keeper) RecycleCoins(ctx sdk.Context) error
- func (k Keeper) Send(ctx sdk.Context, caller, callee sdk.AccAddress, coins sdk.Coins) error
- func (k Keeper) SetAbi(ctx sdk.Context, address crypto.Address, abi []byte)
- func (k Keeper) SetGasRate(ctx sdk.Context, gasRate uint64)
- func (k Keeper) StoreLastBlockHash(ctx sdk.Context)
- type State
- func (s *State) GetAccount(address crypto.Address) (*acm.Account, error)
- func (s *State) GetAddressMeta(address crypto.Address) ([]*acm.ContractMeta, error)
- func (s *State) GetMetadata(metahash acmstate.MetadataHash) (string, error)
- func (s *State) GetStorage(address crypto.Address, key binary.Word256) (value []byte, err error)
- func (s *State) RemoveAccount(address crypto.Address) error
- func (s *State) SetAddressMeta(address crypto.Address, contMeta []*acm.ContractMeta) error
- func (s *State) SetMetadata(metahash acmstate.MetadataHash, metadata string) error
- func (s *State) SetStorage(address crypto.Address, key binary.Word256, value []byte) error
- func (s *State) UpdateAccount(updatedAccount *acm.Account) error
- type TestDistrKeeper
- type TestInput
Constants ¶
const ( // TODO: consolidate native contract gas consumption GasBase uint64 = 1000 )
const TransactionGasLimit = uint64(5000000)
TransactionGasLimit is the gas limit of the block.
Variables ¶
var ( InsufficientGasErrorCode = types.BurrowErrorCodeStart + errors.Codes.InsufficientGas.ErrorCode().Number CodeOutOfBoundsErrorCode = types.BurrowErrorCodeStart + errors.Codes.CodeOutOfBounds.ErrorCode().Number ExecutionRevertedErrorCode = types.BurrowErrorCodeStart + errors.Codes.ExecutionReverted.ErrorCode().Number /* pragma solidity >=0.4.22 <0.6.0; contract Hello55 { function sayHi() public pure returns (uint) { return 55; } } */ Hello55BytecodeString = "" /* 404-byte string literal not displayed */ Hello55AbiJsonString = `` /* 139-byte string literal not displayed */ Hello55MetadataJsonString = `` /* 762-byte string literal not displayed */ /* pragma solidity >=0.4.22 <0.6.0; contract BasicTests { uint myFavoriteNumber = 34; function addTwoNumbers(uint a, uint b) public pure returns (uint) { return a + b; } function failureFunction() public pure { revert("Go away!!"); } function setMyFavoriteNumber(uint newFavNum) public { myFavoriteNumber = newFavNum; } } */ BasicTestsBytecodeString = "" /* 850-byte string literal not displayed */ BasicTestsAbiJsonString = `` /* 827-byte string literal not displayed */ /* pragma solidity >=0.4.22 <0.6.0; contract GoofyContract { uint public goofyNumber; function setGoofyNumber(uint a) public { goofyNumber = a; } } contract GasTests { GoofyContract gc; function addTwoNumbers(uint a, uint b) public pure returns (uint) { return a + b; } function hashMe(bytes memory b) public pure returns (bytes32) { return keccak256(b); } function deployAnotherContract() public { gc = new GoofyContract(); } function setGoofyNumber(uint a) public returns (uint) { gc.setGoofyNumber(a); return gc.goofyNumber(); } } */ GasTestsBytecodeString = "" /* 2420-byte string literal not displayed */ GasTestsAbiJsonString = `` /* 1300-byte string literal not displayed */ //derived using remix.ethereum.org AddTwoNumbersGasCost uint64 = 13055 HashMeGasCost uint64 = 13099 DeployAnotherContractGasCost uint64 = 113549 + 92277 SetGoofyNumberGasCost uint64 = 47895 + 26367 /* pragma solidity >=0.4.22 <0.6.0; contract GasRefund { uint stupidNumber; constructor() public { stupidNumber=10000000; } function iWillRevert() public { uint a = 4 + 5; revert("thats enough work for now"); } function iWillFail() public { uint a = 4 - 4; uint b = 6 / a; } function deleteFromStorage() public { stupidNumber = 0; } function die() public { selfdestruct(address(0x0)); } } */ //GasRefundBytecodeString = /* version with self destruct address as longer string */ "608060405234801561001057600080fd5b50629896806000819055506101708061002a6000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806335f469941461005157806360a5f1871461005b57806383bfecfa146100655780639e2ff0741461006f575b600080fd5b610059610079565b005b6100636100a6565b005b61006d6100af565b005b6100776100c7565b005b73ab35ee8df2f8dd950cc1cfd38fef86857374e97173ffffffffffffffffffffffffffffffffffffffff16ff5b60008081905550565b60008090506000816006816100c057fe5b0490505050565b6000600990506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f746861747320656e6f75676820776f726b20666f72206e6f770000000000000081525060200191505060405180910390fdfea265627a7a72315820e6b239ca4c62450752d8bb2877fe37bc15f1cc95afb6f9387df4199c97f6b6c864736f6c634300050c0032" GasRefundBytecodeString = "" /* 782-byte string literal not displayed */ GasRefundAbiJsonString = `` /* 840-byte string literal not displayed */ CtkTransferTestBytecodeString = "" /* 714-byte string literal not displayed */ CtkTransferTestAbiJsonString = `` /* 599-byte string literal not displayed */ )
var ( Addrs = []sdk.AccAddress{ sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()), sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()), sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()), sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()), sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()), } )
Functions ¶
func NewEventSink ¶
func NewGasMeter ¶
func NewQuerier ¶
NewQuerier is the module level router for state queries.
func RegisterGlobalPermissionAcc ¶
RegisterGlobalPermissionAcc registers the zero address as the global permission account.
Types ¶
type Blockchain ¶
type Blockchain struct {
// contains filtered or unexported fields
}
Blockchain implements the blockchain interface from burrow to make state queries.
func NewBlockChain ¶
func NewBlockChain(ctx sdk.Context, k Keeper) *Blockchain
NewBlockChain returns the pointer to a new BlockChain type data.
func (*Blockchain) BlockHash ¶
func (bc *Blockchain) BlockHash(height uint64) ([]byte, error)
BlockHash returns the block's hash at the provided height.
func (*Blockchain) LastBlockHeight ¶
func (bc *Blockchain) LastBlockHeight() uint64
LastBlockHeight returns the last block height of the chain.
func (*Blockchain) LastBlockTime ¶
func (bc *Blockchain) LastBlockTime() time.Time
LastBlockTime return the unix Time type for the last block.
type CertificateCallable ¶
type CertificateCallable struct {
// contains filtered or unexported fields
}
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper implements SDK Keeper.
func NewKeeper ¶
func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, ak types.AccountKeeper, dk types.DistributionKeeper, ck types.CertKeeper, paramSpace types.ParamSubspace) Keeper
NewKeeper creates a new instance of the CVM keeper.
func (Keeper) AuthKeeper ¶
func (k Keeper) AuthKeeper() types.AccountKeeper
AuthKeeper returns keeper's AccountKeeper.
func (*Keeper) Call ¶
func (k *Keeper) Call(ctx sdk.Context, caller, callee sdk.AccAddress, value uint64, data []byte, payloadMeta []*payload.ContractMeta, view bool) ([]byte, error)
Call executes the CVM call from caller to callee with the given data and gas limit.
func (Keeper) GetAllContracts ¶
GetAllContracts gets all contracts for genesis export.
func (Keeper) GetAllMetas ¶
GetAllMetas gets all metadata for genesis export.
func (*Keeper) GetGasRate ¶
GetGasRate returns the gas rate in parameters subspace.
func (Keeper) GetStorage ¶
func (k Keeper) GetStorage(ctx sdk.Context, address crypto.Address, key binary.Word256) ([]byte, error)
GetStorage returns the value stored given the address and key.
func (Keeper) RecycleCoins ¶
RecycleCoins transfers tokens from the zero address to the community pool.
func (Keeper) Send ¶
Send executes the send transaction from caller to callee with the given amount of tokens.
func (Keeper) SetGasRate ¶
SetGasRate sets parameters subspace for gas rate.
func (Keeper) StoreLastBlockHash ¶
StoreLastBlockHash stores the last block hash.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is the CVM state object. It implements acmstate.ReaderWriter.
func (*State) GetAccount ¶
GetAccount gets an account by its address and returns nil if it does not exist (which should not be an error).
func (*State) GetAddressMeta ¶
GetAddressMeta returns the metadata hash of an address
func (*State) GetMetadata ¶
func (s *State) GetMetadata(metahash acmstate.MetadataHash) (string, error)
GetMetadata returns the metadata of the cvm module.
func (*State) GetStorage ¶
GetStorage retrieves a 32-byte value stored at the key for the account at the address and returns Zero256 if the key does not exist or if the address does not exist.
Note: burrow/acm/acmstate.StorageGetter claims that an error should be thrown upon non-existing address. However, when being embedded in acmstate.Cache, which is the case here, we cannot do that because the contract creation code might load from the new contract's storage, while the cache layer caches the account creation action hence the embedded storage getter will not be aware of it. Returning error in this case would fail the contract deployment.
func (*State) RemoveAccount ¶
RemoveAccount removes the account at the address.
func (*State) SetAddressMeta ¶
SetAddressMeta sets the metadata hash for an address
func (*State) SetMetadata ¶
func (s *State) SetMetadata(metahash acmstate.MetadataHash, metadata string) error
SetMetadata sets the metadata of the cvm module.
func (*State) SetStorage ¶
SetStorage stores a 32-byte value at the key for the account at the address. Setting to Zero256 removes the key.
type TestDistrKeeper ¶
func (*TestDistrKeeper) FundCommunityPool ¶
func (tdk *TestDistrKeeper) FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error