cchainvm

package
v1.9.9-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: BSD-3-Clause Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapDatabase

func WrapDatabase(db database.Database) ethdb.Database

WrapDatabase creates a new database wrapper

Types

type BatchWrapper

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

BatchWrapper wraps a Lux batch to implement ethdb.Batch

func (*BatchWrapper) Delete

func (b *BatchWrapper) Delete(key []byte) error

Delete removes the key from the batch

func (*BatchWrapper) DeleteRange

func (b *BatchWrapper) DeleteRange(start, end []byte) error

DeleteRange removes the key range from the batch

func (*BatchWrapper) Put

func (b *BatchWrapper) Put(key []byte, value []byte) error

Put inserts the given value into the batch

func (*BatchWrapper) Replay

func (b *BatchWrapper) Replay(w ethdb.KeyValueWriter) error

Replay replays the batch contents to the given writer

func (*BatchWrapper) Reset

func (b *BatchWrapper) Reset()

Reset resets the batch for reuse

func (*BatchWrapper) ValueSize

func (b *BatchWrapper) ValueSize() int

ValueSize retrieves the amount of data queued up for writing

func (*BatchWrapper) Write

func (b *BatchWrapper) Write() error

Write flushes any accumulated data to disk

type Block

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

Block wraps an Ethereum block to implement the chain.Block interface

func (*Block) Accept

func (b *Block) Accept(ctx context.Context) error

Accept implements the chain.Block interface

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes implements the chain.Block interface

func (*Block) Height

func (b *Block) Height() uint64

Height implements the chain.Block interface

func (*Block) ID

func (b *Block) ID() ids.ID

ID implements the chain.Block interface

func (*Block) Parent

func (b *Block) Parent() ids.ID

Parent implements the chain.Block interface

func (*Block) Reject

func (b *Block) Reject(ctx context.Context) error

Reject implements the chain.Block interface

func (*Block) Status

func (b *Block) Status() choices.Status

Status implements the chain.Block interface

func (*Block) Timestamp

func (b *Block) Timestamp() time.Time

Timestamp implements the chain.Block interface

func (*Block) Verify

func (b *Block) Verify(ctx context.Context) error

Verify implements the chain.Block interface

type DatabaseWrapper

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

DatabaseWrapper wraps a Lux database to implement ethdb.Database

func (*DatabaseWrapper) Ancient

func (d *DatabaseWrapper) Ancient(kind string, number uint64) ([]byte, error)

Ancient retrieves an ancient binary blob from the append-only immutable files

func (*DatabaseWrapper) AncientDatadir

func (d *DatabaseWrapper) AncientDatadir() (string, error)

AncientDatadir returns the ancient datadir

func (*DatabaseWrapper) AncientRange

func (d *DatabaseWrapper) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error)

AncientRange retrieves multiple items in sequence

func (*DatabaseWrapper) AncientSize

func (d *DatabaseWrapper) AncientSize(kind string) (uint64, error)

AncientSize returns the ancient size of the specified category

func (*DatabaseWrapper) Ancients

func (d *DatabaseWrapper) Ancients() (uint64, error)

Ancients returns the ancient item numbers in the ancient store

func (*DatabaseWrapper) Close

func (d *DatabaseWrapper) Close() error

Close closes the database

func (*DatabaseWrapper) Compact

func (d *DatabaseWrapper) Compact(start []byte, limit []byte) error

Compact flattens the underlying data store for the given key range

func (*DatabaseWrapper) Delete

func (d *DatabaseWrapper) Delete(key []byte) error

Delete removes the key from the key-value data store

func (*DatabaseWrapper) DeleteRange

func (d *DatabaseWrapper) DeleteRange(start, end []byte) error

DeleteRange removes all entries between the given markers

func (*DatabaseWrapper) Get

func (d *DatabaseWrapper) Get(key []byte) ([]byte, error)

Get retrieves the given key if it's present in the key-value data store

func (*DatabaseWrapper) Has

func (d *DatabaseWrapper) Has(key []byte) (bool, error)

