posavchain

package
v0.0.0-...-231e548 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Overview

Package posavchain implements PBFT consensus algorithm integration and bridge feature

Index

Constants

View Source
const (
	// ExtraVanity represents a fixed number of extra-data bytes reserved for proposer vanity
	ExtraVanity = 32

	// ExtraSeal represents the fixed number of extra-data bytes reserved for proposer seal
	ExtraSeal = 65
)
View Source
const (
	ConsensusName = "shibacchain"
)

Variables

View Source
var (
	DefaultTokenConfig = &TokenConfig{
		Name:       defaultNativeTokenName,
		Symbol:     defaultNativeTokenSymbol,
		Decimals:   defaultNativeTokenDecimals,
		IsMintable: false,
		Owner:      types.ZeroAddress,
	}
)
View Source
var PosaVChainMixDigest = types.StringToHash("adce6e5230abe012342a44e4e9b6d05997d6f015387ae0e59be924afc7ec70c1")

PosaVChainMixDigest represents a hash of "PosaVChain Mix" to identify whether the block is from PosaVChain consensus engine

Functions

func Factory

func Factory(params *consensus.Params) (consensus.Consensus, error)

Factory is the factory function to create a discovery consensus

func ForkManagerFactory

func ForkManagerFactory(forks *chain.Forks) error

func ForkManagerInitialParamsFactory

func ForkManagerInitialParamsFactory(config *chain.Chain) (*forkmanager.ForkParams, error)

func GenesisPostHookFactory

func GenesisPostHookFactory(config *chain.Chain, engineName string) func(txn *state.Transition) error

func GetIbftExtraClean

func GetIbftExtraClean(extraRaw []byte) ([]byte, error)

GetIbftExtraClean returns unmarshaled extra field from the passed in header, but without signatures for the given header (it only includes signatures for the parent block)

func NewStateProvider

func NewStateProvider(transition *state.Transition) contract.Provider

NewStateProvider initializes EVM against given state and chain config and returns stateProvider instance which is an abstraction for smart contract calls

func NewStateSyncRelayer

func NewStateSyncRelayer(
	txRelayer txrelayer.TxRelayer,
	stateReceiverAddr types.Address,
	state *StateSyncStore,
	store stateSyncProofRetriever,
	blockchain blockchainBackend,
	key ethgo.Key,
	config *stateSyncRelayerConfig,
	logger hclog.Logger,
) *stateSyncRelayerImpl

Types

type BlockBuilder

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

func NewBlockBuilder

func NewBlockBuilder(params *BlockBuilderParams) *BlockBuilder

func (*BlockBuilder) Block

func (b *BlockBuilder) Block() *types.Block

Block returns the built block if nil, it is not built yet

func (*BlockBuilder) Build

func (b *BlockBuilder) Build(handler func(h *types.Header)) (*types.FullBlock, error)

Build creates the state and the final block

func (*BlockBuilder) Fill

func (b *BlockBuilder) Fill()

Fill fills the block with transactions from the txpool

func (*BlockBuilder) GetState

func (b *BlockBuilder) GetState() *state.Transition

GetState returns Transition reference

func (*BlockBuilder) Receipts

func (b *BlockBuilder) Receipts() []*types.Receipt

Receipts returns the collection of transaction receipts for given block

func (*BlockBuilder) Reset

func (b *BlockBuilder) Reset() error

Init initializes block builder before adding transactions and actual block building

func (*BlockBuilder) WriteTx

func (b *BlockBuilder) WriteTx(tx *types.Transaction) error

WriteTx applies given transaction to the state. If transaction apply fails, it reverts the saved snapshot.

type BlockBuilderParams

type BlockBuilderParams struct {
	// Parent block
	Parent *types.Header

	// Executor
	Executor *state.Executor

	// Coinbase that is signing the block
	Coinbase types.Address

	// GasLimit is the gas limit for the block
	GasLimit uint64

	// duration for one block
	BlockTime time.Duration

	// Logger
	Logger hcf.Logger

	// txPoolInterface implementation
	TxPool txPoolInterface

	// BaseFee is the base fee
	BaseFee uint64
}

BlockBuilderParams are fields for the block that cannot be changed

type BridgeConfig

