Documentation ¶
Index ¶
- Constants
- Variables
- func GetRandomBytes(n int) []byte
- func GetRandomValidatorSet() *tmtypes.ValidatorSet
- func GetRandomValidatorSetWithPrivKey() (*tmtypes.ValidatorSet, ed25519.PrivKey)
- type BaseHeader
- type Block
- func (b *Block) ChainID() string
- func (b *Block) FromProto(other *pb.Block) error
- func (b *Block) Hash() Hash
- func (b *Block) Height() int64
- func (b *Block) IsZero() bool
- func (b *Block) LastHeader() Hash
- func (b *Block) MarshalBinary() ([]byte, error)
- func (b *Block) New() header.Header
- func (b *Block) Time() time.Time
- func (b *Block) ToProto() (*pb.Block, error)
- func (b *Block) UnmarshalBinary(data []byte) error
- func (b *Block) Validate() error
- func (b *Block) ValidateBasic() error
- func (b *Block) Verify(untrst header.Header) error
- type Commit
- func (c *Commit) FromProto(other *pb.Commit) error
- func (c *Commit) GetCommitHash(header *Header, proposerAddress []byte) []byte
- func (c *Commit) MarshalBinary() ([]byte, error)
- func (c *Commit) ToABCICommit(height int64, hash Hash) *tmtypes.Commit
- func (c *Commit) ToProto() *pb.Commit
- func (c *Commit) UnmarshalBinary(data []byte) error
- func (c *Commit) ValidateBasic() error
- type Data
- type Evidence
- type EvidenceData
- 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() int64
- func (h *Header) IsZero() bool
- func (h *Header) LastHeader() Hash
- func (h *Header) MarshalBinary() ([]byte, error)
- func (h *Header) New() header.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(untrst header.Header) error
- type IntermediateStateRoots
- type NamespaceID
- type Signature
- type SignedHeader
- func (h *SignedHeader) FromProto(other *pb.SignedHeader) error
- func (sH *SignedHeader) IsZero() bool
- func (h *SignedHeader) MarshalBinary() ([]byte, error)
- func (sH *SignedHeader) New() header.Header
- func (h *SignedHeader) ToProto() (*pb.SignedHeader, error)
- func (h *SignedHeader) UnmarshalBinary(data []byte) error
- func (h *SignedHeader) ValidateBasic() error
- func (sH *SignedHeader) Verify(untrst header.Header) error
- type State
- type StateFraudProof
- func (fp *StateFraudProof) HeaderHash() []byte
- func (fp *StateFraudProof) Height() uint64
- func (fp *StateFraudProof) MarshalBinary() (data []byte, err error)
- func (fp *StateFraudProof) Type() fraud.ProofType
- func (fp *StateFraudProof) UnmarshalBinary(data []byte) error
- func (fp *StateFraudProof) Validate(header.Header) error
- type Tx
- type TxProof
- type Txs
- type Version
Constants ¶
const StateFraudProofType fraud.ProofType = "state-fraud"
Variables ¶
var InitStateVersion = tmstate.Version{ Consensus: tmversion.Consensus{ Block: version.BlockProtocol, App: 0, }, Software: version.TMCoreSemVer, }
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 GetRandomBytes ¶ added in v0.9.0
func GetRandomValidatorSet ¶ added in v0.9.0
func GetRandomValidatorSet() *tmtypes.ValidatorSet
TODO: accept argument for number of validators / proposer index
func GetRandomValidatorSetWithPrivKey ¶ added in v0.9.0
func GetRandomValidatorSetWithPrivKey() (*tmtypes.ValidatorSet, ed25519.PrivKey)
Types ¶
type BaseHeader ¶
type BaseHeader struct { // Height represents the block height (aka block number) of a given header Height uint64 // Time contains Unix time of a block Time uint64 // The Chain ID ChainID string }
BaseHeader contains the most basic data of a header
type Block ¶
type Block struct { SignedHeader SignedHeader Data Data }
Block defines the structure of Rollkit block.
func (*Block) LastHeader ¶ added in v0.9.0
func (*Block) MarshalBinary ¶
MarshalBinary encodes Block into binary form and returns it.
func (*Block) UnmarshalBinary ¶
UnmarshalBinary decodes binary form of Block into object.
func (*Block) ValidateBasic ¶
ValidateBasic performs basic validation of a block.
type Commit ¶
type Commit struct {
Signatures []Signature // most of the time this is a single signature
}
Commit contains evidence of block creation.
func (*Commit) GetCommitHash ¶ added in v0.9.0
func (*Commit) MarshalBinary ¶
MarshalBinary encodes Commit into binary form and returns it.
func (*Commit) ToABCICommit ¶ added in v0.9.0
ToABCICommit converts Rollkit commit into commit format defined by ABCI. This function only converts fields that are available in Rollkit commit. Other fields (especially ValidatorAddress and Timestamp of Signature) has to be filled by caller.
func (*Commit) UnmarshalBinary ¶
UnmarshalBinary decodes binary form of Commit into object.
func (*Commit) ValidateBasic ¶
ValidateBasic performs basic validation of a commit.
type Data ¶
type Data struct { Txs Txs IntermediateStateRoots IntermediateStateRoots }
Data defines Rollkit block data.
func (*Data) MarshalBinary ¶
MarshalBinary encodes Data into binary form and returns it.
func (*Data) ValidateBasic ¶
ValidateBasic performs basic validation of block data. Actually it's a placeholder, because nothing is checked.
type Evidence ¶
type Evidence interface { ABCI() []abci.Evidence // forms individual evidence to be sent to the application Bytes() []byte // bytes which comprise the evidence Hash() []byte // hash of the evidence Height() int64 // height of the infraction String() string // string format of the evidence Time() time.Time // time of the infraction ValidateBasic() error // basic consistency check }
Evidence represents any provable malicious activity by a validator. Verification logic for each evidence is part of the evidence module.
type EvidenceData ¶
type EvidenceData struct {
Evidence []Evidence
}
EvidenceData defines how evidence is stored in block.
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 // 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 // Hash of block aggregator set, at a time of block creation AggregatorsHash Hash }
Header defines the structure of Rollkit block header.
func (*Header) LastHeader ¶
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 IntermediateStateRoots ¶
type IntermediateStateRoots struct {
RawRootsList [][]byte
}
IntermediateStateRoots describes the state between transactions. They are required for fraud proofs.
type NamespaceID ¶
type NamespaceID [8]byte
type SignedHeader ¶
type SignedHeader struct { Header Commit Commit Validators *tmtypes.ValidatorSet }
SignedHeader combines Header and its Commit.
Used mostly for gossiping.
func GetNextRandomHeader ¶ added in v0.9.0
func GetNextRandomHeader(signedHeader *SignedHeader, privKey ed25519.PrivKey) (*SignedHeader, error)
func GetRandomSignedHeader ¶ added in v0.9.0
func GetRandomSignedHeader() (*SignedHeader, ed25519.PrivKey, error)
func (*SignedHeader) FromProto ¶
func (h *SignedHeader) FromProto(other *pb.SignedHeader) error
FromProto fills SignedHeader with data from protobuf representation.
func (*SignedHeader) IsZero ¶ added in v0.7.0
func (sH *SignedHeader) IsZero() bool
func (*SignedHeader) MarshalBinary ¶
func (h *SignedHeader) MarshalBinary() ([]byte, error)
MarshalBinary encodes SignedHeader into binary form and returns it.
func (*SignedHeader) New ¶ added in v0.7.0
func (sH *SignedHeader) New() header.Header
func (*SignedHeader) ToProto ¶
func (h *SignedHeader) ToProto() (*pb.SignedHeader, error)
ToProto converts SignedHeader into protobuf representation and returns it.
func (*SignedHeader) UnmarshalBinary ¶
func (h *SignedHeader) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes binary form of SignedHeader into object.
func (*SignedHeader) ValidateBasic ¶
func (h *SignedHeader) ValidateBasic() error
ValidateBasic performs basic validation of a signed header.
func (*SignedHeader) Verify ¶ added in v0.7.2
func (sH *SignedHeader) Verify(untrst header.Header) error
type State ¶
type State struct { Version tmstate.Version // immutable ChainID string InitialHeight int64 // should be 1, not 0, when starting from height 1 // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) LastBlockHeight int64 LastBlockID types.BlockID LastBlockTime time.Time // DAHeight identifies DA block containing the latest applied Rollkit block. DAHeight uint64 // In the MVP implementation, there will be only one Validator NextValidators *types.ValidatorSet Validators *types.ValidatorSet LastValidators *types.ValidatorSet LastHeightValidatorsChanged int64 // Consensus parameters used for validating blocks. // Changes returned by EndBlock and updated after Commit. ConsensusParams tmproto.ConsensusParams LastHeightConsensusParamsChanged int64 // Merkle root of the results from executing prev block LastResultsHash Hash // the latest AppHash we've received from calling abci.Commit() AppHash Hash }
State contains information about current state of the blockchain.
func NewFromGenesisDoc ¶
func NewFromGenesisDoc(genDoc *types.GenesisDoc) (State, error)
NewFromGenesisDoc reads blockchain State from genesis.
type StateFraudProof ¶ added in v0.8.0
type StateFraudProof struct {
abci.FraudProof
}
func (*StateFraudProof) HeaderHash ¶ added in v0.8.0
func (fp *StateFraudProof) HeaderHash() []byte
func (*StateFraudProof) Height ¶ added in v0.8.0
func (fp *StateFraudProof) Height() uint64
func (*StateFraudProof) MarshalBinary ¶ added in v0.8.0
func (fp *StateFraudProof) MarshalBinary() (data []byte, err error)
func (*StateFraudProof) Type ¶ added in v0.8.0
func (fp *StateFraudProof) Type() fraud.ProofType
func (*StateFraudProof) UnmarshalBinary ¶ added in v0.8.0
func (fp *StateFraudProof) UnmarshalBinary(data []byte) error
func (*StateFraudProof) Validate ¶ added in v0.8.0
func (fp *StateFraudProof) Validate(header.Header) error
type Tx ¶
type Tx []byte
Tx represents transactoin.
func GetRandomTx ¶ added in v0.9.0
func GetRandomTx() Tx
type TxProof ¶
type TxProof struct { RootHash tmbytes.HexBytes `json:"root_hash"` Data Tx `json:"data"` Proof merkle.Proof `json:"proof"` }
TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.
type Txs ¶
type Txs []Tx
Txs represents a slice of transactions.
func (Txs) Proof ¶
Proof returns a simple merkle proof for this node. Panics if i < 0 or i >= len(txs) TODO: optimize this!
func (Txs) ToTxsWithISRs ¶ added in v0.8.0
func (txs Txs) ToTxsWithISRs(intermediateStateRoots IntermediateStateRoots) ([]pb.TxWithISRs, error)
ToTxsWithISRs converts a slice of transactions and a list of intermediate state roots to a slice of TxWithISRs. Note that the length of intermediateStateRoots is equal to the length of txs + 1.