Documentation ¶
Index ¶
- Variables
- func VerifyIdentity(data []byte, att *common.AttestationReport) error
- type AttestationProvider
- type BatchExecutionContext
- type BatchExecutor
- type BatchRegistry
- type BlockIngestionType
- type ComputedBatch
- type DummyAttestationProvider
- type EgoAttestationProvider
- type IDData
- type L1BlockProcessor
- type RollupCompression
- type RollupConsumer
- type RollupProducer
- type SharedSecretProcessor
- type SignatureValidator
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateRollup = errors.New("duplicate rollup received")
var ErrNoTransactionsToProcess = fmt.Errorf("no transactions to process")
Functions ¶
func VerifyIdentity ¶
func VerifyIdentity(data []byte, att *common.AttestationReport) error
Types ¶
type AttestationProvider ¶
type AttestationProvider interface { // GetReport returns the verifiable attestation report GetReport(ctx context.Context, pubKey []byte, enclaveID gethcommon.Address, hostAddress string) (*common.AttestationReport, error) // VerifyReport returns the embedded report data VerifyReport(att *common.AttestationReport) ([]byte, error) }
type BatchExecutionContext ¶
type BatchExecutionContext struct { BlockPtr common.L1BlockHash // Block is needed for the cross chain messages ParentPtr common.L2BatchHash Transactions common.L2Transactions AtTime uint64 Creator gethcommon.Address ChainConfig *params.ChainConfig SequencerNo *big.Int BaseFee *big.Int }
BatchExecutionContext - Contains all of the data that each batch depends on
type BatchExecutor ¶
type BatchExecutor interface { // ComputeBatch - a more primitive ExecuteBatch // Call with same BatchContext should always produce identical extBatch - idempotent // Should be safe to call in parallel // failForEmptyBatch bool is used to skip batch production ComputeBatch(ctx context.Context, batchContext *BatchExecutionContext, failForEmptyBatch bool) (*ComputedBatch, error) // ExecuteBatch - executes the transactions and xchain messages, returns the receipts, and updates the stateDB ExecuteBatch(context.Context, *core.Batch) (types.Receipts, error) // CreateGenesisState - will create and commit the genesis state in the stateDB for the given block hash, // and uint64 timestamp representing the time now. In this genesis state is where one can // find preallocated funds for faucet. TODO - make this an option CreateGenesisState(context.Context, common.L1BlockHash, uint64, gethcommon.Address, *big.Int) (*core.Batch, *types.Transaction, error) }
func NewBatchExecutor ¶
func NewBatchExecutor( storage storage.Storage, batchRegistry BatchRegistry, config config.EnclaveConfig, gethEncodingService gethencoding.EncodingService, cc *crosschain.Processors, genesis *genesis.Genesis, gasOracle gas.Oracle, chainConfig *params.ChainConfig, batchGasLimit uint64, logger gethlog.Logger, ) BatchExecutor
type BatchRegistry ¶
type BatchRegistry interface { // BatchesAfter - Given a hash, will return batches following it until the head batch and the l1 blocks referenced by those batches BatchesAfter(ctx context.Context, batchSeqNo uint64, upToL1Height uint64, rollupLimiter limiters.RollupLimiter) ([]*core.Batch, []*types.Block, error) // GetBatchStateAtHeight - creates a stateDB for the block number GetBatchStateAtHeight(ctx context.Context, blockNumber *gethrpc.BlockNumber) (*state.StateDB, error) // GetBatchState - creates a stateDB for the block hash GetBatchState(ctx context.Context, hash *common.L2BatchHash) (*state.StateDB, error) // GetBatchAtHeight - same as `GetBatchStateAtHeight`, but instead returns the full batch // rather than its stateDB only. GetBatchAtHeight(ctx context.Context, height gethrpc.BlockNumber) (*core.Batch, error) // SubscribeForExecutedBatches - register a callback for new batches SubscribeForExecutedBatches(func(*core.Batch, types.Receipts)) UnsubscribeFromBatches() OnBatchExecuted(batch *core.Batch, receipts types.Receipts) OnL1Reorg(*BlockIngestionType) // HasGenesisBatch - returns if genesis batch is available yet or not, or error in case // the function is unable to determine. HasGenesisBatch() (bool, error) HeadBatchSeq() *big.Int HealthCheck() (bool, error) }
func NewBatchRegistry ¶
func NewBatchRegistry(storage storage.Storage, logger gethlog.Logger) BatchRegistry
type BlockIngestionType ¶
type BlockIngestionType struct { // 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 // ChainFork contains information about the status of the new block in the chain ChainFork *common.ChainFork }
func (*BlockIngestionType) IsFork ¶
func (bit *BlockIngestionType) IsFork() bool
type ComputedBatch ¶
type ComputedBatch struct { Batch *core.Batch Receipts types.Receipts Commit func(bool) (gethcommon.Hash, error) }
ComputedBatch - a structure representing the result of a batch computation where `Batch` is the newly computed batch and `Receipts` are the receipts for the executed transactions inside this batch. The `Commit` function allows for committing the stateDB resulting from the computation of the batch. One might not want to commit in case the resulting batch differs than what is being validated for example.
type DummyAttestationProvider ¶
type DummyAttestationProvider struct{}
func (*DummyAttestationProvider) GetReport ¶
func (e *DummyAttestationProvider) GetReport(ctx context.Context, pubKey []byte, enclaveID gethcommon.Address, hostAddress string) (*common.AttestationReport, error)
func (*DummyAttestationProvider) VerifyReport ¶
func (e *DummyAttestationProvider) VerifyReport(att *common.AttestationReport) ([]byte, error)
type EgoAttestationProvider ¶
type EgoAttestationProvider struct{}
func (*EgoAttestationProvider) GetReport ¶
func (e *EgoAttestationProvider) GetReport(ctx context.Context, pubKey []byte, enclaveID gethcommon.Address, hostAddress string) (*common.AttestationReport, error)
func (*EgoAttestationProvider) VerifyReport ¶
func (e *EgoAttestationProvider) VerifyReport(att *common.AttestationReport) ([]byte, error)
todo (#1059) - we need to verify the hash is a recognized enclave - figure out how we solve for upgradability
type L1BlockProcessor ¶
type L1BlockProcessor interface { Process(ctx context.Context, br *common.BlockAndReceipts) (*BlockIngestionType, error) GetHead(context.Context) (*common.L1Block, error) GetCrossChainContractAddress() *gethcommon.Address HealthCheck() (bool, error) }
func NewBlockProcessor ¶
func NewBlockProcessor(storage storage.Storage, cc *crosschain.Processors, gasOracle gas.Oracle, logger gethlog.Logger) L1BlockProcessor
type RollupCompression ¶
type RollupCompression struct {
// contains filtered or unexported fields
}
RollupCompression - responsible for the compression logic
## Problem The main overhead (after the tx payloads), are the batch headers.
## Requirements: 1. recreate the exact batch headers as the live ones 2. security - make sure it all chains up cryptographically, so it can't be gamed
## Solution elements: 1. Add another compressed and encrypted metadata blob to the ExtRollup. This is the "CalldataRollupHeader". It will also be published as calldata, together with the transactions. The role of this header is to contain the bare minimum information required to recreate the batches. 2. Use implicit position information, deltas, and exceptions to minimise size. Eg. If the time between 2 batches is always 1second, there is no need to store any extra information. 3. To avoid storing hashes, which don't compress at all, we execute each batch to be able to populate the parent hash. 4. The Signatures over the batches are not stored, since the rollup is itself signed. 5. The cross chain messages are calculated.
func NewRollupCompression ¶
func NewRollupCompression( batchRegistry BatchRegistry, batchExecutor BatchExecutor, dataEncryptionService crypto.DataEncryptionService, dataCompressionService compression.DataCompressionService, storage storage.Storage, gethEncodingService gethencoding.EncodingService, chainConfig *params.ChainConfig, logger gethlog.Logger, ) *RollupCompression
func (*RollupCompression) CreateExtRollup ¶
func (rc *RollupCompression) CreateExtRollup(ctx context.Context, r *core.Rollup) (*common.ExtRollup, error)
CreateExtRollup - creates a compressed and encrypted External rollup from the internal data structure
func (*RollupCompression) ProcessExtRollup ¶
func (rc *RollupCompression) ProcessExtRollup(ctx context.Context, rollup *common.ExtRollup) (*common.CalldataRollupHeader, error)
ProcessExtRollup - given an External rollup, responsible with checking and saving all batches found inside
type RollupConsumer ¶
type RollupConsumer interface { // ProcessRollupsInBlock - extracts the rollup from the block's transactions // and verifies its integrity, saving and processing any batches that have // not been seen previously. ProcessRollupsInBlock(ctx context.Context, b *common.BlockAndReceipts) error }
func NewRollupConsumer ¶
func NewRollupConsumer( mgmtContractLib mgmtcontractlib.MgmtContractLib, batchRegistry BatchRegistry, rollupCompression *RollupCompression, storage storage.Storage, logger gethlog.Logger, verifier *SignatureValidator, ) RollupConsumer
type RollupProducer ¶
type RollupProducer interface { // CreateInternalRollup - creates a rollup starting from the end of the last rollup that has been stored on the L1 CreateInternalRollup(ctx context.Context, fromBatchNo uint64, upToL1Height uint64, limiter limiters.RollupLimiter) (*core.Rollup, error) }
func NewRollupProducer ¶
func NewRollupProducer(enclaveID gethcommon.Address, storage storage.Storage, batchRegistry BatchRegistry, logger gethlog.Logger) RollupProducer
type SharedSecretProcessor ¶
type SharedSecretProcessor struct {
// contains filtered or unexported fields
}
func NewSharedSecretProcessor ¶
func NewSharedSecretProcessor(mgmtcontractlib mgmtcontractlib.MgmtContractLib, attestationProvider AttestationProvider, enclaveID gethcommon.Address, storage storage.Storage, logger gethlog.Logger) *SharedSecretProcessor
func (*SharedSecretProcessor) ProcessNetworkSecretMsgs ¶
func (ssp *SharedSecretProcessor) ProcessNetworkSecretMsgs(ctx context.Context, br *common.BlockAndReceipts) []*common.ProducedSecretResponse
ProcessNetworkSecretMsgs we watch for all messages that are requesting or receiving the secret and we store the nodes attested keys
type SignatureValidator ¶
type SignatureValidator struct {
// contains filtered or unexported fields
}
func NewSignatureValidator ¶
func NewSignatureValidator(storage storage.Storage) (*SignatureValidator, error)
func (*SignatureValidator) CheckSequencerSignature ¶
func (sigChecker *SignatureValidator) CheckSequencerSignature(_ gethcommon.Hash, sig []byte) error
CheckSequencerSignature - verifies the signature against the registered sequencer