type BridgeConfig struct {
	StateSenderAddr                   types.Address `json:"stateSenderAddress"`
	CheckpointManagerAddr             types.Address `json:"checkpointManagerAddress"`
	ExitHelperAddr                    types.Address `json:"exitHelperAddress"`
	RootERC20PredicateAddr            types.Address `json:"erc20PredicateAddress"`
	ChildMintableERC20PredicateAddr   types.Address `json:"erc20ChildMintablePredicateAddress"`
	RootNativeERC20Addr               types.Address `json:"nativeERC20Address"`
	RootERC721PredicateAddr           types.Address `json:"erc721PredicateAddress"`
	ChildMintableERC721PredicateAddr  types.Address `json:"erc721ChildMintablePredicateAddress"`
	RootERC1155PredicateAddr          types.Address `json:"erc1155PredicateAddress"`
	ChildMintableERC1155PredicateAddr types.Address `json:"erc1155ChildMintablePredicateAddress"`
	ChildERC20Addr                    types.Address `json:"childERC20Address"`
	ChildERC721Addr                   types.Address `json:"childERC721Address"`
	ChildERC1155Addr                  types.Address `json:"childERC1155Address"`
	CustomSupernetManagerAddr         types.Address `json:"customSupernetManagerAddr"`
	StakeManagerAddr                  types.Address `json:"stakeManagerAddr"`
	// only populated if stake-manager-deploy command is executed, and used for e2e tests
	StakeTokenAddr types.Address `json:"stakeTokenAddr,omitempty"`
	BLSAddress     types.Address `json:"blsAddr"`
	BN256G2Address types.Address `json:"bn256G2Addr"`

	JSONRPCEndpoint         string                   `json:"jsonRPCEndpoint"`
	EventTrackerStartBlocks map[types.Address]uint64 `json:"eventTrackerStartBlocks"`
}

BridgeConfig is the rootchain configuration, needed for bridging

type BridgeTransport

type BridgeTransport interface {
	Multicast(msg interface{})
}

BridgeTransport is an abstraction of network layer for a bridge

type BurnContractInfo

type BurnContractInfo struct {
	BlockNumber        uint64
	Address            types.Address
	DestinationAddress types.Address
}

BurnContractInfo contains metadata for burn contract, which is part of EIP-1559 specification

type CheckpointData

type CheckpointData struct {
	BlockRound            uint64
	EpochNumber           uint64
	CurrentValidatorsHash types.Hash
	NextValidatorsHash    types.Hash
	EventRoot             types.Hash
}

CheckpointData represents data needed for checkpointing mechanism

func (*CheckpointData) Copy

func (c *CheckpointData) Copy() *CheckpointData

Copy returns deep copy of CheckpointData instance

func (*CheckpointData) Hash

func (c *CheckpointData) Hash(chainID uint64, blockNumber uint64, blockHash types.Hash) (types.Hash, error)

Hash calculates keccak256 hash of the CheckpointData. CheckpointData is ABI encoded and then hashed.

func (*CheckpointData) MarshalRLPWith

func (c *CheckpointData) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value

MarshalRLPWith defines the marshal function implementation for CheckpointData

func (*CheckpointData) UnmarshalRLPWith

func (c *CheckpointData) UnmarshalRLPWith(v *fastrlp.Value) error

UnmarshalRLPWith unmarshals CheckpointData object from the RLP format

func (*CheckpointData) Validate

func (c *CheckpointData) Validate(parentCheckpoint *CheckpointData,
	currentValidators validator.AccountSet, nextValidators validator.AccountSet,
	exitRootHash types.Hash) error

Validate encapsulates validation logic for checkpoint data (with regards to current and next epoch validators)

func (*CheckpointData) ValidateBasic

func (c *CheckpointData) ValidateBasic(parentCheckpoint *CheckpointData) error

ValidateBasic encapsulates basic validation logic for checkpoint data. It only checks epoch numbers validity and whether validators hashes are non-empty.

type CheckpointManager

type CheckpointManager interface {
	EventSubscriber
	PostBlock(req *PostBlockRequest) error
	BuildEventRoot(epoch uint64) (types.Hash, error)
	GenerateExitProof(exitID uint64) (types.Proof, error)
}

type CheckpointStore

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

Bolt DB schema:

exit events/ |--> (id+epoch+blockNumber) -> *ExitEvent (json marshalled) |--> (exitEventID) -> epochNumber |--> (lastProcessedBlockKey) -> block number

type CommitmentMessageSigned

