Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultAggregatorNodeSignatureBytesProvider(header *Header) ([]byte, error)
- func DefaultSyncNodeSignatureBytesProvider(_ context.Context, header *Header, _ *Data) ([]byte, error)
- func GenerateRandomBlockCustom(config *BlockConfig, chainID string) (*SignedHeader, *Data, crypto.PrivKey)
- func GenerateRandomBlockCustomWithAppHash(config *BlockConfig, chainID string, appHash []byte) (*SignedHeader, *Data, crypto.PrivKey)
- func GetGenesisWithPrivkey(chainID string) (genesis.Genesis, crypto.PrivKey, crypto.PubKey)
- func GetRandomBlock(height uint64, nTxs int, chainID string) (*SignedHeader, *Data)
- func GetRandomBytes(n uint) []byte
- func KeyAddress(pubKey crypto.PubKey) []byte
- func RetrieveWithHelpers(ctx context.Context, da coreda.DA, logger zerolog.Logger, ...) coreda.ResultRetrieve
- func SubmitWithHelpers(ctx context.Context, da coreda.DA, logger zerolog.Logger, data [][]byte, ...) coreda.ResultSubmit
- func Validate(header *SignedHeader, data *Data) error
- type AggregatorNodeSignatureBytesProvider
- type BaseHeader
- type BlockConfig
- type Data
- func (d *Data) ChainID() string
- func (d *Data) DACommitment() Hash
- func (d *Data) FromProto(other *pb.Data) error
- func (d *Data) Hash() Hash
- func (d *Data) Height() uint64
- func (d *Data) IsZero() bool
- func (d *Data) LastHeader() Hash
- func (d *Data) MarshalBinary() ([]byte, error)
- func (d *Data) New() *Data
- func (d *Data) Size() int
- func (d *Data) Time() time.Time
- func (d *Data) ToProto() *pb.Data
- func (d *Data) UnmarshalBinary(data []byte) error
- func (d *Data) Validate() error
- func (d *Data) Verify(untrustedData *Data) error
- type Hash
- type Header
- func (h *Header) ChainID() string
- func (h *Header) FromProto(other *pb.Header) error
- func (h *Header) Hash() Hash
- func (h *Header) Height() uint64
- func (h *Header) IsZero() bool
- func (h *Header) LastHeader() Hash
- func (h *Header) MarshalBinary() ([]byte, error)
- func (h *Header) New() *Header
- func (h *Header) Time() time.Time
- func (h *Header) ToProto() *pb.Header
- func (h *Header) UnmarshalBinary(data []byte) error
- func (h *Header) Validate() error
- func (h *Header) ValidateBasic() error
- func (h *Header) Verify(untrstH *Header) error
- type HeaderConfig
- type Metadata
- type Signature
- type SignedData
- type SignedHeader
- func GetFirstSignedHeader(signer signer.Signer, chainID string) (*SignedHeader, error)
- func GetRandomNextSignedHeader(signedHeader *SignedHeader, signer signer.Signer, chainID string) (*SignedHeader, error)
- func GetRandomSignedHeader(chainID string) (*SignedHeader, crypto.PrivKey, error)
- func GetRandomSignedHeaderCustom(config *HeaderConfig, chainID string) (*SignedHeader, error)
- func (sh *SignedHeader) FromProto(other *pb.SignedHeader) error
- func (sh *SignedHeader) IsZero() bool
- func (sh *SignedHeader) MarshalBinary() ([]byte, error)
- func (sh *SignedHeader) New() *SignedHeader
- func (sh *SignedHeader) SetCustomVerifierForAggregator(provider AggregatorNodeSignatureBytesProvider)
- func (sh *SignedHeader) SetCustomVerifierForSyncNode(provider SyncNodeSignatureBytesProvider)
- func (sh *SignedHeader) ToProto() (*pb.SignedHeader, error)
- func (sh *SignedHeader) UnmarshalBinary(data []byte) error
- func (sh *SignedHeader) ValidateBasic() error
- func (sh *SignedHeader) ValidateBasicWithData(data *Data) error
- func (sh *SignedHeader) Verify(untrstH *SignedHeader) error
- type Signer
- type State
- type SyncNodeSignatureBytesProvider
- type Tx
- type Txs
- type ValidatorHasherProvider
- type Version
Constants ¶
const DefaultSigningKeyType = "ed25519"
DefaultSigningKeyType is the key type used by the sequencer signing key
Variables ¶
var ( // ErrNoProposerAddress is returned when the proposer address is not set. ErrNoProposerAddress = errors.New("no proposer address") // ErrProposerVerificationFailed is returned when the proposer verification fails. ErrProposerVerificationFailed = errors.New("proposer verification failed") )
var ( // ErrLastHeaderHashMismatch is returned when the last header hash doesn't match. ErrLastHeaderHashMismatch = errors.New("last header hash mismatch") // ErrLastCommitHashMismatch is returned when the last commit hash doesn't match. ErrLastCommitHashMismatch = errors.New("last commit hash mismatch") )
var ( // ErrAggregatorSetHashMismatch is returned when the aggregator set hash // in the signed header doesn't match the hash of the validator set. ErrAggregatorSetHashMismatch = errors.New("aggregator set hash in signed header and hash of validator set do not match") // ErrSignatureVerificationFailed is returned when the signature // verification fails ErrSignatureVerificationFailed = errors.New("signature verification failed") // ErrProposerAddressMismatch is returned when the proposer address in the signed header does not match the proposer address in the validator set ErrProposerAddressMismatch = errors.New("proposer address in SignedHeader does not match the proposer address in the validator set") // ErrSignatureEmpty is returned when signature is empty ErrSignatureEmpty = errors.New("signature is empty") )
var HeaderContextKey = headerContextKey{}
HeaderContextKey is used to store the header in the context. This is useful if the execution client needs to access the header during transaction execution.
var InitStateVersion = Version{
Block: 11,
App: 0,
}
InitStateVersion sets the Consensus.Block and Software versions, but leaves the Consensus.App version blank. The Consensus.App version will be set during the Handshake, once we hear from the app what protocol version it is running.
Functions ¶
func DefaultAggregatorNodeSignatureBytesProvider ¶
DefaultAggregatorNodeSignatureBytesProvider is the default implementation of AggregatorNodeSignatureBytesProvider.
func DefaultSyncNodeSignatureBytesProvider ¶
func DefaultSyncNodeSignatureBytesProvider(_ context.Context, header *Header, _ *Data) ([]byte, error)
DefaultSyncNodeSignatureBytesProvider is the default implementation of SyncNodeSignatureBytesProvider.
func GenerateRandomBlockCustom ¶
func GenerateRandomBlockCustom(config *BlockConfig, chainID string) (*SignedHeader, *Data, crypto.PrivKey)
GenerateRandomBlockCustom returns a block with random data and the given height, transactions, privateKey and proposer address.
func GenerateRandomBlockCustomWithAppHash ¶
func GenerateRandomBlockCustomWithAppHash(config *BlockConfig, chainID string, appHash []byte) (*SignedHeader, *Data, crypto.PrivKey)
GenerateRandomBlockCustomWithAppHash returns a block with random data and the given height, transactions, privateKey, proposer address, and custom appHash.
func GetGenesisWithPrivkey ¶
GetGenesisWithPrivkey returns a genesis state and a private key
func GetRandomBlock ¶
func GetRandomBlock(height uint64, nTxs int, chainID string) (*SignedHeader, *Data)
GetRandomBlock creates a block with a given height and number of transactions, intended for testing. It's tailored for simplicity, primarily used in test setups where additional outputs are not needed.
func GetRandomBytes ¶
GetRandomBytes returns a byte slice of random bytes of length n. It uses crypto/rand for cryptographically secure random number generation.
func KeyAddress ¶
func RetrieveWithHelpers ¶
func RetrieveWithHelpers( ctx context.Context, da coreda.DA, logger zerolog.Logger, dataLayerHeight uint64, namespace []byte, requestTimeout time.Duration, ) coreda.ResultRetrieve
RetrieveWithHelpers performs blob retrieval using the underlying DA layer, handling error mapping to produce a ResultRetrieve. It mimics the logic previously found in da.DAClient.Retrieve. requestTimeout defines the timeout for the each retrieval request.
func SubmitWithHelpers ¶
func SubmitWithHelpers( ctx context.Context, da coreda.DA, logger zerolog.Logger, data [][]byte, gasPrice float64, namespace []byte, options []byte, ) coreda.ResultSubmit
SubmitWithHelpers performs blob submission using the underlying DA layer, handling error mapping to produce a ResultSubmit. It assumes blob size filtering is handled within the DA implementation's Submit. It mimics the logic previously found in da.DAClient.Submit.
func Validate ¶
func Validate(header *SignedHeader, data *Data) error
Validate performs validation of data with respect to its header
Types ¶
type AggregatorNodeSignatureBytesProvider ¶
AggregatorNodeSignatureBytesProvider defines the function type for providing a signature payload to sign.
type BaseHeader ¶
type BaseHeader struct {
// Height represents the block height (aka block number) of a given header
Height uint64
// Time contains Unix nanotime of a block
Time uint64
// The Chain ID
ChainID string
}
BaseHeader contains the most basic data of a header
type BlockConfig ¶
type BlockConfig struct {
Height uint64
NTxs int
PrivKey crypto.PrivKey // Input and Output option
ProposerAddr []byte // Input option
}
BlockConfig carries all necessary state for block generation
type Data ¶
Data defines Evolve block data.
func (*Data) DACommitment ¶
DACommitment returns the DA commitment of the Data excluding the Metadata
func (*Data) LastHeader ¶
LastHeader returns last header hash of the block.
func (*Data) MarshalBinary ¶
MarshalBinary encodes Data into binary form and returns it.
func (*Data) UnmarshalBinary ¶
UnmarshalBinary decodes binary form of Data into object.
type Hash ¶
type Hash = header.Hash
Hash is a 32-byte array which is used to represent a hash result.
type Header ¶
type Header struct {
BaseHeader
// Block and App version
Version Version
// prev block info
LastHeaderHash Hash
// hashes of block data
LastCommitHash Hash // commit from aggregator(s) from the last block
DataHash Hash // Block.Data root aka Transactions
ConsensusHash Hash // consensus params for current block
AppHash Hash // state after applying txs from the current block
// Root hash of all results from the txs from the previous block.
// This is ABCI specific but smart-contract chains require some way of committing
// to transaction receipts/results.
LastResultsHash Hash
// compatibility with tendermint light client
ValidatorHash Hash
// Note that the address can be derived from the pubkey which can be derived
// from the signature when using secp256k.
// We keep this in case users choose another signature format where the
// pubkey can't be recovered by the signature (e.g. ed25519).
ProposerAddress []byte // original proposer of the block
}
Header defines the structure of Evolve block header.
func GetRandomHeader ¶
GetRandomHeader returns a header with random fields and current time
func GetRandomNextHeader ¶
GetRandomNextHeader returns a header with random data and height of +1 from the provided Header
func (*Header) LastHeader ¶
LastHeader returns last header hash of the header.
func (*Header) MarshalBinary ¶
MarshalBinary encodes Header into binary form and returns it.
func (*Header) UnmarshalBinary ¶
UnmarshalBinary decodes binary form of Header into object.
func (*Header) ValidateBasic ¶
ValidateBasic performs basic validation of a header.
type HeaderConfig ¶
type HeaderConfig struct {
Height uint64
DataHash header.Hash
AppHash header.Hash
Signer signer.Signer
}
HeaderConfig carries all necessary state for header generation
type Metadata ¶
Metadata defines metadata for Data struct to help with p2p gossiping.
func (*Metadata) MarshalBinary ¶
MarshalBinary encodes Metadata into binary form and returns it.
func (*Metadata) UnmarshalBinary ¶
UnmarshalBinary decodes binary form of Metadata into object.
type Signature ¶
type Signature []byte
Signature represents signature of block creator.
func GetSignature ¶
GetSignature returns a signature from the given private key over the given header
func (*Signature) ValidateBasic ¶
ValidateBasic performs basic validation of a signature.
type SignedData ¶
SignedData combines Data and its signature.
func (*SignedData) FromProto ¶
func (sd *SignedData) FromProto(other *pb.SignedData) error
FromProto fills SignedData with data from protobuf representation.
func (*SignedData) MarshalBinary ¶
func (sd *SignedData) MarshalBinary() ([]byte, error)
MarshalBinary encodes SignedData into binary form and returns it.
func (*SignedData) ToProto ¶
func (sd *SignedData) ToProto() (*pb.SignedData, error)
ToProto converts SignedData into protobuf representation and returns it.
func (*SignedData) UnmarshalBinary ¶
func (sd *SignedData) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes binary form of SignedData into object.
type SignedHeader ¶
type SignedHeader struct {
Header
// Note: This is backwards compatible as ABCI exported types are not affected.
Signature Signature
Signer Signer
// contains filtered or unexported fields
}
SignedHeader combines Header and its signature.
Used mostly for gossiping.
func GetFirstSignedHeader ¶
func GetFirstSignedHeader(signer signer.Signer, chainID string) (*SignedHeader, error)
GetFirstSignedHeader creates a 1st signed header for a chain, given a valset and signing key.
func GetRandomNextSignedHeader ¶
func GetRandomNextSignedHeader(signedHeader *SignedHeader, signer signer.Signer, chainID string) (*SignedHeader, error)
GetRandomNextSignedHeader returns a signed header with random data and height of +1 from the provided signed header
func GetRandomSignedHeader ¶
func GetRandomSignedHeader(chainID string) (*SignedHeader, crypto.PrivKey, error)
GetRandomSignedHeader generates a signed header with random data and returns it.
func GetRandomSignedHeaderCustom ¶
func GetRandomSignedHeaderCustom(config *HeaderConfig, chainID string) (*SignedHeader, error)
GetRandomSignedHeaderCustom creates a signed header based on the provided HeaderConfig.
func (*SignedHeader) FromProto ¶
func (sh *SignedHeader) FromProto(other *pb.SignedHeader) error
FromProto fills SignedHeader with data from protobuf representation. The contained Signer can only be used to verify signatures, not to sign messages.
func (*SignedHeader) IsZero ¶
func (sh *SignedHeader) IsZero() bool
IsZero returns true if the SignedHeader is nil
func (*SignedHeader) MarshalBinary ¶
func (sh *SignedHeader) MarshalBinary() ([]byte, error)
MarshalBinary encodes SignedHeader into binary form and returns it.
func (*SignedHeader) New ¶
func (sh *SignedHeader) New() *SignedHeader
New creates a new SignedHeader.
func (*SignedHeader) SetCustomVerifierForAggregator ¶
func (sh *SignedHeader) SetCustomVerifierForAggregator(provider AggregatorNodeSignatureBytesProvider)
SetCustomVerifierForAggregator sets a custom signature provider for the SignedHeader. If set, ValidateBasic will use this function to verify the signature.
func (*SignedHeader) SetCustomVerifierForSyncNode ¶
func (sh *SignedHeader) SetCustomVerifierForSyncNode(provider SyncNodeSignatureBytesProvider)
SetCustomVerifierForSyncNode sets a custom signature provider for the SignedHeader. If set, ValidateBasic will use this function to verify the signature.
func (*SignedHeader) ToProto ¶
func (sh *SignedHeader) ToProto() (*pb.SignedHeader, error)
ToProto converts SignedHeader into protobuf representation and returns it.
func (*SignedHeader) UnmarshalBinary ¶
func (sh *SignedHeader) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes binary form of SignedHeader into object.
func (*SignedHeader) ValidateBasic ¶
func (sh *SignedHeader) ValidateBasic() error
Validate performs basic validation of a signed header for the aggregator node.
func (*SignedHeader) ValidateBasicWithData ¶
func (sh *SignedHeader) ValidateBasicWithData(data *Data) error
ValidateBasicWithData performs basic validator of a signed header, granted data for syncing node.
func (*SignedHeader) Verify ¶
func (sh *SignedHeader) Verify(untrstH *SignedHeader) error
Verify verifies the signed header.
type Signer ¶
Signer is a type that can verify messages.
type State ¶
type State struct {
Version Version
// immutable
ChainID string
InitialHeight uint64
// LastBlockHeight=0 at genesis (ie. block(H=0) does not exist)
LastBlockHeight uint64
LastBlockTime time.Time
// DAHeight identifies DA block containing the latest applied Evolve block.
DAHeight uint64
// Merkle root of the results from executing prev block
LastResultsHash Hash
// the latest AppHash we've received from calling abci.Commit()
AppHash []byte
}
State contains information about current state of the blockchain.
type SyncNodeSignatureBytesProvider ¶
SyncNodeSignatureBytesProvider defines the function type for providing a signature payload to be verified by syncing nodes.
type ValidatorHasherProvider ¶
ValidatorHasherProvider defines the function type for hashing a validator's public key and address.