eth

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: LGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

* Copyright (C) 2021 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.

* Copyright (C) 2021 The poly network Authors * This file is part of The poly network library. * * The poly network is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The poly network is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with The poly network . If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	BaseFeeChangeDenominator = 8          // Bounds the amount the base fee can change between blocks.
	ElasticityMultiplier     = 2          // Bounds the maximum gas limit an EIP-1559 block may have.
	InitialBaseFee           = 1000000000 // Initial base fee for EIP-1559 blocks.
)

Variables

View Source
var (
	BIG_1             = big.NewInt(1)
	BIG_2             = big.NewInt(2)
	BIG_9             = big.NewInt(9)
	BIG_MINUS_99      = big.NewInt(-99)
	BLOCK_DIFF_FACTOR = big.NewInt(2048)
	DIFF_PERIOD       = big.NewInt(100000)
	BOMB_DELAY        = big.NewInt(8999999)
)

Functions

func CalcBaseFee added in v1.6.0

func CalcBaseFee(parent *Header) *big.Int

CalcBaseFee calculates the basefee of the header.

func GetCurrentHeaderHeight

func GetCurrentHeaderHeight(native *native.NativeService, chainID uint64) (uint64, error)

func HashHeader

func HashHeader(header *Header) (hash ethcommon.Hash)

func IsHeaderExist

func IsHeaderExist(native *native.NativeService, hash []byte, chainID uint64) (bool, error)

func RestructChain

func RestructChain(native *native.NativeService, current, new *Header, chainID uint64) error

func VerifyEip1559Header added in v1.6.0

func VerifyEip1559Header(parent, header *Header) error

VerifyEip1559Header verifies some header attributes which were changed in EIP-1559, - gas limit check - basefee check

func VerifyGaslimit added in v1.6.0

func VerifyGaslimit(parentGasLimit, headerGasLimit uint64) error

VerifyGaslimit verifies the header gas limit according increase/decrease in relation to the parent gas limit.

Types

type Caches

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

func NewCaches

func NewCaches(size int, native *native.NativeService) *Caches

type ETHHandler

type ETHHandler struct {
}

func NewETHHandler

func NewETHHandler() *ETHHandler

func (*ETHHandler) SyncBlockHeader

func (this *ETHHandler) SyncBlockHeader(native *native.NativeService) error

func (*ETHHandler) SyncCrossChainMsg

func (this *ETHHandler) SyncCrossChainMsg(native *native.NativeService) error

func (*ETHHandler) SyncGenesisHeader

func (this *ETHHandler) SyncGenesisHeader(native *native.NativeService) error
type Header struct {
	ParentHash  common.Hash      `json:"parentHash"       gencodec:"required"`
	UncleHash   common.Hash      `json:"sha3Uncles"       gencodec:"required"`
	Coinbase    common.Address   `json:"miner"            gencodec:"required"`
	Root        common.Hash      `json:"stateRoot"        gencodec:"required"`
	TxHash      common.Hash      `json:"transactionsRoot" gencodec:"required"`
	ReceiptHash common.Hash      `json:"receiptsRoot"     gencodec:"required"`
	Bloom       types.Bloom      `json:"logsBloom"        gencodec:"required"`
	Difficulty  *big.Int         `json:"difficulty"       gencodec:"required"`
	Number      *big.Int         `json:"number"           gencodec:"required"`
	GasLimit    uint64           `json:"gasLimit"         gencodec:"required"`
	GasUsed     uint64           `json:"gasUsed"          gencodec:"required"`
	Time        uint64           `json:"timestamp"        gencodec:"required"`
	Extra       []byte           `json:"extraData"        gencodec:"required"`
	MixDigest   common.Hash      `json:"mixHash"`
	Nonce       types.BlockNonce `json:"nonce"`

	// BaseFee was added by EIP-1559 and is ignored in legacy headers.
	BaseFee *big.Int `json:"baseFeePerGas" rlp:"optional"`
}

func GetCurrentHeader

func GetCurrentHeader(native *native.NativeService, chainID uint64) (*Header, *big.Int, error)

func GetHeaderByHash

func GetHeaderByHash(native *native.NativeService, hash []byte, chainID uint64) (*Header, *big.Int, error)

func GetHeaderByHeight

func GetHeaderByHeight(native *native.NativeService, height, chainID uint64) (*Header, *big.Int, error)

func To1559 added in v1.6.0

func To1559(h *types.Header) *Header

func (*Header) Hash added in v1.6.0

func (h *Header) Hash() common.Hash

func (Header) MarshalJSON added in v1.6.0

func (h Header) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Header) UnmarshalJSON added in v1.6.0

func (h *Header) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type HeaderWithDifficultySum

type HeaderWithDifficultySum struct {
	Header        Header   `json:"header"`
	DifficultySum *big.Int `json:"difficultySum"`
}

type KeccakState added in v1.6.0

type KeccakState interface {
	hash.Hash
	Read([]byte) (int, error)
}

KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.

Directories

Path Synopsis
Package rlp implements the RLP serialization format.
Package rlp implements the RLP serialization format.

Jump to

Keyboard shortcuts

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