type CommitmentMessageSigned struct {
	Message      *contractsapi.StateSyncCommitment
	AggSignature Signature
	PublicKeys   [][]byte
}

CommitmentMessageSigned encapsulates commitment message with aggregated signatures

func (*CommitmentMessageSigned) ContainsStateSync

func (cm *CommitmentMessageSigned) ContainsStateSync(stateSyncID uint64) bool

ContainsStateSync checks if commitment contains given state sync event

func (*CommitmentMessageSigned) DecodeAbi

func (cm *CommitmentMessageSigned) DecodeAbi(txData []byte) error

DecodeAbi contains logic for decoding given ABI data

func (*CommitmentMessageSigned) EncodeAbi

func (cm *CommitmentMessageSigned) EncodeAbi() ([]byte, error)

EncodeAbi contains logic for encoding arbitrary data into ABI format

func (*CommitmentMessageSigned) Hash

func (cm *CommitmentMessageSigned) Hash() (types.Hash, error)

Hash calculates hash value for commitment object.

func (*CommitmentMessageSigned) VerifyStateSyncProof

func (cm *CommitmentMessageSigned) VerifyStateSyncProof(proof []types.Hash,
	stateSync *contractsapi.StateSyncedEvent) error

VerifyStateSyncProof validates given state sync proof against merkle tree root hash contained in the CommitmentMessage

type EpochStore

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

type EventProvider

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

EventProvider represents an event provider in a blockchain system that returns desired events to subscribers from finalized blocks Note that this provider needs to be called manually on each block finalization. The EventProvider struct has the following fields: - blockchain: A blockchainBackend type that represents the blockchain backend used by the event provider. - subscribers: A map[string]eventSubscriber that stores the subscribers of the event provider. - allFilters: A map[types.Address]map[types.Hash][]string that stores the filters for event logs.

func NewEventProvider

func NewEventProvider(blockchain blockchainBackend) *EventProvider

NewEventProvider returns a new instance of eventProvider

func (*EventProvider) GetEventsFromBlocks

func (e *EventProvider) GetEventsFromBlocks(lastProcessedBlock uint64,
	latestBlock *types.FullBlock,
	dbTx *bolt.Tx) error

GetEventsFromBlocks gets all desired logs (events) for each subscriber in given block range

Inputs: - lastProcessedBlock - last finalized block that was processed for desired events - latestBlock - latest finalized block - dbTx - database transaction under which events are gathered

Returns: - nil - if getting events finished successfully - error - if a block or its receipts could not be retrieved from blockchain

func (*EventProvider) Subscribe

func (e *EventProvider) Subscribe(subscriber EventSubscriber)

Subscribe subscribes given EventSubscriber to desired logs (events)

type EventSubscriber

type EventSubscriber interface {
	// GetLogFilters returns a map of log filters for getting desired events,
	// where the key is the address of contract that emits desired events,
	// and the value is a slice of signatures of events we want to get.
	GetLogFilters() map[types.Address][]types.Hash

	// ProcessLog is used to handle a log defined in GetLogFilters, provided by event provider
	ProcessLog(header *types.Header, log *ethgo.Log, dbTx *bolt.Tx) error
}

EventSubscriber specifies functions needed for a component to subscribe to eventProvider

type ExitEvent

type ExitEvent struct {
	*contractsapi.L2StateSyncedEvent
	// EpochNumber is the epoch number in which exit event was added
	EpochNumber uint64 `abi:"-"`
	// BlockNumber is the block in which exit event was added
	BlockNumber uint64 `abi:"-"`
}

ExitEvent is an event emitted by Exit contract

type Extra

type Extra struct {
	Validators *validator.ValidatorSetDelta
	Parent     *Signature
	Committed  *Signature
	Checkpoint *CheckpointData
}

Extra defines the structure of the extra field for Istanbul

func GetIbftExtra

func GetIbftExtra(extraRaw []byte) (*Extra, error)

GetIbftExtra returns the istanbul extra data field from the passed in header

func (*Extra) MarshalRLPTo

func (i *Extra) MarshalRLPTo(dst []byte) []byte

MarshalRLPTo defines the marshal function wrapper for Extra

func (*Extra) MarshalRLPWith

func (i *Extra) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value

MarshalRLPWith defines the marshal function implementation for Extra

func (*Extra) UnmarshalRLP

func (i *Extra) UnmarshalRLP(input []byte) error