Has retrieves if a key is present in the key-value data store

func (*DatabaseWrapper) MigrateTable

func (d *DatabaseWrapper) MigrateTable(string, func([]byte) ([]byte, error)) error

MigrateTable processes and migrates entries of a given table to a new format

func (*DatabaseWrapper) ModifyAncients

func (d *DatabaseWrapper) ModifyAncients(fn func(ethdb.AncientWriteOp) error) (int64, error)

ModifyAncients runs a write operation on the ancient store

func (*DatabaseWrapper) NewBatch

func (d *DatabaseWrapper) NewBatch() ethdb.Batch

NewBatch creates a write-only database that buffers changes to its host db

func (*DatabaseWrapper) NewBatchWithSize

func (d *DatabaseWrapper) NewBatchWithSize(size int) ethdb.Batch

NewBatchWithSize creates a write-only database batch with a specified size

func (*DatabaseWrapper) NewIterator

func (d *DatabaseWrapper) NewIterator(prefix []byte, start []byte) ethdb.Iterator

NewIterator creates a binary-alphabetical iterator over a subset

func (*DatabaseWrapper) Put

func (d *DatabaseWrapper) Put(key []byte, value []byte) error

Put inserts the given value into the key-value data store

func (*DatabaseWrapper) ReadAncients

func (d *DatabaseWrapper) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error)

ReadAncients applies the provided AncientReader function

func (*DatabaseWrapper) Stat

func (d *DatabaseWrapper) Stat() (string, error)

Stat returns a particular internal stat of the database

func (*DatabaseWrapper) Sync

func (d *DatabaseWrapper) Sync() error

Sync flushes the database to disk

func (*DatabaseWrapper) SyncAncient

func (d *DatabaseWrapper) SyncAncient() error

SyncAncient syncs the ancient data directory

func (*DatabaseWrapper) SyncKeyValue

func (d *DatabaseWrapper) SyncKeyValue() error

SyncKeyValue ensures that all pending writes are flushed to disk

func (*DatabaseWrapper) Tail

func (d *DatabaseWrapper) Tail() (uint64, error)

Tail returns the number of first stored item in the freezer

func (*DatabaseWrapper) TruncateHead

func (d *DatabaseWrapper) TruncateHead(n uint64) (uint64, error)

TruncateHead discards all but the first n ancient data from the ancient store

func (*DatabaseWrapper) TruncateTail

func (d *DatabaseWrapper) TruncateTail(n uint64) (uint64, error)

TruncateTail discards the first n ancient data from the ancient store

type EthAPI

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

EthAPI provides an Ethereum RPC API

func NewEthAPI

func NewEthAPI(backend *MinimalEthBackend) *EthAPI

NewEthAPI creates a new Ethereum RPC API

func (*EthAPI) BlockNumber

func (api *EthAPI) BlockNumber() (hexutil.Uint64, error)

BlockNumber returns the current block number

func (*EthAPI) ChainId

func (api *EthAPI) ChainId() (*hexutil.Big, error)

ChainId returns the chain ID

func (*EthAPI) EstimateGas

func (api *EthAPI) EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error)

EstimateGas estimates the gas needed for a transaction

func (*EthAPI) GasPrice

func (api *EthAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)

GasPrice returns the current gas price

func (*EthAPI) GetBalance

func (api *EthAPI) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

GetBalance returns the balance of an account

func (*EthAPI) GetBlockByHash

