Documentation ¶
Index ¶
- func CreateDBFromConfig(cfg *enclaveconfig.EnclaveConfig, logger gethlog.Logger) (enclavedb.EnclaveDB, error)
- type AttestationStorage
- type BatchResolver
- type BlockResolver
- type CacheService
- func (cs *CacheService) CacheBatch(ctx context.Context, batch *core.Batch)
- func (cs *CacheService) CacheBlock(ctx context.Context, b *types.Header)
- func (cs *CacheService) CacheConvertedHash(ctx context.Context, batchHash, convertedHash gethcommon.Hash)
- func (cs *CacheService) CacheReceipt(ctx context.Context, r *CachedReceipt)
- func (cs *CacheService) ReadBatch(ctx context.Context, seqNum uint64, onCacheMiss func(any) (*core.Batch, error)) (*core.Batch, error)
- func (cs *CacheService) ReadBatchHeader(ctx context.Context, seqNum uint64, ...) (*common.BatchHeader, error)
- func (cs *CacheService) ReadBatchSeqByHash(ctx context.Context, hash common.L2BatchHash, ...) (*big.Int, error)
- func (cs *CacheService) ReadBatchSeqByHeight(ctx context.Context, height uint64, onCacheMiss func(any) (*big.Int, error)) (*big.Int, error)
- func (cs *CacheService) ReadBlock(ctx context.Context, key gethcommon.Hash, ...) (*types.Header, error)
- func (cs *CacheService) ReadContractAddr(ctx context.Context, addr gethcommon.Address, ...) (*enclavedb.Contract, error)
- func (cs *CacheService) ReadConvertedHash(ctx context.Context, hash common.L2BatchHash, ...) (*gethcommon.Hash, error)
- func (cs *CacheService) ReadConvertedHeader(ctx context.Context, batchHash common.L2BatchHash, ...) (*types.Header, error)
- func (cs *CacheService) ReadEOA(ctx context.Context, addr gethcommon.Address, ...) (*uint64, error)
- func (cs *CacheService) ReadEventType(ctx context.Context, contractAddress gethcommon.Address, ...) (*enclavedb.EventType, error)
- func (cs *CacheService) ReadReceipt(ctx context.Context, txHash gethcommon.Hash) (*CachedReceipt, error)
- type CachedReceipt
- type CrossChainMessagesStorage
- type EnclaveKeyStorage
- type GethStateDB
- type ScanStorage
- type SharedSecretStorage
- type Storage
- type TransactionStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDBFromConfig ¶
func CreateDBFromConfig(cfg *enclaveconfig.EnclaveConfig, logger gethlog.Logger) (enclavedb.EnclaveDB, error)
CreateDBFromConfig creates an appropriate ethdb.Database instance based on your config
Types ¶
type AttestationStorage ¶
type AttestationStorage interface { // FetchAttestedKey returns the public key of an attested aggregator FetchAttestedKey(ctx context.Context, aggregator gethcommon.Address) (*ecdsa.PublicKey, error) // StoreAttestedKey - store the public key of an attested aggregator StoreAttestedKey(ctx context.Context, aggregator gethcommon.Address, key *ecdsa.PublicKey) error }
type BatchResolver ¶
type BatchResolver interface { // FetchBatch returns the batch with the given hash. FetchBatch(ctx context.Context, hash common.L2BatchHash) (*core.Batch, error) // FetchBatchHeader returns the batch header with the given hash. FetchBatchHeader(ctx context.Context, hash common.L2BatchHash) (*common.BatchHeader, error) FetchBatchTransactionsBySeq(ctx context.Context, seqNo uint64) ([]*common.L2Tx, error) // FetchBatchByHeight returns the batch on the canonical chain with the given height. FetchBatchByHeight(ctx context.Context, height uint64) (*core.Batch, error) // FetchBatchBySeqNo returns the batch with the given seq number. FetchBatchBySeqNo(ctx context.Context, seqNum uint64) (*core.Batch, error) // FetchBatchHeaderBySeqNo returns the batch header with the given seq number. FetchBatchHeaderBySeqNo(ctx context.Context, seqNum uint64) (*common.BatchHeader, error) FetchHeadBatchHeader(ctx context.Context) (*common.BatchHeader, error) // FetchCurrentSequencerNo returns the sequencer number FetchCurrentSequencerNo(ctx context.Context) (*big.Int, error) // FetchBatchesByBlock returns all batches with the block hash as the L1 proof FetchBatchesByBlock(ctx context.Context, hash common.L1BlockHash) ([]*common.BatchHeader, error) // FetchNonCanonicalBatchesBetween - returns all reorged batches between the sequences FetchNonCanonicalBatchesBetween(ctx context.Context, startSeq uint64, endSeq uint64) ([]*common.BatchHeader, error) // FetchCanonicalBatchesBetween - returns all canon batches between the sequences FetchCanonicalBatchesBetween(ctx context.Context, startSeq uint64, endSeq uint64) ([]*common.BatchHeader, error) // IsBatchCanonical - true if the batch is canonical IsBatchCanonical(ctx context.Context, seq uint64) (bool, error) // FetchCanonicalUnexecutedBatches - return the list of the unexecuted batches that are canonical FetchCanonicalUnexecutedBatches(context.Context, *big.Int) ([]*common.BatchHeader, error) FetchConvertedHash(ctx context.Context, hash common.L2BatchHash) (gethcommon.Hash, error) // BatchWasExecuted - return true if the batch was executed BatchWasExecuted(ctx context.Context, hash common.L2BatchHash) (bool, error) // StoreBatch stores an un-executed batch. StoreBatch(ctx context.Context, batch *core.Batch, convertedHash gethcommon.Hash) error // StoreExecutedBatch - store the batch after it was executed StoreExecutedBatch(ctx context.Context, batch *common.BatchHeader, results []*core.TxExecResult) error // StoreRollup StoreRollup(ctx context.Context, rollup *common.ExtRollup, header *common.CalldataRollupHeader) error FetchRollupMetadata(ctx context.Context, hash common.L2RollupHash) (*common.PublicRollupMetadata, error) FetchReorgedRollup(ctx context.Context, reorgedBlocks []common.L1BlockHash) (*common.L2BatchHash, error) }
type BlockResolver ¶
type BlockResolver interface { // FetchBlock returns the L1 BlockHeader with the given hash. FetchBlock(ctx context.Context, blockHash common.L1BlockHash) (*types.Header, error) IsBlockCanonical(ctx context.Context, blockHash common.L1BlockHash) (bool, error) // FetchCanonicaBlockByHeight - self explanatory FetchCanonicaBlockByHeight(ctx context.Context, height *big.Int) (*types.Header, error) // FetchHeadBlock - returns the head of the current chain. FetchHeadBlock(ctx context.Context) (*types.Header, error) // StoreBlock persists the L1 BlockHeader and updates the canonical ancestors if there was a fork StoreBlock(ctx context.Context, block *types.Header, fork *common.ChainFork) error // IsAncestor returns true if maybeAncestor is an ancestor of the L1 BlockHeader, and false otherwise IsAncestor(ctx context.Context, block *types.Header, maybeAncestor *types.Header) bool // IsBlockAncestor returns true if maybeAncestor is an ancestor of the L1 BlockHeader, and false otherwise // Takes into consideration that the BlockHeader to verify might be on a branch we haven't received yet // todo (low priority) - this is super confusing, analyze the usage IsBlockAncestor(ctx context.Context, block *types.Header, maybeAncestor common.L1BlockHash) bool }
BlockResolver stores new blocks and returns information on existing blocks
type CacheService ¶ added in v0.25.0
type CacheService struct {
// contains filtered or unexported fields
}
func NewCacheService ¶ added in v0.25.0
func NewCacheService(logger gethlog.Logger, testMode bool) *CacheService
func (*CacheService) CacheBatch ¶ added in v0.25.0
func (cs *CacheService) CacheBatch(ctx context.Context, batch *core.Batch)
func (*CacheService) CacheBlock ¶ added in v0.25.0
func (cs *CacheService) CacheBlock(ctx context.Context, b *types.Header)
func (*CacheService) CacheConvertedHash ¶ added in v0.28.0
func (cs *CacheService) CacheConvertedHash(ctx context.Context, batchHash, convertedHash gethcommon.Hash)
func (*CacheService) CacheReceipt ¶ added in v0.28.0
func (cs *CacheService) CacheReceipt(ctx context.Context, r *CachedReceipt)
func (*CacheService) ReadBatchHeader ¶ added in v0.28.0
func (cs *CacheService) ReadBatchHeader(ctx context.Context, seqNum uint64, onCacheMiss func(any) (*common.BatchHeader, error)) (*common.BatchHeader, error)
func (*CacheService) ReadBatchSeqByHash ¶ added in v0.25.0
func (*CacheService) ReadBatchSeqByHeight ¶ added in v0.25.0
func (*CacheService) ReadContractAddr ¶ added in v0.25.0
func (*CacheService) ReadConvertedHash ¶ added in v0.25.0
func (cs *CacheService) ReadConvertedHash(ctx context.Context, hash common.L2BatchHash, onCacheMiss func(any) (*gethcommon.Hash, error)) (*gethcommon.Hash, error)
func (*CacheService) ReadConvertedHeader ¶ added in v0.25.0
func (*CacheService) ReadEOA ¶ added in v0.25.0
func (cs *CacheService) ReadEOA(ctx context.Context, addr gethcommon.Address, onCacheMiss func(any) (*uint64, error)) (*uint64, error)
func (*CacheService) ReadEventType ¶ added in v0.25.0
func (cs *CacheService) ReadEventType(ctx context.Context, contractAddress gethcommon.Address, eventSignature gethcommon.Hash, onCacheMiss func(any) (*enclavedb.EventType, error)) (*enclavedb.EventType, error)
func (*CacheService) ReadReceipt ¶ added in v0.28.0
func (cs *CacheService) ReadReceipt(ctx context.Context, txHash gethcommon.Hash) (*CachedReceipt, error)
type CachedReceipt ¶ added in v0.28.0
type CachedReceipt struct { Receipt *types.Receipt From *gethcommon.Address To *gethcommon.Address }
type CrossChainMessagesStorage ¶
type CrossChainMessagesStorage interface { StoreL1Messages(ctx context.Context, blockHash common.L1BlockHash, messages common.CrossChainMessages) error GetL1Messages(ctx context.Context, blockHash common.L1BlockHash) (common.CrossChainMessages, error) StoreValueTransfers(ctx context.Context, blockHash common.L1BlockHash, transfers common.ValueTransferEvents) error GetL1Transfers(ctx context.Context, blockHash common.L1BlockHash) (common.ValueTransferEvents, error) }
type EnclaveKeyStorage ¶
type EnclaveKeyStorage interface { StoreEnclaveKey(ctx context.Context, enclaveKey *crypto.EnclaveKey) error GetEnclaveKey(ctx context.Context) (*crypto.EnclaveKey, error) }
type GethStateDB ¶
type ScanStorage ¶
type ScanStorage interface { GetContractCount(ctx context.Context) (*big.Int, error) GetTransactionsPerAddress(ctx context.Context, address *gethcommon.Address, pagination *common.QueryPagination) ([]*core.InternalReceipt, error) CountTransactionsPerAddress(ctx context.Context, addr *gethcommon.Address) (uint64, error) }
type SharedSecretStorage ¶
type SharedSecretStorage interface { context.Context) (*crypto.SharedEnclaveSecret, error) StoreSecret(ctx context.Context, secret crypto.SharedEnclaveSecret) error }FetchSecret(ctx
type Storage ¶
type Storage interface { BlockResolver BatchResolver GethStateDB SharedSecretStorage TransactionStorage AttestationStorage CrossChainMessagesStorage EnclaveKeyStorage ScanStorage io.Closer // HealthCheck returns whether the storage is deemed healthy or not HealthCheck(ctx context.Context) (bool, error) // FilterLogs - applies the properties the relevancy checks for the requestingAccount to all the stored log events // nil values will be ignored. Make sure to set all fields to the right values before calling this function // the blockHash should always be nil. FilterLogs(ctx context.Context, requestingAccount *gethcommon.Address, fromBlock, toBlock *big.Int, blockHash *common.L2BatchHash, addresses []gethcommon.Address, topics [][]gethcommon.Hash) ([]*types.Log, error) // DebugGetLogs returns logs for a given tx hash without any constraints - should only be used for debug purposes DebugGetLogs(ctx context.Context, from *big.Int, to *big.Int, address gethcommon.Address, eventSig gethcommon.Hash) ([]*common.DebugLogVisibility, error) // TrieDB - return the underlying trie database TrieDB() *triedb.Database // StateDB - return the underlying state database StateDB() state.Database ReadContract(ctx context.Context, address gethcommon.Address) (*enclavedb.Contract, error) ReadEventType(ctx context.Context, contractAddress gethcommon.Address, eventSignature gethcommon.Hash) (*enclavedb.EventType, error) }
Storage is the enclave's interface for interacting with the enclave's datastore
func NewStorage ¶
func NewStorage(backingDB enclavedb.EnclaveDB, cachingService *CacheService, chainConfig *params.ChainConfig, logger gethlog.Logger) Storage
func NewStorageFromConfig ¶
func NewStorageFromConfig(config *enclaveconfig.EnclaveConfig, cachingService *CacheService, chainConfig *params.ChainConfig, logger gethlog.Logger) Storage
type TransactionStorage ¶
type TransactionStorage interface { // GetTransaction - returns the positional metadata of the tx by hash GetTransaction(ctx context.Context, txHash common.L2TxHash) (*types.Transaction, common.L2BatchHash, uint64, uint64, error) // GetFilteredReceipt - returns the receipt of a tx with event logs visible to the requester GetFilteredInternalReceipt(ctx context.Context, txHash common.L2TxHash, requester *gethcommon.Address, syntheticTx bool) (*core.InternalReceipt, error) ExistsTransactionReceipt(ctx context.Context, txHash common.L2TxHash) (bool, error) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.