UnmarshalRLP defines the unmarshal function wrapper for Extra

func (*Extra) UnmarshalRLPWith

func (i *Extra) UnmarshalRLPWith(v *fastrlp.Value) error

UnmarshalRLPWith defines the unmarshal implementation for Extra

func (*Extra) ValidateFinalizedData

func (i *Extra) ValidateFinalizedData(header *types.Header, parent *types.Header, parents []*types.Header,
	chainID uint64, consensusBackend posavchainBackend, domain []byte, logger hclog.Logger) error

ValidateFinalizedData contains extra data validations for finalized headers

func (*Extra) ValidateParentSignatures

func (i *Extra) ValidateParentSignatures(blockNumber uint64, consensusBackend posavchainBackend, parents []*types.Header,
	parent *types.Header, parentExtra *Extra, chainID uint64, domain []byte, logger hclog.Logger) error

ValidateParentSignatures validates signatures for parent block

type IBFTConsensusWrapper

type IBFTConsensusWrapper struct {
	*core.IBFT
}

IBFTConsensusWrapper is a convenience wrapper for the go-ibft package

type MessageSignature

type MessageSignature struct {
	// Signer of the vote
	From string
	// Signature of the message
	Signature []byte
}

MessageSignature encapsulates sender identifier and its signature

type PendingCommitment

type PendingCommitment struct {
	*contractsapi.StateSyncCommitment
	MerkleTree *merkle.MerkleTree
	Epoch      uint64
}

PendingCommitment holds merkle trie of bridge transactions accompanied by epoch number

func NewPendingCommitment

func NewPendingCommitment(epoch uint64, stateSyncEvents []*contractsapi.StateSyncedEvent) (*PendingCommitment, error)

NewPendingCommitment creates a new commitment object

func (*PendingCommitment) Hash

func (cm *PendingCommitment) Hash() (types.Hash, error)

Hash calculates hash value for commitment object.

type PosaVChain

type PosaVChain struct {
	// InitialValidatorSet are the genesis validators
	InitialValidatorSet []*validator.GenesisValidator `json:"initialValidatorSet"`

	// Bridge is the rootchain bridge configuration
	Bridge *BridgeConfig `json:"bridge"`

	// EpochSize is size of epoch
	EpochSize uint64 `json:"epochSize"`

	// EpochReward is assigned to validators for blocks sealing
	EpochReward uint64 `json:"epochReward"`

	// SprintSize is size of sprint
	SprintSize uint64 `json:"sprintSize"`

	// BlockTime is target frequency of blocks production
	BlockTime common.Duration `json:"blockTime"`

	// Governance is the initial governance address
	Governance types.Address `json:"governance"`

	// NativeTokenConfig defines name, symbol and decimal count of the native token
	NativeTokenConfig *TokenConfig `json:"nativeTokenConfig"`

	InitialTrieRoot types.Hash `json:"initialTrieRoot"`

	// SupernetID indicates ID of given supernet generated by stake manager contract
	SupernetID int64 `json:"supernetID"`

	// MinValidatorSetSize indicates the minimum size of validator set
	MinValidatorSetSize uint64 `json:"minValidatorSetSize"`

	// MaxValidatorSetSize indicates the maximum size of validator set
	MaxValidatorSetSize uint64 `json:"maxValidatorSetSize"`

	// RewardConfig defines rewards configuration
	RewardConfig *RewardsConfig `json:"rewardConfig"`

	// BlockTimeDrift defines the time slot in which a new block can be created
	BlockTimeDrift uint64 `json:"blockTimeDrift"`

	// BlockTrackerPollInterval specifies interval
	// at which block tracker polls for blocks on a rootchain
	BlockTrackerPollInterval common.Duration `json:"blockTrackerPollInterval,omitempty"`

	// ProxyContractsAdmin is the address that will have the privilege to change both the proxy
	// implementation address and the admin
	ProxyContractsAdmin types.Address `json:"proxyContractsAdmin,omitempty"`
}

PosaVChain is the configuration file for the Posavchain consensus protocol.

func GetPosaVChain

func GetPosaVChain(chainConfig *chain.Chain) (PosaVChain, error)

GetPosaVChain deserializes provided chain config and returns PosaVChain

func LoadPosaVChain

func LoadPosaVChain(chainConfigFile string) (PosaVChain, error)

LoadPosaVChain loads chain config from provided path and unmarshals PosaVChain

