thor

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockInterval uint64 = 10 // time interval between two consecutive blocks.

	TxGas                     uint64 = 5000
	ClauseGas                 uint64 = params.TxGas - TxGas
	ClauseGasContractCreation uint64 = params.TxGasContractCreation - TxGas

	MinGasLimit          uint64 = 1000 * 1000
	InitialGasLimit      uint64 = 10 * 1000 * 1000 // InitialGasLimit gas limit value int genesis block.
	GasLimitBoundDivisor uint64 = 1024             // from ethereum
	GetBalanceGas        uint64 = 400              //EIP158 gas table
	SloadGas             uint64 = 200              // EIP158 gas table
	SstoreSetGas         uint64 = params.SstoreSetGas
	SstoreResetGas       uint64 = params.SstoreResetGas

	MaxTxWorkDelay uint32 = 30 // (unit: block) if tx delay exceeds this value, no energy can be exchanged.

	InitialMaxBlockProposers uint64 = 101

	TolerableBlockPackingTime = 500 * time.Millisecond // the indicator to adjust target block gas limit

	MaxStateHistory = 65535 // max guaranteed state history allowed to be accessed in EVM, presented in block number

	SeederInterval     = 8640 // blocks between two seeder epochs.
	CheckpointInterval = 180  // blocks between two bft checkpoints.
)

Constants of block chain.

View Source
const (
	// AddressLength length of address in bytes.
	AddressLength = common.AddressLength
)

Variables

View Source
var (
	KeyExecutorAddress     = BytesToBytes32([]byte("executor"))
	KeyRewardRatio         = BytesToBytes32([]byte("reward-ratio"))
	KeyBaseGasPrice        = BytesToBytes32([]byte("base-gas-price"))
	KeyProposerEndorsement = BytesToBytes32([]byte("proposer-endorsement"))
	KeyMaxBlockProposers   = BytesToBytes32([]byte("max-block-proposers"))

	InitialRewardRatio         = big.NewInt(3e17) // 30%
	InitialBaseGasPrice        = big.NewInt(1e15)
	InitialProposerEndorsement = new(big.Int).Mul(big.NewInt(1e18), big.NewInt(25000000))

	EnergyGrowthRate = big.NewInt(5000000000) // WEI THOR per token(VET) per second. about 0.000432 THOR per token per day.
)

Keys of governance params.

View Source
var NoFork = ForkConfig{
	VIP191:    math.MaxUint32,
	ETH_CONST: math.MaxUint32,
	BLOCKLIST: math.MaxUint32,
	ETH_IST:   math.MaxUint32,
	VIP214:    math.MaxUint32,
	FINALITY:  math.MaxUint32,
}

NoFork a special config without any forks.

Functions

func IsOriginBlocked

func IsOriginBlocked(origin Address) bool

IsOriginBlocked returns true if the address is in the blocklist

func LoadCorrectReceiptsRoots

func LoadCorrectReceiptsRoots() map[string]string

LoadCorrectReceiptsRoots load a map from block ID to correct receipts root.

func MockBlocklist

func MockBlocklist(list []string)

MockBlocklist mock the blocklist

func NewBlake2b

func NewBlake2b() hash.Hash

NewBlake2b return blake2b-256 hash.

Types

type Address

type Address common.Address

Address address of account.

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress converts bytes slice into address. If b is larger than address legnth, b will be cropped (from the left). If b is smaller than address length, b will be extended (from the left).

func CreateContractAddress

func CreateContractAddress(txID Bytes32, clauseIndex uint32, creationCount uint32) Address

CreateContractAddress to generate contract address according to tx id, clause index and contract creation count.

func MustParseAddress

func MustParseAddress(s string) Address

MustParseAddress convert string presented address into Address type, panic on error.

func ParseAddress

func ParseAddress(s string) (Address, error)

ParseAddress convert string presented address into Address type.

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes returns byte slice form of address.

func (Address) IsZero

func (a Address) IsZero() bool

IsZero returns if address is all zero bytes.

func (*Address) MarshalJSON

func (a *Address) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Address) String

func (a Address) String() string

String implements the stringer interface

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Bytes32

type Bytes32 [32]byte

Bytes32 array of 32 bytes.

func Blake2b

func Blake2b(data ...[]byte) Bytes32

Blake2b computes blake2b-256 checksum for given data.

func Blake2bFn

func Blake2bFn(fn func(w io.Writer)) (h Bytes32)

Blake2bFn computes blake2b-256 checksum for the provided writer.

func BytesToBytes32

func BytesToBytes32(b []byte) Bytes32

BytesToBytes32 converts bytes slice into Bytes32. If b is larger than Bytes32 legnth, b will be cropped (from the left). If b is smaller than Bytes32 length, b will be extended (from the left).

func Keccak256

func Keccak256(data ...[]byte) (h Bytes32)

func MustParseBytes32

func MustParseBytes32(s string) Bytes32

MustParseBytes32 convert string presented into Bytes32 type, panic on error.

func ParseBytes32

func ParseBytes32(s string) (Bytes32, error)

ParseBytes32 convert string presented into Bytes32 type

func (Bytes32) AbbrevString

func (b Bytes32) AbbrevString() string

AbbrevString returns abbrev string presentation.

func (Bytes32) Bytes

func (b Bytes32) Bytes() []byte

Bytes returns byte slice form of Bytes32.

func (Bytes32) IsZero

func (b Bytes32) IsZero() bool

IsZero returns if Bytes32 has all zero bytes.

func (*Bytes32) MarshalJSON

func (b *Bytes32) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Bytes32) String

func (b Bytes32) String() string

String implements stringer

func (*Bytes32) UnmarshalJSON

func (b *Bytes32) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type ForkConfig

type ForkConfig struct {
	VIP191    uint32
	ETH_CONST uint32
	BLOCKLIST uint32
	ETH_IST   uint32
	VIP214    uint32
	FINALITY  uint32
}

ForkConfig config for a fork.

func GetForkConfig

func GetForkConfig(genesisID Bytes32) ForkConfig

GetForkConfig get fork config for given genesis ID.

func (ForkConfig) String

func (fc ForkConfig) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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