Documentation ¶
Index ¶
- Variables
- func DeserializeBlockStoresPb(buf []byte) (*iotextypes.BlockStores, error)
- func DeserializeSystemLogPb(buf []byte) (*iotextypes.TransactionLogs, error)
- func GenesisHash() hash.Hash256
- func LoadGenesisHash(g *genesis.Genesis)
- type BlkTransactionLog
- type Block
- func (b *Block) ActionByHash(h hash.Hash256) (*action.SealedEnvelope, uint32, error)
- func (b *Block) ConvertToBlockPb() *iotextypes.Block
- func (b *Block) Finalize(endorsements []*endorsement.Endorsement, ts time.Time) error
- func (b *Block) HasBlob() bool
- func (b *Block) ProtoWithoutSidecar() *iotextypes.Block
- func (b *Block) RunnableActions() RunnableActions
- func (b *Block) Serialize() ([]byte, error)
- func (b *Block) TransactionLog() *BlkTransactionLog
- func (b *Block) VerifyTxRoot() error
- func (b *Block) WithBlobSidecars(sidecars []*types.BlobTxSidecar, txhash []string, deser *action.Deserializer) (*Block, error)
- type Body
- type Builder
- func (b *Builder) GetCurrentBlockHeader() Header
- func (b *Builder) SetBaseFee(fee *big.Int) *Builder
- func (b *Builder) SetBlobGasUsed(g uint64) *Builder
- func (b *Builder) SetDeltaStateDigest(h hash.Hash256) *Builder
- func (b *Builder) SetExcessBlobGas(g uint64) *Builder
- func (b *Builder) SetGasUsed(g uint64) *Builder
- func (b *Builder) SetHeight(h uint64) *Builder
- func (b *Builder) SetLogsBloom(f bloom.BloomFilter) *Builder
- func (b *Builder) SetPrevBlockHash(h hash.Hash256) *Builder
- func (b *Builder) SetReceiptRoot(h hash.Hash256) *Builder
- func (b *Builder) SetReceipts(receipts []*action.Receipt) *Builder
- func (b *Builder) SetTimestamp(ts time.Time) *Builder
- func (b *Builder) SetVersion(v uint32) *Builder
- func (b *Builder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
- type Deserializer
- func (bd *Deserializer) BlockFromBlockStoreProto(pb *iotextypes.BlockStore) (*Block, error)
- func (bd *Deserializer) DeserializeBlock(buf []byte) (*Block, error)
- func (bd *Deserializer) DeserializeBlockStore(buf []byte) (*Store, error)
- func (bd *Deserializer) DeserializeBody(buf []byte) (*Body, error)
- func (bd *Deserializer) EvmNetworkID() uint32
- func (bd *Deserializer) FromBlockProto(pbBlock *iotextypes.Block) (*Block, error)
- func (bd *Deserializer) ReceiptsFromBlockStoreProto(pb *iotextypes.BlockStore) ([]*action.Receipt, error)
- func (bd *Deserializer) SetEvmNetworkID(id uint32) *Deserializer
- type Footer
- func (f *Footer) CommitTime() time.Time
- func (f *Footer) ConvertFromBlockFooterPb(pb *iotextypes.BlockFooter) error
- func (f *Footer) ConvertToBlockFooterPb() (*iotextypes.BlockFooter, error)
- func (f *Footer) Deserialize(buf []byte) error
- func (f *Footer) Endorsements() []*endorsement.Endorsement
- func (f *Footer) Serialize() ([]byte, error)
- type Header
- func (h *Header) BaseFee() *big.Int
- func (h *Header) BlobGasUsed() uint64
- func (h *Header) BlockHeaderCoreProto() *iotextypes.BlockHeaderCore
- func (h *Header) DeltaStateDigest() hash.Hash256
- func (h *Header) Deserialize(buf []byte) error
- func (h *Header) ExcessBlobGas() uint64
- func (h *Header) GasUsed() uint64
- func (h *Header) HashBlock() hash.Hash256
- func (h *Header) HashHeader() hash.Hash256
- func (h *Header) HashHeaderCore() hash.Hash256
- func (h *Header) HeaderLogger(l *zap.Logger) *zap.Logger
- func (h *Header) Height() uint64
- func (h *Header) LoadFromBlockHeaderProto(pb *iotextypes.BlockHeader) error
- func (h *Header) LogsBloomfilter() bloom.BloomFilter
- func (h *Header) PrevHash() hash.Hash256
- func (h *Header) ProducerAddress() string
- func (h *Header) Proto() *iotextypes.BlockHeader
- func (h *Header) PublicKey() crypto.PublicKey
- func (h *Header) ReceiptRoot() hash.Hash256
- func (h *Header) Serialize() ([]byte, error)
- func (h *Header) SerializeCore() []byte
- func (h *Header) Timestamp() time.Time
- func (h *Header) TxRoot() hash.Hash256
- func (h *Header) VerifyDeltaStateDigest(digest hash.Hash256) bool
- func (h *Header) VerifyReceiptRoot(root hash.Hash256) bool
- func (h *Header) VerifySignature() bool
- func (h *Header) VerifyTransactionRoot(root hash.Hash256) bool
- func (h *Header) Version() uint32
- type RunnableActions
- type RunnableActionsBuilder
- type Store
- type TestingBuilder
- func (b *TestingBuilder) AddActions(acts ...*action.SealedEnvelope) *TestingBuilder
- func (b *TestingBuilder) SetHeight(h uint64) *TestingBuilder
- func (b *TestingBuilder) SetPrevBlockHash(h hash.Hash256) *TestingBuilder
- func (b *TestingBuilder) SetReceipts(receipts []*action.Receipt) *TestingBuilder
- func (b *TestingBuilder) SetTimeStamp(ts time.Time) *TestingBuilder
- func (b *TestingBuilder) SetVersion(v uint32) *TestingBuilder
- func (b *TestingBuilder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
- type TokenTxRecord
- type TransactionLog
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( ErrTxRootMismatch = errors.New("transaction merkle root does not match") ErrDeltaStateMismatch = errors.New("delta state digest doesn't match") ErrReceiptRootMismatch = errors.New("receipt root hash does not match") )
Errors
Functions ¶
func DeserializeBlockStoresPb ¶
func DeserializeBlockStoresPb(buf []byte) (*iotextypes.BlockStores, error)
DeserializeBlockStoresPb decode byte stream into BlockStores pb message
func DeserializeSystemLogPb ¶
func DeserializeSystemLogPb(buf []byte) (*iotextypes.TransactionLogs, error)
DeserializeSystemLogPb parse the byte stream into TransactionLogs Pb message
func LoadGenesisHash ¶
LoadGenesisHash is done once to compute and save the genesis'es hash
Types ¶
type BlkTransactionLog ¶
type BlkTransactionLog struct {
// contains filtered or unexported fields
}
BlkTransactionLog is transaction log in one block
func (*BlkTransactionLog) Serialize ¶
func (log *BlkTransactionLog) Serialize() []byte
Serialize returns a serialized byte stream for BlkTransactionLog
type Block ¶
type Block struct { Header Body // TODO: move receipts out of block struct Receipts []*action.Receipt }
Block defines the struct of block
func CreateTestBlockWithBlob ¶
func NewBlockDeprecated ¶
func NewBlockDeprecated( chainID uint32, height uint64, prevBlockHash hash.Hash256, timestamp time.Time, producer crypto.PublicKey, actions []*action.SealedEnvelope, ) *Block
NewBlockDeprecated returns a new block This method is deprecated. Only used in old tests.
func (*Block) ActionByHash ¶
ActionByHash returns the action of a given hash
func (*Block) ConvertToBlockPb ¶
func (b *Block) ConvertToBlockPb() *iotextypes.Block
ConvertToBlockPb converts Block to Block
func (*Block) Finalize ¶
func (b *Block) Finalize(endorsements []*endorsement.Endorsement, ts time.Time) error
Finalize creates a footer for the block
func (*Block) ProtoWithoutSidecar ¶
func (b *Block) ProtoWithoutSidecar() *iotextypes.Block
ProtoWithoutSidecar returns the protobuf without sidecar
func (*Block) RunnableActions ¶
func (b *Block) RunnableActions() RunnableActions
RunnableActions abstructs RunnableActions from a Block.
func (*Block) TransactionLog ¶
func (b *Block) TransactionLog() *BlkTransactionLog
TransactionLog returns transaction logs in the block
func (*Block) VerifyTxRoot ¶
VerifyTxRoot verifies the transaction root hash
func (*Block) WithBlobSidecars ¶
func (b *Block) WithBlobSidecars(sidecars []*types.BlobTxSidecar, txhash []string, deser *action.Deserializer) (*Block, error)
type Body ¶
type Body struct {
Actions []*action.SealedEnvelope
}
Body defines the struct of body
func (*Body) CalculateTransferAmount ¶
CalculateTransferAmount returns the calculated transfer amount in this block.
func (*Body) CalculateTxRoot ¶
CalculateTxRoot returns the Merkle root of all txs and actions in this block.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to construct Block.
func (*Builder) GetCurrentBlockHeader ¶
GetCurrentBlockHeader returns the current hash of Block Header Core
func (*Builder) SetBaseFee ¶
SetBaseFee sets the base fee
func (*Builder) SetBlobGasUsed ¶
SetBlobGasUsed sets the blob gas used
func (*Builder) SetDeltaStateDigest ¶
SetDeltaStateDigest sets the new delta state digest after running actions included in this building block
func (*Builder) SetExcessBlobGas ¶
SetExcessBlobGas sets the excess blob gas
func (*Builder) SetGasUsed ¶
SetGasUsed sets the used gas
func (*Builder) SetLogsBloom ¶
func (b *Builder) SetLogsBloom(f bloom.BloomFilter) *Builder
SetLogsBloom sets the logs bloom filter value after running actions included in this building block.
func (*Builder) SetPrevBlockHash ¶
SetPrevBlockHash sets the previous block hash for block which is building.
func (*Builder) SetReceiptRoot ¶
SetReceiptRoot sets the receipt root after running actions included in this building block.
func (*Builder) SetReceipts ¶
SetReceipts sets the receipts after running actions included in this building block.
func (*Builder) SetTimestamp ¶
SetTimestamp sets the block timestamp
func (*Builder) SetVersion ¶
SetVersion sets the protocol version for block which is building.
func (*Builder) SignAndBuild ¶
func (b *Builder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
SignAndBuild signs and then builds a block.
type Deserializer ¶
type Deserializer struct {
// contains filtered or unexported fields
}
Deserializer de-serializes a block
It's a wrapper to set certain parameters in order to correctly de-serialize a block Currently the parameter is EVM network ID for tx in web3 format, it is called like
blk, err := (&Deserializer{}).SetEvmNetworkID(id).FromBlockProto(pbBlock) blk, err := (&Deserializer{}).SetEvmNetworkID(id).DeserializeBlock(buf)
func NewDeserializer ¶
func NewDeserializer(evmNetworkID uint32) *Deserializer
NewDeserializer creates a new deserializer
func (*Deserializer) BlockFromBlockStoreProto ¶
func (bd *Deserializer) BlockFromBlockStoreProto(pb *iotextypes.BlockStore) (*Block, error)
func (*Deserializer) DeserializeBlock ¶
func (bd *Deserializer) DeserializeBlock(buf []byte) (*Block, error)
DeserializeBlock de-serializes a block
func (*Deserializer) DeserializeBlockStore ¶
func (bd *Deserializer) DeserializeBlockStore(buf []byte) (*Store, error)
DeserializeBlockStore de-serializes a block store
func (*Deserializer) DeserializeBody ¶
func (bd *Deserializer) DeserializeBody(buf []byte) (*Body, error)
DeserializeBody de-serializes a block body
func (*Deserializer) EvmNetworkID ¶
func (bd *Deserializer) EvmNetworkID() uint32
EvmNetworkID get evm network ID
func (*Deserializer) FromBlockProto ¶
func (bd *Deserializer) FromBlockProto(pbBlock *iotextypes.Block) (*Block, error)
FromBlockProto converts protobuf to block
func (*Deserializer) ReceiptsFromBlockStoreProto ¶
func (bd *Deserializer) ReceiptsFromBlockStoreProto(pb *iotextypes.BlockStore) ([]*action.Receipt, error)
func (*Deserializer) SetEvmNetworkID ¶
func (bd *Deserializer) SetEvmNetworkID(id uint32) *Deserializer
SetEvmNetworkID sets the evm network ID for web3 actions
type Footer ¶
type Footer struct {
// contains filtered or unexported fields
}
Footer defines a set of proof of this block
func (*Footer) CommitTime ¶
CommitTime returns the timestamp the block was committed
func (*Footer) ConvertFromBlockFooterPb ¶
func (f *Footer) ConvertFromBlockFooterPb(pb *iotextypes.BlockFooter) error
ConvertFromBlockFooterPb converts BlockFooter to BlockFooter
func (*Footer) ConvertToBlockFooterPb ¶
func (f *Footer) ConvertToBlockFooterPb() (*iotextypes.BlockFooter, error)
ConvertToBlockFooterPb converts BlockFooter
func (*Footer) Deserialize ¶
Deserialize loads from the serialized byte stream
func (*Footer) Endorsements ¶
func (f *Footer) Endorsements() []*endorsement.Endorsement
Endorsements returns the number of commit endorsements froms delegates
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header defines the struct of block header make sure the variable type and order of this struct is same as "BlockHeaderPb" in blockchain.pb.go
func (*Header) BlobGasUsed ¶
BlobGasUsed returns the blob gas used in this block
func (*Header) BlockHeaderCoreProto ¶
func (h *Header) BlockHeaderCoreProto() *iotextypes.BlockHeaderCore
BlockHeaderCoreProto returns BlockHeaderCore proto.
func (*Header) DeltaStateDigest ¶
DeltaStateDigest returns the delta sate digest after applying this block.
func (*Header) Deserialize ¶
Deserialize loads from the serialized byte stream
func (*Header) ExcessBlobGas ¶
ExcessBlobGas returns the excess blob gas in this block
func (*Header) HashHeaderCore ¶
HashHeaderCore hahes the header core.
func (*Header) HeaderLogger ¶
HeaderLogger returns a new logger with block header fields' value.
func (*Header) LoadFromBlockHeaderProto ¶
func (h *Header) LoadFromBlockHeaderProto(pb *iotextypes.BlockHeader) error
LoadFromBlockHeaderProto loads from protobuf
func (*Header) LogsBloomfilter ¶
func (h *Header) LogsBloomfilter() bloom.BloomFilter
LogsBloomfilter return the bloom filter for all contract log events
func (*Header) ProducerAddress ¶
ProducerAddress returns the address of producer
func (*Header) Proto ¶
func (h *Header) Proto() *iotextypes.BlockHeader
Proto returns BlockHeader proto.
func (*Header) ReceiptRoot ¶
ReceiptRoot returns the receipt root after apply this block
func (*Header) SerializeCore ¶
SerializeCore returns byte stream for header core.
func (*Header) VerifyDeltaStateDigest ¶
VerifyDeltaStateDigest verifies the delta state digest in header
func (*Header) VerifyReceiptRoot ¶
VerifyReceiptRoot verifies the receipt root in header
func (*Header) VerifySignature ¶
VerifySignature verifies the signature saved in block header
func (*Header) VerifyTransactionRoot ¶
VerifyTransactionRoot verifies the delta state digest in header
type RunnableActions ¶
type RunnableActions struct {
// contains filtered or unexported fields
}
RunnableActions is abstructed from block which contains information to execute all actions in a block.
func (RunnableActions) Actions ¶
func (ra RunnableActions) Actions() []*action.SealedEnvelope
Actions returns Actions.
func (RunnableActions) TxHash ¶
func (ra RunnableActions) TxHash() hash.Hash256
TxHash returns TxHash.
type RunnableActionsBuilder ¶
type RunnableActionsBuilder struct {
// contains filtered or unexported fields
}
RunnableActionsBuilder is used to construct RunnableActions.
func NewRunnableActionsBuilder ¶
func NewRunnableActionsBuilder() *RunnableActionsBuilder
NewRunnableActionsBuilder creates a RunnableActionsBuilder.
func (*RunnableActionsBuilder) AddActions ¶
func (b *RunnableActionsBuilder) AddActions(acts ...*action.SealedEnvelope) *RunnableActionsBuilder
AddActions adds actions for block which is building.
func (*RunnableActionsBuilder) Build ¶
func (b *RunnableActionsBuilder) Build() RunnableActions
Build signs and then builds a block.
type Store ¶
Store defines block storage schema
func (*Store) ToProto ¶
func (in *Store) ToProto() *iotextypes.BlockStore
ToProto converts to proto message
func (*Store) ToProtoWithoutSidecar ¶
func (in *Store) ToProtoWithoutSidecar() *iotextypes.BlockStore
ToProto converts to proto message
type TestingBuilder ¶
type TestingBuilder struct {
// contains filtered or unexported fields
}
TestingBuilder is used to construct Block.
func NewTestingBuilder ¶
func NewTestingBuilder() *TestingBuilder
NewTestingBuilder creates a Builder.
func (*TestingBuilder) AddActions ¶
func (b *TestingBuilder) AddActions(acts ...*action.SealedEnvelope) *TestingBuilder
AddActions adds actions for block which is building.
func (*TestingBuilder) SetHeight ¶
func (b *TestingBuilder) SetHeight(h uint64) *TestingBuilder
SetHeight sets the block height for block which is building.
func (*TestingBuilder) SetPrevBlockHash ¶
func (b *TestingBuilder) SetPrevBlockHash(h hash.Hash256) *TestingBuilder
SetPrevBlockHash sets the previous block hash for block which is building.
func (*TestingBuilder) SetReceipts ¶
func (b *TestingBuilder) SetReceipts(receipts []*action.Receipt) *TestingBuilder
SetReceipts sets the receipts after running actions included in this building block.
func (*TestingBuilder) SetTimeStamp ¶
func (b *TestingBuilder) SetTimeStamp(ts time.Time) *TestingBuilder
SetTimeStamp sets the time stamp for block which is building.
func (*TestingBuilder) SetVersion ¶
func (b *TestingBuilder) SetVersion(v uint32) *TestingBuilder
SetVersion sets the protocol version for block which is building.
func (*TestingBuilder) SignAndBuild ¶
func (b *TestingBuilder) SignAndBuild(signerPrvKey crypto.PrivateKey) (Block, error)
SignAndBuild signs and then builds a block.
type TokenTxRecord ¶
type TokenTxRecord struct {
// contains filtered or unexported fields
}
TokenTxRecord is a token transaction record
func LogTokenTxRecord ¶
func LogTokenTxRecord(l *action.TransactionLog) *TokenTxRecord
LogTokenTxRecord generates token transaction record from log
func NewTokenTxRecord ¶
func NewTokenTxRecord(typ iotextypes.TransactionLogType, amount, sender, recipient string) *TokenTxRecord
NewTokenTxRecord creates a new TokenTxRecord
type TransactionLog ¶
type TransactionLog struct {
// contains filtered or unexported fields
}
TransactionLog is transaction log in one action
func NewTransactionLog ¶
func NewTransactionLog(actHash hash.Hash256, records []*TokenTxRecord) *TransactionLog
NewTransactionLog creates a new TransactionLog
func ReceiptTransactionLog ¶
func ReceiptTransactionLog(r *action.Receipt) *TransactionLog
ReceiptTransactionLog generates transaction log from receipt
func (*TransactionLog) Proto ¶
func (log *TransactionLog) Proto() *iotextypes.TransactionLog
Proto returns the pb message
type Validator ¶
type Validator interface { // Validate validates the given block's content Validate(ctx context.Context, block *Block) error }
Validator is the interface of validator
func NewValidator ¶
func NewValidator(subsequenceValidator Validator, validators ...action.SealedEnvelopeValidator) Validator
NewValidator creates a validator with a set of sealed envelope validators