func (*PosaVChain) IsBridgeEnabled

func (p *PosaVChain) IsBridgeEnabled() bool

type Posavchain

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

func (*Posavchain) Close

func (p *Posavchain) Close() error

Close closes the connection

func (*Posavchain) FilterExtra

func (p *Posavchain) FilterExtra(extra []byte) ([]byte, error)

FilterExtra is an implementation of Consensus interface

func (*Posavchain) GetBlockCreator

func (p *Posavchain) GetBlockCreator(h *types.Header) (types.Address, error)

GetBlockCreator retrieves the block creator (or signer) given the block header

func (*Posavchain) GetBridgeProvider

func (p *Posavchain) GetBridgeProvider() consensus.BridgeDataProvider

GetBridgeProvider is an implementation of Consensus interface Returns an instance of BridgeDataProvider

func (*Posavchain) GetSyncProgression

func (p *Posavchain) GetSyncProgression() *progress.Progression

GetSyncProgression retrieves the current sync progression, if any

func (*Posavchain) GetValidators

func (p *Posavchain) GetValidators(blockNumber uint64, parents []*types.Header) (validator.AccountSet, error)

func (*Posavchain) GetValidatorsWithTx

func (p *Posavchain) GetValidatorsWithTx(blockNumber uint64, parents []*types.Header,
	dbTx *bolt.Tx) (validator.AccountSet, error)

func (*Posavchain) Initialize

func (p *Posavchain) Initialize() error

Initialize initializes the consensus (e.g. setup data)

func (*Posavchain) Multicast

func (p *Posavchain) Multicast(msg *ibftProto.Message)

Multicast is implementation of core.Transport interface

func (*Posavchain) PreCommitState

func (p *Posavchain) PreCommitState(block *types.Block, _ *state.Transition) error

PreCommitState a hook to be called before finalizing state transition on inserting block

func (*Posavchain) ProcessHeaders

func (p *Posavchain) ProcessHeaders(_ []*types.Header) error

ProcessHeaders updates the snapshot based on the verified headers

func (*Posavchain) Start

func (p *Posavchain) Start() error

Start starts the consensus and servers

func (*Posavchain) VerifyHeader

func (p *Posavchain) VerifyHeader(header *types.Header) error

VerifyHeader implements consensus.Engine and checks whether a header conforms to the consensus rules

type PostBlockRequest

type PostBlockRequest struct {
	// FullBlock is a reference of the executed block
	FullBlock *types.FullBlock
	// Epoch is the epoch number of the executed block
	Epoch uint64
	// IsEpochEndingBlock indicates if this was the last block of given epoch
	IsEpochEndingBlock bool
	// DBTx is the opened transaction on state store (in our case boltDB)
	// used to save necessary data on PostBlock
	DBTx *bolt.Tx
}

type PostEpochRequest

type PostEpochRequest struct {
	// NewEpochID is the id of the new epoch
	NewEpochID uint64

	// FirstBlockOfEpoch is the number of the epoch beginning block
	FirstBlockOfEpoch uint64

	// SystemState is the state of the governance smart contracts
	// after this block
	SystemState SystemState

	// ValidatorSet is the validator set for the new epoch
	ValidatorSet validator.ValidatorSet

	// DBTx is the opened transaction on state store (in our case boltDB)
	// used to save necessary data on PostEpoch
	DBTx *bolt.Tx
}

type PrioritizedValidator

type PrioritizedValidator struct {
	Metadata         *validator.ValidatorMetadata
	ProposerPriority *big.Int
}

PrioritizedValidator holds ValidatorMetadata together with priority

func (PrioritizedValidator) String

func (pv PrioritizedValidator) String() string

type ProposerCalculator

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

func NewProposerCalculator

func NewProposerCalculator(config *runtimeConfig, logger hclog.Logger,
	dbTx *bolt.Tx) (*ProposerCalculator, error)

NewProposerCalculator creates a new proposer calculator object

func NewProposerCalculatorFromSnapshot

func NewProposerCalculatorFromSnapshot(pcs *ProposerSnapshot, config *runtimeConfig,
	logger hclog.Logger) *ProposerCalculator

NewProposerCalculator creates a new proposer calculator object

func (*ProposerCalculator) GetSnapshot

func (pc *ProposerCalculator) GetSnapshot() (*ProposerSnapshot, bool)