func (api *EthAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the block for the given block hash

func (*EthAPI) GetBlockByNumber

func (api *EthAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the block for the given block number

func (*EthAPI) GetCode

func (api *EthAPI) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetCode returns the code of a contract

func (*EthAPI) GetTransactionByHash

func (api *EthAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error)

GetTransactionByHash returns a transaction by hash

func (*EthAPI) GetTransactionCount

func (api *EthAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)

GetTransactionCount returns the nonce of an account

func (*EthAPI) GetTransactionReceipt

func (api *EthAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

GetTransactionReceipt returns the receipt of a transaction

func (*EthAPI) SendRawTransaction

func (api *EthAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error)

SendRawTransaction sends a raw transaction

type Factory

type Factory struct{}

Factory creates new instances of the C-Chain VM

func (*Factory) New

func (f *Factory) New(log logging.Logger) (interface{}, error)

New creates a new C-Chain VM instance

type IteratorWrapper

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

IteratorWrapper wraps a Lux iterator to implement ethdb.Iterator

func (*IteratorWrapper) Error

func (i *IteratorWrapper) Error() error

Error returns any accumulated error

func (*IteratorWrapper) Key

func (i *IteratorWrapper) Key() []byte

Key returns the key of the current key/value pair

func (*IteratorWrapper) Next

func (i *IteratorWrapper) Next() bool

Next moves the iterator to the next key/value pair

func (*IteratorWrapper) Release

func (i *IteratorWrapper) Release()

Release releases associated resources

func (*IteratorWrapper) Value

func (i *IteratorWrapper) Value() []byte

Value returns the value of the current key/value pair

type MinimalEthBackend

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

MinimalEthBackend provides a minimal Ethereum backend without p2p networking

func NewMigratedBackend

func NewMigratedBackend(db ethdb.Database, migratedHeight uint64) (*MinimalEthBackend, error)

NewMigratedBackend creates a special backend for fully migrated data This completely bypasses genesis initialization

func NewMinimalEthBackend

func NewMinimalEthBackend(db ethdb.Database, config *ethconfig.Config, genesis *gethcore.Genesis) (*MinimalEthBackend, error)

NewMinimalEthBackend creates a new minimal Ethereum backend

func NewMinimalEthBackendForMigration

func NewMinimalEthBackendForMigration(db ethdb.Database, config *ethconfig.Config, genesis *gethcore.Genesis, migratedHeight uint64) (*MinimalEthBackend, error)

NewMinimalEthBackendForMigration creates a backend that loads from migrated data

func (*MinimalEthBackend) APIs

func (b *MinimalEthBackend) APIs() []rpc.API

APIs returns the collection of RPC services the ethereum package offers

func (*MinimalEthBackend) BlockChain

func (b *MinimalEthBackend) BlockChain() *gethcore.BlockChain

BlockChain returns the blockchain

func (*MinimalEthBackend) ChainConfig

func (b *MinimalEthBackend) ChainConfig() *params.ChainConfig

ChainConfig returns the chain configuration

func (*MinimalEthBackend) TxPool

func (b *MinimalEthBackend) TxPool() *txpool.TxPool

TxPool returns the transaction pool

type NetAPI

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

NetAPI provides network RPC API

func (*NetAPI) Listening

func (api *NetAPI) Listening() bool

Listening returns whether the node is listening for network connections

func (*NetAPI) PeerCount

func (api *NetAPI) PeerCount() hexutil.Uint

PeerCount returns the number of connected peers

func (*NetAPI) Version

func (api *NetAPI) Version() string

Version returns the network ID

type RPCTransaction

type RPCTransaction struct {
	BlockHash        *common.Hash      `json:"blockHash"`
	BlockNumber      *hexutil.Big      `json:"blockNumber"`
	From             common.Address    `json:"from"`
	Gas              hexutil.Uint64    `json:"gas"`
	GasPrice         *hexutil.Big      `json:"gasPrice"`
	GasFeeCap        *hexutil.Big      `json:"maxFeePerGas,omitempty"`
	GasTipCap        *hexutil.Big      `json:"maxPriorityFeePerGas,omitempty"`
	Hash             common.Hash       `json:"hash"`
	Input            hexutil.Bytes     `json:"input"`
	Nonce            hexutil.Uint64    `json:"nonce"`
	To               *common.Address   `json:"to"`
	TransactionIndex *hexutil.Uint64   `json:"transactionIndex"`
	Value            *hexutil.Big      `json:"value"`
	Type             hexutil.Uint64    `json:"type"`
	Accesses         *types.AccessList `json:"accessList,omitempty"`
	ChainID          *hexutil.Big      `json:"chainId,omitempty"`
	V                *hexutil.Big      `json:"v"`
	R                *hexutil.Big      `json:"r"`
	S                *hexutil.Big      `json:"s"`
}

RPCTransaction represents a transaction for RPC

type TransactionArgs

type TransactionArgs struct {
	From     *common.Address `json:"from"`
	To       *common.Address `json:"to"`
	Gas      *hexutil.Uint64 `json:"gas"`
	GasPrice *hexutil.Big    `json:"gasPrice"`
	Value    *hexutil.Big    `json:"value"`
	Nonce    *hexutil.Uint64 `json:"nonce"`
	Data     *hexutil.Bytes  `json:"data"`
	Input    *hexutil.Bytes  `json:"input"`
}

TransactionArgs represents the arguments for a transaction

type VM

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

VM implements the C-Chain VM interface using geth

func (*VM) AppGossip

func (vm *VM) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error

AppGossip implements the block.ChainVM interface

func (*VM) AppRequest

func (vm *VM) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

AppRequest implements the block.ChainVM interface

func (*VM) AppRequestFailed

func (vm *VM) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *core.AppError) error

AppRequestFailed implements the block.ChainVM interface

func (*VM) AppResponse

func (vm *VM) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

AppResponse implements the block.ChainVM interface

func (*VM) BuildBlock

func (vm *VM) BuildBlock(ctx context.Context) (chain.Block, error)

BuildBlock implements the block.ChainVM interface

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, version *version.Application) error

Connected implements the block.ChainVM interface

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(ctx context.Context) (map[string]http.Handler, error)

CreateHandlers implements the block.ChainVM interface

func (*VM) CrossChainAppRequest

func (vm *VM) CrossChainAppRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, request []byte) error

