Documentation
¶
Overview ¶
Package chain is a generated GoMock package.
Package chain is a generated GoMock package.
Package chain is a generated GoMock package.
Package chain is a generated GoMock package.
Index ¶
- Constants
- Variables
- func BuildBlock(ctx context.Context, vm VM, preferred ids.ID) (snowman.Block, error)
- func HandlePreExecute(err error) (bool, bool, bool)
- func MarshalResults(src []*Result) ([]byte, error)
- func MarshalTxs(txs []*Transaction, actionRegistry ActionRegistry, authRegistry AuthRegistry) ([]byte, error)
- type Action
- type ActionRegistry
- type Auth
- type AuthFactory
- type AuthRegistry
- type Base
- type Database
- type ExecutionContext
- type Mempool
- type MockAction
- func (m *MockAction) EXPECT() *MockActionMockRecorder
- func (m *MockAction) Execute(arg0 context.Context, arg1 Rules, arg2 Database, arg3 int64, arg4 Auth, ...) (*Result, error)
- func (m *MockAction) Marshal(arg0 *codec.Packer)
- func (m *MockAction) MaxUnits(arg0 Rules) uint64
- func (m *MockAction) StateKeys(arg0 Auth) [][]byte
- func (m *MockAction) ValidRange(arg0 Rules) (int64, int64)
- type MockActionMockRecorder
- func (mr *MockActionMockRecorder) Execute(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call
- func (mr *MockActionMockRecorder) Marshal(arg0 interface{}) *gomock.Call
- func (mr *MockActionMockRecorder) MaxUnits(arg0 interface{}) *gomock.Call
- func (mr *MockActionMockRecorder) StateKeys(arg0 interface{}) *gomock.Call
- func (mr *MockActionMockRecorder) ValidRange(arg0 interface{}) *gomock.Call
- type MockAuth
- func (m *MockAuth) AsyncVerify(arg0 []byte) error
- func (m *MockAuth) CanDeduct(arg0 context.Context, arg1 Database, arg2 uint64) error
- func (m *MockAuth) Deduct(arg0 context.Context, arg1 Database, arg2 uint64) error
- func (m *MockAuth) EXPECT() *MockAuthMockRecorder
- func (m *MockAuth) Marshal(arg0 *codec.Packer)
- func (m *MockAuth) MaxUnits(arg0 Rules) uint64
- func (m *MockAuth) Payer() []byte
- func (m *MockAuth) Refund(arg0 context.Context, arg1 Database, arg2 uint64) error
- func (m *MockAuth) StateKeys() [][]byte
- func (m *MockAuth) ValidRange(arg0 Rules) (int64, int64)
- func (m *MockAuth) Verify(arg0 context.Context, arg1 Rules, arg2 Database, arg3 Action) (uint64, error)
- type MockAuthFactory
- type MockAuthFactoryMockRecorder
- type MockAuthMockRecorder
- func (mr *MockAuthMockRecorder) AsyncVerify(arg0 interface{}) *gomock.Call
- func (mr *MockAuthMockRecorder) CanDeduct(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockAuthMockRecorder) Deduct(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockAuthMockRecorder) Marshal(arg0 interface{}) *gomock.Call
- func (mr *MockAuthMockRecorder) MaxUnits(arg0 interface{}) *gomock.Call
- func (mr *MockAuthMockRecorder) Payer() *gomock.Call
- func (mr *MockAuthMockRecorder) Refund(arg0, arg1, arg2 interface{}) *gomock.Call
- func (mr *MockAuthMockRecorder) StateKeys() *gomock.Call
- func (mr *MockAuthMockRecorder) ValidRange(arg0 interface{}) *gomock.Call
- func (mr *MockAuthMockRecorder) Verify(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- type MockRules
- func (m *MockRules) EXPECT() *MockRulesMockRecorder
- func (m *MockRules) FetchCustom(arg0 string) (interface{}, bool)
- func (m *MockRules) GetBaseUnits() uint64
- func (m *MockRules) GetBlockCostChangeDenominator() uint64
- func (m *MockRules) GetChainID() ids.ID
- func (m *MockRules) GetMaxBlockTxs() int
- func (m *MockRules) GetMaxBlockUnits() uint64
- func (m *MockRules) GetMinBlockCost() uint64
- func (m *MockRules) GetMinUnitPrice() uint64
- func (m *MockRules) GetUnitPriceChangeDenominator() uint64
- func (m *MockRules) GetValidityWindow() int64
- func (m *MockRules) GetWindowTargetBlocks() uint64
- func (m *MockRules) GetWindowTargetUnits() uint64
- type MockRulesMockRecorder
- func (mr *MockRulesMockRecorder) FetchCustom(arg0 interface{}) *gomock.Call
- func (mr *MockRulesMockRecorder) GetBaseUnits() *gomock.Call
- func (mr *MockRulesMockRecorder) GetBlockCostChangeDenominator() *gomock.Call
- func (mr *MockRulesMockRecorder) GetChainID() *gomock.Call
- func (mr *MockRulesMockRecorder) GetMaxBlockTxs() *gomock.Call
- func (mr *MockRulesMockRecorder) GetMaxBlockUnits() *gomock.Call
- func (mr *MockRulesMockRecorder) GetMinBlockCost() *gomock.Call
- func (mr *MockRulesMockRecorder) GetMinUnitPrice() *gomock.Call
- func (mr *MockRulesMockRecorder) GetUnitPriceChangeDenominator() *gomock.Call
- func (mr *MockRulesMockRecorder) GetValidityWindow() *gomock.Call
- func (mr *MockRulesMockRecorder) GetWindowTargetBlocks() *gomock.Call
- func (mr *MockRulesMockRecorder) GetWindowTargetUnits() *gomock.Call
- type Parser
- type Processor
- type Result
- type Rules
- type StatefulBlock
- type StatelessBlock
- func NewBlock(ectx *ExecutionContext, vm VM, parent snowman.Block, tmstp int64) *StatelessBlock
- func ParseBlock(ctx context.Context, source []byte, status choices.Status, vm VM) (*StatelessBlock, error)
- func ParseStatefulBlock(ctx context.Context, blk *StatefulBlock, source []byte, status choices.Status, ...) (*StatelessBlock, error)
- func (b *StatelessBlock) Accept(ctx context.Context) error
- func (b *StatelessBlock) Bytes() []byte
- func (b *StatelessBlock) GetTimestamp() int64
- func (b *StatelessBlock) GetTxs() []*Transaction
- func (b *StatelessBlock) GetUnitPrice() uint64
- func (b *StatelessBlock) Height() uint64
- func (b *StatelessBlock) ID() ids.ID
- func (b *StatelessBlock) IsRepeat(ctx context.Context, oldestAllowed int64, txs []*Transaction) (bool, error)
- func (b *StatelessBlock) Parent() ids.ID
- func (b *StatelessBlock) Processed() bool
- func (b *StatelessBlock) Reject(ctx context.Context) error
- func (b *StatelessBlock) Results() []*Result
- func (b *StatelessBlock) SetLastAccepted(ctx context.Context) error
- func (b *StatelessBlock) State() (Database, error)
- func (b *StatelessBlock) Status() choices.Status
- func (b *StatelessBlock) Timestamp() time.Time
- func (b *StatelessBlock) Verify(ctx context.Context) error
- type SyncableBlock
- type Transaction
- func (t *Transaction) Bytes() []byte
- func (t *Transaction) Digest() ([]byte, error)
- func (t *Transaction) Execute(ctx context.Context, r Rules, tdb *tstate.TState, timestamp int64) (*Result, error)
- func (t *Transaction) Expiry() int64
- func (t *Transaction) ID() ids.ID
- func (t *Transaction) Init(_ context.Context, actionRegistry ActionRegistry, authRegistry AuthRegistry) (func() error, error)
- func (t *Transaction) Marshal(p *codec.Packer, actionRegistry *codec.TypeParser[Action], ...) error
- func (t *Transaction) MaxUnits(r Rules) uint64
- func (t *Transaction) Payer() string
- func (t *Transaction) PreExecute(ctx context.Context, ectx *ExecutionContext, r Rules, db Database, ...) error
- func (t *Transaction) Sign(factory AuthFactory) error
- func (t *Transaction) Size() uint64
- func (t *Transaction) StateKeys() [][]byte
- func (t *Transaction) UnitPrice() uint64
- type VM
Constants ¶
const (
FutureBound = 10 * time.Second
)
const ( // AvalancheGo imposes a limit of 2 MiB on the network, so we limit at // 2 MiB - ProposerVM header - Protobuf encoding overhead (we assume this is // no more than 50 KiB of overhead but is likely much less) NetworkSizeLimit = 2_044_723 // 1.95 MiB )
Variables ¶
var ( // Parsing ErrInvalidObject = errors.New("invalid object") // Genesis Correctness ErrInvalidChainID = errors.New("invalid chain ID") ErrInvalidBlockRate = errors.New("invalid block rate") // Block Correctness ErrTimestampTooEarly = errors.New("timestamp too early") ErrTimestampTooLate = errors.New("timestamp too late") ErrStateRootEmpty = errors.New("state root empty") ErrNoTxs = errors.New("no transactions") ErrInvalidUnitPrice = errors.New("invalid unit price") ErrInvalidUnitWindow = errors.New("invalid unit window") ErrInvalidBlockCost = errors.New("invalid block cost") ErrInvalidBlockWindow = errors.New("invalid block window") ErrInvalidUnitsConsumed = errors.New("invalid units consumed") ErrInsufficientSurplus = errors.New("insufficient surplus fee") ErrInvalidSurplus = errors.New("invalid surplus fee") ErrStateRootMismatch = errors.New("state root mismatch") ErrInvalidResult = errors.New("invalid result") // Tx Correctness ErrInvalidSignature = errors.New("invalid signature") ErrDuplicateTx = errors.New("duplicate transaction") ErrInsufficientPrice = errors.New("insufficient price") ErrInvalidType = errors.New("invalid tx type") ErrInvalidID = errors.New("invalid content ID") ErrInvalidSchema = errors.New("invalid schema") ErrInvalidContent = errors.New("invalid content") ErrContentAlreadyExists = errors.New("content already exists") ErrContentMissing = errors.New("content does not exist") ErrWrongOwner = errors.New("wrong owner") ErrInsufficientTip = errors.New("insufficient tip") ErrAccountNotEmpty = errors.New("account not empty") ErrServicerMissing = errors.New("servicer missing") ErrTooManyTxs = errors.New("too many transactions") ErrActionNotActivated = errors.New("action not activated") ErrAuthNotActivated = errors.New("auth not activated") ErrAuthFailed = errors.New("auth failed") // Execution Correctness ErrInvalidBalance = errors.New("invalid balance") ErrBlockTooBig = errors.New("block too big") ErrKeyNotSpecified = errors.New("key not specified") // Misc ErrNotImplemented = errors.New("not implemented") ErrBlockNotProcessed = errors.New("block is not processed") )
Functions ¶
func BuildBlock ¶
func MarshalResults ¶
func MarshalTxs ¶
func MarshalTxs( txs []*Transaction, actionRegistry ActionRegistry, authRegistry AuthRegistry, ) ([]byte, error)
Types ¶
type Action ¶
type Action interface { MaxUnits(Rules) uint64 // max units that could be charged via execute ValidRange(Rules) (start int64, end int64) // -1 means no start/end // Auth may contain an [Actor] that performs a transaction // // if attempt to reference missing key, error...it is ok to not use all keys (conditional logic based on state) StateKeys(Auth) [][]byte // Key distinction with "Auth" is the payment of fees. All non-fee payments // occur in Execute but Auth handles fees. // // The weird part of this is that they both need a shared understanding of // balance tracking. Is it weird Auth then needs an understanding of storage // structure? Not sure there is an easier way. // // It is also odd because we may pull some aspect of the transaction from // auth (like where to pull balance from on a transfer). Execute( ctx context.Context, r Rules, db Database, timestamp int64, auth Auth, txID ids.ID, ) (result *Result, err error) // err should only be returned if fatal Marshal(p *codec.Packer) }
type ActionRegistry ¶
type ActionRegistry *codec.TypeParser[Action]
type Auth ¶
type Auth interface { MaxUnits(Rules) uint64 ValidRange(Rules) (start int64, end int64) // -1 means no start/end StateKeys() [][]byte // will be run concurrently, optimistically start crypto ops (may not complete before [Verify]) AsyncVerify(msg []byte) error // Is Auth able to execute [Action], assuming [AsyncVerify] passes? Verify( ctx context.Context, r Rules, db Database, action Action, ) (units uint64, err error) // if there is account abstraction, may need to pull from state some mapping // TODO: identifier->may be used to send to in action as well? Payer() []byte // need to track mempool + charge fees -> used to clear related accounts if balance check fails CanDeduct(ctx context.Context, db Database, amount uint64) error Deduct(ctx context.Context, db Database, amount uint64) error Refund(ctx context.Context, db Database, amount uint64) error // only invoked if amount > 0 Marshal(p *codec.Packer) }
type AuthFactory ¶
type AuthRegistry ¶
type AuthRegistry *codec.TypeParser[Auth]
type Base ¶
type Base struct { // Timestamp is the expiry of the transaction. Once this time passes and the // transaction is not included in a block, it is safe to regenerate it. Timestamp int64 `json:"nonce"` // ChainID protects against replay attacks on different VM instances. ChainID ids.ID `json:"chainId"` // Unit price is the value per unit to spend on this transaction. UnitPrice uint64 `json:"unitPrice"` }
type ExecutionContext ¶
type ExecutionContext struct { NextUnitPrice uint64 NextUnitWindow window.Window NextBlockCost uint64 NextBlockWindow window.Window }
func GenerateExecutionContext ¶
func GenerateExecutionContext( ctx context.Context, currTime int64, parent *StatelessBlock, tracer trace.Tracer, r Rules, ) (*ExecutionContext, error)
type MockAction ¶
type MockAction struct {
// contains filtered or unexported fields
}
MockAction is a mock of Action interface.
func NewMockAction ¶
func NewMockAction(ctrl *gomock.Controller) *MockAction
NewMockAction creates a new mock instance.
func (*MockAction) EXPECT ¶
func (m *MockAction) EXPECT() *MockActionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockAction) Execute ¶
func (m *MockAction) Execute(arg0 context.Context, arg1 Rules, arg2 Database, arg3 int64, arg4 Auth, arg5 ids.ID) (*Result, error)
Execute mocks base method.
func (*MockAction) Marshal ¶
func (m *MockAction) Marshal(arg0 *codec.Packer)
Marshal mocks base method.
func (*MockAction) MaxUnits ¶
func (m *MockAction) MaxUnits(arg0 Rules) uint64
MaxUnits mocks base method.
func (*MockAction) StateKeys ¶
func (m *MockAction) StateKeys(arg0 Auth) [][]byte
StateKeys mocks base method.
func (*MockAction) ValidRange ¶
func (m *MockAction) ValidRange(arg0 Rules) (int64, int64)
ValidRange mocks base method.
type MockActionMockRecorder ¶
type MockActionMockRecorder struct {
// contains filtered or unexported fields
}
MockActionMockRecorder is the mock recorder for MockAction.
func (*MockActionMockRecorder) Execute ¶
func (mr *MockActionMockRecorder) Execute(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call
Execute indicates an expected call of Execute.
func (*MockActionMockRecorder) Marshal ¶
func (mr *MockActionMockRecorder) Marshal(arg0 interface{}) *gomock.Call
Marshal indicates an expected call of Marshal.
func (*MockActionMockRecorder) MaxUnits ¶
func (mr *MockActionMockRecorder) MaxUnits(arg0 interface{}) *gomock.Call
MaxUnits indicates an expected call of MaxUnits.
func (*MockActionMockRecorder) StateKeys ¶
func (mr *MockActionMockRecorder) StateKeys(arg0 interface{}) *gomock.Call
StateKeys indicates an expected call of StateKeys.
func (*MockActionMockRecorder) ValidRange ¶
func (mr *MockActionMockRecorder) ValidRange(arg0 interface{}) *gomock.Call
ValidRange indicates an expected call of ValidRange.
type MockAuth ¶
type MockAuth struct {
// contains filtered or unexported fields
}
MockAuth is a mock of Auth interface.
func NewMockAuth ¶
func NewMockAuth(ctrl *gomock.Controller) *MockAuth
NewMockAuth creates a new mock instance.
func (*MockAuth) AsyncVerify ¶
AsyncVerify mocks base method.
func (*MockAuth) EXPECT ¶
func (m *MockAuth) EXPECT() *MockAuthMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockAuth) ValidRange ¶
ValidRange mocks base method.
type MockAuthFactory ¶
type MockAuthFactory struct {
// contains filtered or unexported fields
}
MockAuthFactory is a mock of AuthFactory interface.
func NewMockAuthFactory ¶
func NewMockAuthFactory(ctrl *gomock.Controller) *MockAuthFactory
NewMockAuthFactory creates a new mock instance.
func (*MockAuthFactory) EXPECT ¶
func (m *MockAuthFactory) EXPECT() *MockAuthFactoryMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockAuthFactoryMockRecorder ¶
type MockAuthFactoryMockRecorder struct {
// contains filtered or unexported fields
}
MockAuthFactoryMockRecorder is the mock recorder for MockAuthFactory.
func (*MockAuthFactoryMockRecorder) Sign ¶
func (mr *MockAuthFactoryMockRecorder) Sign(arg0, arg1 interface{}) *gomock.Call
Sign indicates an expected call of Sign.
type MockAuthMockRecorder ¶
type MockAuthMockRecorder struct {
// contains filtered or unexported fields
}
MockAuthMockRecorder is the mock recorder for MockAuth.
func (*MockAuthMockRecorder) AsyncVerify ¶
func (mr *MockAuthMockRecorder) AsyncVerify(arg0 interface{}) *gomock.Call
AsyncVerify indicates an expected call of AsyncVerify.
func (*MockAuthMockRecorder) CanDeduct ¶
func (mr *MockAuthMockRecorder) CanDeduct(arg0, arg1, arg2 interface{}) *gomock.Call
CanDeduct indicates an expected call of CanDeduct.
func (*MockAuthMockRecorder) Deduct ¶
func (mr *MockAuthMockRecorder) Deduct(arg0, arg1, arg2 interface{}) *gomock.Call
Deduct indicates an expected call of Deduct.
func (*MockAuthMockRecorder) Marshal ¶
func (mr *MockAuthMockRecorder) Marshal(arg0 interface{}) *gomock.Call
Marshal indicates an expected call of Marshal.
func (*MockAuthMockRecorder) MaxUnits ¶
func (mr *MockAuthMockRecorder) MaxUnits(arg0 interface{}) *gomock.Call
MaxUnits indicates an expected call of MaxUnits.
func (*MockAuthMockRecorder) Payer ¶
func (mr *MockAuthMockRecorder) Payer() *gomock.Call
Payer indicates an expected call of Payer.
func (*MockAuthMockRecorder) Refund ¶
func (mr *MockAuthMockRecorder) Refund(arg0, arg1, arg2 interface{}) *gomock.Call
Refund indicates an expected call of Refund.
func (*MockAuthMockRecorder) StateKeys ¶
func (mr *MockAuthMockRecorder) StateKeys() *gomock.Call
StateKeys indicates an expected call of StateKeys.
func (*MockAuthMockRecorder) ValidRange ¶
func (mr *MockAuthMockRecorder) ValidRange(arg0 interface{}) *gomock.Call
ValidRange indicates an expected call of ValidRange.
func (*MockAuthMockRecorder) Verify ¶
func (mr *MockAuthMockRecorder) Verify(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
Verify indicates an expected call of Verify.
type MockRules ¶
type MockRules struct {
// contains filtered or unexported fields
}
MockRules is a mock of Rules interface.
func NewMockRules ¶
func NewMockRules(ctrl *gomock.Controller) *MockRules
NewMockRules creates a new mock instance.
func (*MockRules) EXPECT ¶
func (m *MockRules) EXPECT() *MockRulesMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockRules) FetchCustom ¶
FetchCustom mocks base method.
func (*MockRules) GetBaseUnits ¶
GetBaseUnits mocks base method.
func (*MockRules) GetBlockCostChangeDenominator ¶
GetBlockCostChangeDenominator mocks base method.
func (*MockRules) GetChainID ¶
GetChainID mocks base method.
func (*MockRules) GetMaxBlockTxs ¶
GetMaxBlockTxs mocks base method.
func (*MockRules) GetMaxBlockUnits ¶
GetMaxBlockUnits mocks base method.
func (*MockRules) GetMinBlockCost ¶
GetMinBlockCost mocks base method.
func (*MockRules) GetMinUnitPrice ¶
GetMinUnitPrice mocks base method.
func (*MockRules) GetUnitPriceChangeDenominator ¶
GetUnitPriceChangeDenominator mocks base method.
func (*MockRules) GetValidityWindow ¶
GetValidityWindow mocks base method.
func (*MockRules) GetWindowTargetBlocks ¶
GetWindowTargetBlocks mocks base method.
func (*MockRules) GetWindowTargetUnits ¶
GetWindowTargetUnits mocks base method.
type MockRulesMockRecorder ¶
type MockRulesMockRecorder struct {
// contains filtered or unexported fields
}
MockRulesMockRecorder is the mock recorder for MockRules.
func (*MockRulesMockRecorder) FetchCustom ¶
func (mr *MockRulesMockRecorder) FetchCustom(arg0 interface{}) *gomock.Call
FetchCustom indicates an expected call of FetchCustom.
func (*MockRulesMockRecorder) GetBaseUnits ¶
func (mr *MockRulesMockRecorder) GetBaseUnits() *gomock.Call
GetBaseUnits indicates an expected call of GetBaseUnits.
func (*MockRulesMockRecorder) GetBlockCostChangeDenominator ¶
func (mr *MockRulesMockRecorder) GetBlockCostChangeDenominator() *gomock.Call
GetBlockCostChangeDenominator indicates an expected call of GetBlockCostChangeDenominator.
func (*MockRulesMockRecorder) GetChainID ¶
func (mr *MockRulesMockRecorder) GetChainID() *gomock.Call
GetChainID indicates an expected call of GetChainID.
func (*MockRulesMockRecorder) GetMaxBlockTxs ¶
func (mr *MockRulesMockRecorder) GetMaxBlockTxs() *gomock.Call
GetMaxBlockTxs indicates an expected call of GetMaxBlockTxs.
func (*MockRulesMockRecorder) GetMaxBlockUnits ¶
func (mr *MockRulesMockRecorder) GetMaxBlockUnits() *gomock.Call
GetMaxBlockUnits indicates an expected call of GetMaxBlockUnits.
func (*MockRulesMockRecorder) GetMinBlockCost ¶
func (mr *MockRulesMockRecorder) GetMinBlockCost() *gomock.Call
GetMinBlockCost indicates an expected call of GetMinBlockCost.
func (*MockRulesMockRecorder) GetMinUnitPrice ¶
func (mr *MockRulesMockRecorder) GetMinUnitPrice() *gomock.Call
GetMinUnitPrice indicates an expected call of GetMinUnitPrice.
func (*MockRulesMockRecorder) GetUnitPriceChangeDenominator ¶
func (mr *MockRulesMockRecorder) GetUnitPriceChangeDenominator() *gomock.Call
GetUnitPriceChangeDenominator indicates an expected call of GetUnitPriceChangeDenominator.
func (*MockRulesMockRecorder) GetValidityWindow ¶
func (mr *MockRulesMockRecorder) GetValidityWindow() *gomock.Call
GetValidityWindow indicates an expected call of GetValidityWindow.
func (*MockRulesMockRecorder) GetWindowTargetBlocks ¶
func (mr *MockRulesMockRecorder) GetWindowTargetBlocks() *gomock.Call
GetWindowTargetBlocks indicates an expected call of GetWindowTargetBlocks.
func (*MockRulesMockRecorder) GetWindowTargetUnits ¶
func (mr *MockRulesMockRecorder) GetWindowTargetUnits() *gomock.Call
GetWindowTargetUnits indicates an expected call of GetWindowTargetUnits.
type Parser ¶
type Parser interface { Rules(int64) Rules Registry() (ActionRegistry, AuthRegistry) }
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
func NewProcessor ¶
func NewProcessor(tracer trace.Tracer, b *StatelessBlock) *Processor
Only prepare for population if above last accepted height
type Result ¶
func UnmarshalResults ¶
type Rules ¶
type Rules interface { GetChainID() ids.ID GetMaxBlockTxs() int GetMaxBlockUnits() uint64 // should ensure can't get above block max size GetValidityWindow() int64 GetBaseUnits() uint64 GetMinUnitPrice() uint64 GetUnitPriceChangeDenominator() uint64 GetWindowTargetUnits() uint64 GetMinBlockCost() uint64 GetBlockCostChangeDenominator() uint64 GetWindowTargetBlocks() uint64 FetchCustom(string) (any, bool) }
type StatefulBlock ¶
type StatefulBlock struct { Prnt ids.ID `json:"parent"` Tmstmp int64 `json:"timestamp"` Hght uint64 `json:"height"` UnitPrice uint64 `json:"unitPrice"` UnitWindow window.Window `json:"unitWindow"` BlockCost uint64 `json:"blockCost"` BlockWindow window.Window `json:"blockWindow"` Txs []*Transaction `json:"txs"` StateRoot ids.ID `json:"stateRoot"` UnitsConsumed uint64 `json:"unitsConsumed"` SurplusFee uint64 `json:"surplusFee"` }
func NewGenesisBlock ¶
func NewGenesisBlock(root ids.ID, minUnit uint64, minBlock uint64) *StatefulBlock
func UnmarshalBlock ¶
func UnmarshalBlock(raw []byte, parser Parser) (*StatefulBlock, error)
func (*StatefulBlock) Marshal ¶
func (b *StatefulBlock) Marshal( actionRegistry ActionRegistry, authRegistry AuthRegistry, ) ([]byte, error)
type StatelessBlock ¶
type StatelessBlock struct { *StatefulBlock `json:"block"` // contains filtered or unexported fields }
Stateless is defined separately from "Block" in case external packages needs use the stateful block without mocking VM or parent block
func NewBlock ¶
func NewBlock(ectx *ExecutionContext, vm VM, parent snowman.Block, tmstp int64) *StatelessBlock
func ParseBlock ¶
func ParseStatefulBlock ¶
func ParseStatefulBlock( ctx context.Context, blk *StatefulBlock, source []byte, status choices.Status, vm VM, ) (*StatelessBlock, error)
func (*StatelessBlock) Accept ¶
func (b *StatelessBlock) Accept(ctx context.Context) error
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) GetTimestamp ¶
func (b *StatelessBlock) GetTimestamp() int64
func (*StatelessBlock) GetTxs ¶
func (b *StatelessBlock) GetTxs() []*Transaction
func (*StatelessBlock) GetUnitPrice ¶
func (b *StatelessBlock) GetUnitPrice() uint64
func (*StatelessBlock) ID ¶
func (b *StatelessBlock) ID() ids.ID
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) IsRepeat ¶
func (b *StatelessBlock) IsRepeat( ctx context.Context, oldestAllowed int64, txs []*Transaction, ) (bool, error)
func (*StatelessBlock) Processed ¶
func (b *StatelessBlock) Processed() bool
Used to determine if should notify listeners and/or pass to controller
func (*StatelessBlock) Reject ¶
func (b *StatelessBlock) Reject(ctx context.Context) error
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) Results ¶
func (b *StatelessBlock) Results() []*Result
func (*StatelessBlock) SetLastAccepted ¶
func (b *StatelessBlock) SetLastAccepted(ctx context.Context) error
SetLastAccepted is called during [Accept] and at the start and end of state sync.
func (*StatelessBlock) State ¶
func (b *StatelessBlock) State() (Database, error)
State is used to verify txs in the mempool. It should never be written to.
TODO: we should modify the interface here to only allow read-like messages
func (*StatelessBlock) Status ¶
func (b *StatelessBlock) Status() choices.Status
implements "snowman.Block.choices.Decidable"
func (*StatelessBlock) Timestamp ¶
func (b *StatelessBlock) Timestamp() time.Time
implements "snowman.Block"
type SyncableBlock ¶
type SyncableBlock struct {
*StatelessBlock
}
func NewSyncableBlock ¶
func NewSyncableBlock(sb *StatelessBlock) *SyncableBlock
func (*SyncableBlock) Accept ¶
func (sb *SyncableBlock) Accept(ctx context.Context) (block.StateSyncMode, error)
func (*SyncableBlock) String ¶
func (sb *SyncableBlock) String() string
type Transaction ¶
type Transaction struct { Base *Base `json:"base"` Action Action `json:"action"` Auth Auth `json:"auth"` // contains filtered or unexported fields }
func NewTx ¶
func NewTx(base *Base, act Action) *Transaction
func UnmarshalTx ¶
func UnmarshalTx( p *codec.Packer, actionRegistry *codec.TypeParser[Action], authRegistry *codec.TypeParser[Auth], ) (*Transaction, error)
func UnmarshalTxs ¶
func UnmarshalTxs( raw []byte, maxCount int, actionRegistry ActionRegistry, authRegistry AuthRegistry, ) ([]*Transaction, error)
func (*Transaction) Bytes ¶
func (t *Transaction) Bytes() []byte
func (*Transaction) Digest ¶
func (t *Transaction) Digest() ([]byte, error)
func (*Transaction) Execute ¶
func (t *Transaction) Execute( ctx context.Context, r Rules, tdb *tstate.TState, timestamp int64, ) (*Result, error)
Execute after knowing a transaction can pay a fee
func (*Transaction) Expiry ¶
func (t *Transaction) Expiry() int64
func (*Transaction) ID ¶
func (t *Transaction) ID() ids.ID
func (*Transaction) Init ¶
func (t *Transaction) Init( _ context.Context, actionRegistry ActionRegistry, authRegistry AuthRegistry, ) (func() error, error)
func (*Transaction) Marshal ¶
func (t *Transaction) Marshal( p *codec.Packer, actionRegistry *codec.TypeParser[Action], authRegistry *codec.TypeParser[Auth], ) error
func (*Transaction) MaxUnits ¶
func (t *Transaction) MaxUnits(r Rules) uint64
Units is charged whether or not a transaction is successful because state lookup is not free.
func (*Transaction) PreExecute ¶
func (t *Transaction) PreExecute( ctx context.Context, ectx *ExecutionContext, r Rules, db Database, timestamp int64, ) error
PreExecute must not modify state
func (*Transaction) Sign ¶
func (t *Transaction) Sign(factory AuthFactory) error
func (*Transaction) Size ¶
func (t *Transaction) Size() uint64
func (*Transaction) StateKeys ¶
func (t *Transaction) StateKeys() [][]byte
It is ok to have duplicate ReadKeys...the processor will skip them
func (*Transaction) UnitPrice ¶
func (t *Transaction) UnitPrice() uint64
type VM ¶
type VM interface { Parser HRP() string Workers() *workers.Workers Tracer() trace.Tracer Logger() logging.Logger IsBootstrapped() bool LastAcceptedBlock() *StatelessBlock SetLastAccepted(*StatelessBlock) error GetStatelessBlock(context.Context, ids.ID) (*StatelessBlock, error) State() (*merkledb.Database, error) Mempool() Mempool IsRepeat(context.Context, []*Transaction) bool Verified(context.Context, *StatelessBlock) Rejected(context.Context, *StatelessBlock) Accepted(context.Context, *StatelessBlock) AcceptedSyncableBlock(context.Context, *SyncableBlock) (block.StateSyncMode, error) // UpdateSyncTarget returns a bool that is true if the root // was updated and the sync is continuing with the new specified root // and false if the sync completed with the previous root. UpdateSyncTarget(*StatelessBlock) (bool, error) StateReady() bool }