Get copy of the proposers' snapshot

func (*ProposerCalculator) PostBlock

func (pc *ProposerCalculator) PostBlock(req *PostBlockRequest) error

PostBlock is called on every insert of finalized block (either from consensus or syncer) It will update priorities and save the updated snapshot to db

type ProposerSnapshot

type ProposerSnapshot struct {
	Height     uint64
	Round      uint64
	Proposer   *PrioritizedValidator
	Validators []*PrioritizedValidator
}

ProposerSnapshot represents snapshot of one proposer calculation

func NewProposerSnapshot

func NewProposerSnapshot(height uint64, validators []*validator.ValidatorMetadata) *ProposerSnapshot

NewProposerSnapshot creates ProposerSnapshot with height and validators with all priorities set to zero

func NewProposerSnapshotFromState

func NewProposerSnapshotFromState(config *runtimeConfig, dbTx *bolt.Tx) (*ProposerSnapshot, error)

NewProposerSnapshotFromState create ProposerSnapshot from state if possible or from genesis block

func (*ProposerSnapshot) CalcProposer

func (pcs *ProposerSnapshot) CalcProposer(round, height uint64) (types.Address, error)

CalcProposer calculates next proposer

func (*ProposerSnapshot) Copy

func (pcs *ProposerSnapshot) Copy() *ProposerSnapshot

Copy Returns copy of current ProposerSnapshot object

func (*ProposerSnapshot) GetLatestProposer

func (pcs *ProposerSnapshot) GetLatestProposer(round, height uint64) (types.Address, error)

GetLatestProposer returns latest calculated proposer if any

func (ProposerSnapshot) GetTotalVotingPower

func (pcs ProposerSnapshot) GetTotalVotingPower() *big.Int

GetTotalVotingPower returns total voting power from all the validators

type ProposerSnapshotStore

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

type RewardsConfig

type RewardsConfig struct {
	// TokenAddress is the address of reward token on child chain
	TokenAddress types.Address

	// WalletAddress is the address of reward wallet on child chain
	WalletAddress types.Address

	// WalletAmount is the amount of tokens in reward wallet
	WalletAmount *big.Int
}

func (*RewardsConfig) MarshalJSON

func (r *RewardsConfig) MarshalJSON() ([]byte, error)

func (*RewardsConfig) UnmarshalJSON

func (r *RewardsConfig) UnmarshalJSON(data []byte) error

type RootchainConfig

type RootchainConfig struct {
	JSONRPCAddr string

	StateSenderAddress                   types.Address
	CheckpointManagerAddress             types.Address
	BLSAddress                           types.Address
	BN256G2Address                       types.Address
	ExitHelperAddress                    types.Address
	RootERC20PredicateAddress            types.Address
	ChildMintableERC20PredicateAddress   types.Address
	RootNativeERC20Address               types.Address
	ChildERC20Address                    types.Address
	RootERC721PredicateAddress           types.Address
	ChildMintableERC721PredicateAddress  types.Address
	ChildERC721Address                   types.Address
	RootERC1155PredicateAddress          types.Address
	ChildMintableERC1155PredicateAddress types.Address
	ChildERC1155Address                  types.Address
	CustomSupernetManagerAddress         types.Address
	StakeManagerAddress                  types.Address
	StakeTokenAddress                    types.Address
}

RootchainConfig contains rootchain metadata (such as JSON RPC endpoint and contract addresses)

func (*RootchainConfig) ToBridgeConfig

func (r *RootchainConfig) ToBridgeConfig() *BridgeConfig

ToBridgeConfig creates BridgeConfig instance

type Runtime

type Runtime interface {
	IsActiveValidator() bool
}

type Signature

type Signature struct {
	AggregatedSignature []byte
	Bitmap              []byte
}

Signature represents aggregated signatures of signers accompanied with a bitmap (in order to be able to determine identities of each signer)

func (*Signature) MarshalRLPWith

func (s *Signature) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value

MarshalRLPWith marshals Signature object into RLP format

func (*Signature) UnmarshalRLPWith

func (s *Signature) UnmarshalRLPWith(v *fastrlp.Value) error

UnmarshalRLPWith unmarshals Signature object from the RLP format

func (*Signature) Verify

func (s *Signature) Verify(blockNumber uint64, validators validator.AccountSet,
	hash types.Hash, domain []byte, logger hclog.Logger) error