CrossChainAppRequest implements the block.ChainVM interface

func (*VM) CrossChainAppRequestFailed

func (vm *VM) CrossChainAppRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, appErr *core.AppError) error

CrossChainAppRequestFailed implements the block.ChainVM interface

func (*VM) CrossChainAppResponse

func (vm *VM) CrossChainAppResponse(ctx context.Context, chainID ids.ID, requestID uint32, response []byte) error

CrossChainAppResponse implements the block.ChainVM interface

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

Disconnected implements the block.ChainVM interface

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, blkID ids.ID) (chain.Block, error)

GetBlock implements the block.ChainVM interface

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

GetBlockIDAtHeight implements the block.ChainVM interface

func (*VM) HealthCheck

func (vm *VM) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck implements the block.ChainVM interface

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtx *consensusNode.Context,
	db database.Database,
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	fxs []*core.Fx,
	appSender core.AppSender,
) error

Initialize implements the block.ChainVM interface

func (*VM) LastAccepted

func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)

LastAccepted implements the block.ChainVM interface

func (*VM) NewHTTPHandler

func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)

NewHTTPHandler implements the block.ChainVM interface

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (chain.Block, error)

ParseBlock implements the block.ChainVM interface

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, blkID ids.ID) error

SetPreference implements the block.ChainVM interface

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state consensusNode.State) error

SetState implements the block.ChainVM interface

func (*VM) Shutdown

func (vm *VM) Shutdown(ctx context.Context) error

Shutdown implements the block.ChainVM interface

func (*VM) Version

func (vm *VM) Version(ctx context.Context) (string, error)

Version implements the block.ChainVM interface

func (*VM) WaitForEvent

func (vm *VM) WaitForEvent(ctx context.Context) (core.Message, error)

WaitForEvent implements the block.ChainVM interface

type Web3API

type Web3API struct{}

Web3API provides web3 RPC API

func (*Web3API) ClientVersion

func (api *Web3API) ClientVersion() string

ClientVersion returns the node client version

func (*Web3API) Sha3

func (api *Web3API) Sha3(input hexutil.Bytes) hexutil.Bytes

Sha3 returns the Keccak-256 hash of the given data

Jump to

Keyboard shortcuts

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