l2chain

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: AGPL-3.0 Imports: 30 Imported by: 0

README

This is where the bulk of the Obscuro specific logic is. The entry point is the L2Chain.

Ethereum Blocks and Rollups produced by peers are fed into this datastructure, and it decides which is the canonical chain, it produces rollups, and is able provide information when requested via RPC.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewL1Blockchain

func NewL1Blockchain(genesisJSON []byte, logger gethlog.Logger) *core.BlockChain

NewL1Blockchain creates a Geth BlockChain object. `genesisJSON` is the Genesis block config in JSON format. A Geth node can be made to output this using the `dumpgenesis` startup command.

Types

type BlockIngestionType added in v0.14.0

type BlockIngestionType struct {
	// IsLatest is true if this block was the canonical head of the L1 chain at the time it was submitted to enclave
	// (if false then we are behind and catching up, expect to be fed another block immediately afterwards)
	IsLatest bool

	// Fork is true if the ingested block is on a different branch to previously known head
	// (resulting in rewinding of one or more blocks that we had previously considered canonical)
	Fork bool

	// PreGenesis is true if there is no stored L1 head block.
	// (L1 head is only stored when there is an L2 state to associate it with. Soon we will start consuming from the
	// genesis block and then, we should only see one block ingested in a 'PreGenesis' state)
	PreGenesis bool
}

type ObscuroChain

type ObscuroChain interface {
	// GetBalance - Returns the balance of an address given the standard provided BlockNumber which in our case is batch number.
	// Note this method also returns the address we should encrypt the balance for, unlike `GetBalanceAtBlock`
	GetBalance(accountAddress gethcommon.Address, blockNumber *gethrpc.BlockNumber) (*gethcommon.Address, *hexutil.Big, error)

	// GetBalanceAtBlock - will return the balance of a specific address at the specific given block number (batch number).
	GetBalanceAtBlock(accountAddr gethcommon.Address, blockNumber *gethrpc.BlockNumber) (*hexutil.Big, error)

	// ObsCall - The interface for executing eth_call RPC commands against obscuro.
	ObsCall(apiArgs *gethapi.TransactionArgs, blockNumber *gethrpc.BlockNumber) (*gethcore.ExecutionResult, error)

	// ObsCallAtBlock - Execute eth_call RPC against obscuro for a specific block (batch) number.
	ObsCallAtBlock(apiArgs *gethapi.TransactionArgs, blockNumber *gethrpc.BlockNumber) (*gethcore.ExecutionResult, error)

	// GetChainStateAtTransaction - returns the stateDB after applying all the transactions in the batch leading to the desired transaction.
	GetChainStateAtTransaction(batch *core.Batch, txIndex int, reexec uint64) (gethcore.Message, vm.BlockContext, *state.StateDB, error)
}

ObscuroChain - the interface that provides the data access layer to the obscuro l2. Operations here should be read only.

func NewChain added in v0.14.0

func NewChain(
	storage storage.Storage,
	chainConfig *params.ChainConfig,
	genesis *genesis.Genesis,
	logger gethlog.Logger,
	registry components.BatchRegistry,
) ObscuroChain

Jump to

Keyboard shortcuts

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