Verify is used to verify aggregated signature based on current validator set, message hash and domain

type StakeManager

type StakeManager interface {
	EventSubscriber
	PostBlock(req *PostBlockRequest) error
	UpdateValidatorSet(epoch uint64, currentValidatorSet validator.AccountSet) (*validator.ValidatorSetDelta, error)
}

StakeManager interface provides functions for handling stake change of validators and updating validator set based on changed stake

type StakeStore

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

type State

type State struct {
	StateSyncStore        *StateSyncStore
	CheckpointStore       *CheckpointStore
	EpochStore            *EpochStore
	ProposerSnapshotStore *ProposerSnapshotStore
	StakeStore            *StakeStore
	// contains filtered or unexported fields
}

State represents a persistence layer which persists consensus data off-chain

type StateSyncManager

type StateSyncManager interface {
	EventSubscriber
	Init() error
	Close()
	Commitment(blockNumber uint64) (*CommitmentMessageSigned, error)
	GetStateSyncProof(stateSyncID uint64) (types.Proof, error)
	PostBlock(req *PostBlockRequest) error
	PostEpoch(req *PostEpochRequest) error
}

StateSyncManager is an interface that defines functions for state sync workflow

type StateSyncProof

type StateSyncProof struct {
	Proof     []types.Hash
	StateSync *contractsapi.StateSyncedEvent
}

type StateSyncRelayer

type StateSyncRelayer interface {
	EventSubscriber
	PostBlock(req *PostBlockRequest) error
	Init() error
	Close()
}

StateSyncRelayer is an interface that defines functions for state sync relayer

type StateSyncRelayerEventData

type StateSyncRelayerEventData struct {
	EventID     uint64 `json:"eventID"`
	CountTries  uint64 `json:"countTries"`
	BlockNumber uint64 `json:"blockNumber"` // block when state sync is sent
	SentStatus  bool   `json:"sentStatus"`
}

StateSyncRelayerEventData keeps information about an event

func (StateSyncRelayerEventData) String

func (ed StateSyncRelayerEventData) String() string

type StateSyncStore

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

type SystemState

type SystemState interface {
	// GetEpoch retrieves current epoch number from the smart contract
	GetEpoch() (uint64, error)
	// GetNextCommittedIndex retrieves next committed bridge state sync index
	GetNextCommittedIndex() (uint64, error)
}

SystemState is an interface to interact with the consensus system contracts in the chain

type SystemStateImpl

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

SystemStateImpl is implementation of SystemState interface

func NewSystemState

func NewSystemState(valSetAddr types.Address, stateRcvAddr types.Address, provider contract.Provider) *SystemStateImpl

NewSystemState initializes new instance of systemState which abstracts smart contracts functions

func (*SystemStateImpl) GetEpoch

func (s *SystemStateImpl) GetEpoch() (uint64, error)

GetEpoch retrieves current epoch number from the smart contract

func (*SystemStateImpl) GetNextCommittedIndex

func (s *SystemStateImpl) GetNextCommittedIndex() (uint64, error)

GetNextCommittedIndex retrieves next committed bridge state sync index

type TokenConfig

type TokenConfig struct {
	Name       string        `json:"name"`
	Symbol     string        `json:"symbol"`
	Decimals   uint8         `json:"decimals"`
	IsMintable bool          `json:"isMintable"`
	Owner      types.Address `json:"owner"`
}

TokenConfig is the configuration of native token used by vchain network

func ParseRawTokenConfig

func ParseRawTokenConfig(rawConfig string) (*TokenConfig, error)

type TransportMessage

type TransportMessage struct {
	// Hash is encoded data
	Hash []byte
	// Message signature
	Signature []byte
	// From is the address of the message signer
	From string
	// Number of epoch
	EpochNumber uint64
}

TransportMessage represents the payload which is gossiped across the network

type ValidatorInfo

type ValidatorInfo struct {
	Address             ethgo.Address `json:"address"`
	Stake               *big.Int      `json:"stake"`
	WithdrawableRewards *big.Int      `json:"withdrawableRewards"`
	IsActive            bool          `json:"isActive"`
	IsWhitelisted       bool          `json:"isWhitelisted"`
}

ValidatorInfo is data transfer object which holds validator information, provided by smart contract

Directories

Path Synopsis
Code generated by scapi/gen.
Code generated by scapi/gen.

Jump to

Keyboard shortcuts

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