Documentation ¶
Index ¶
- Constants
- Variables
- func ExtractPotentialAddress(hash gethcommon.Hash) *gethcommon.Address
- func MaxInt(x, y uint32) uint32
- func RandomStr(n int) string
- func ShortAddress(address gethcommon.Address) uint64
- func ShortHash(hash gethcommon.Hash) uint64
- func ShortNonce(nonce types.BlockNonce) uint64
- func ValueInWei(tokenAmount *big.Int) *big.Int
- type AttestationReport
- type BatchHeader
- type BatchListingResponse
- type BatchRequest
- type BlockAndReceipts
- type BlockListingResponse
- type BlockSubmissionResponse
- type CalldataRollupHeader
- type ChainFork
- type CrossChainMessage
- type CrossChainMessages
- type Enclave
- type EnclavePublicConfig
- type EnclaveScan
- type EncodedAttestationReport
- type EncodedBatchMsg
- type EncodedBatchRequest
- type EncodedL1Block
- type EncodedRollup
- type EncryptedParamsCall
- type EncryptedParamsEstimateGas
- type EncryptedParamsGetBalance
- type EncryptedParamsGetLogs
- type EncryptedParamsGetStorageAt
- type EncryptedParamsGetTxByHash
- type EncryptedParamsGetTxCount
- type EncryptedParamsGetTxReceipt
- type EncryptedParamsLogSubscription
- type EncryptedParamsSendRawTx
- type EncryptedSharedEnclaveSecret
- type EncryptedSubscriptionLogs
- type EncryptedTransactions
- type EncryptedTx
- type ExtBatch
- type ExtRollup
- type FilterCriteriaJSON
- type FinalityType
- type IDAndEncLog
- type IDAndLog
- type L1Address
- type L1Block
- type L1BlockHash
- type L1Receipt
- type L1Receipts
- type L1Transaction
- type L2Address
- type L2BatchHash
- type L2Receipt
- type L2Receipts
- type L2RollupHash
- type L2Transactions
- type L2Tx
- type L2TxHash
- type Latency
- type LogSubscription
- type NodeType
- type Nonce
- type ObscuroNetworkInfo
- type PrivateCustomQueryListTransactions
- type PrivateQueryResponse
- type ProducedSecretResponse
- type PublicBatch
- type PublicBlock
- type PublicTransaction
- type QueryPagination
- type RollupHeader
- type StateRoot
- type Status
- type StatusCode
- type StreamL2UpdatesResponse
- type SystemError
- type TransactionListingResponse
- type TxHash
- type ValueTransferEvent
- type ValueTransferEvents
Constants ¶
const ( L2GenesisHeight = uint64(0) L1GenesisHeight = uint64(0) L2GenesisSeqNo = uint64(1) // HeightCommittedBlocks is the number of blocks deep a transaction must be to be considered safe from reorganisations. HeightCommittedBlocks = 15 )
Variables ¶
These are the multipliers for ERC20 and native ETH value denominations Example: To get the wei value of an amount in whole tokens, use
new(big.Int).Mul(value, big.NewInt(common.Token))
Functions ¶
func ExtractPotentialAddress ¶
func ExtractPotentialAddress(hash gethcommon.Hash) *gethcommon.Address
ExtractPotentialAddress - given a 32 byte hash , it checks whether it can be an address and extracts that
func ShortAddress ¶
func ShortAddress(address gethcommon.Address) uint64
ShortAddress converts the address to a shorter uint64 for printing.
func ShortHash ¶
func ShortHash(hash gethcommon.Hash) uint64
ShortHash converts the hash to a shorter uint64 for printing.
func ShortNonce ¶
func ShortNonce(nonce types.BlockNonce) uint64
ShortNonce converts the nonce to a shorter uint64 for printing.
Types ¶
type AttestationReport ¶
type AttestationReport struct { Report []byte // the signed bytes of the report which includes some encrypted identifying data PubKey []byte // a public key that can be used to send encrypted data back to the TEE securely (should only be used once Report has been verified) Owner common.Address // address identifying the owner of the TEE which signed this report, can also be verified from the encrypted Report data HostAddress string // the IP address on which the host can be contacted by other Obscuro hosts for peer-to-peer communication }
AttestationReport represents a signed attestation report from a TEE and some metadata about the source of it to verify it
func DecodeAttestation ¶
func DecodeAttestation(encoded EncodedAttestationReport) (*AttestationReport, error)
type BatchHeader ¶
type BatchHeader struct { ParentHash L2BatchHash `json:"parentHash"` Root StateRoot `json:"stateRoot"` TxHash common.Hash `json:"transactionsRoot"` ReceiptHash common.Hash `json:"receiptsRoot"` Number *big.Int `json:"number"` // height of the batch SequencerOrderNo *big.Int `json:"sequencerOrderNo"` // multiple batches can be created with the same height in case of L1 reorgs. The sequencer is responsible for including all of them in the rollups. GasLimit uint64 `json:"gasLimit"` GasUsed uint64 `json:"gasUsed"` Time uint64 `json:"timestamp"` Extra []byte `json:"extraData"` BaseFee *big.Int `json:"baseFee"` Coinbase common.Address `json:"coinbase"` // The custom Obscuro fields. L1Proof L1BlockHash `json:"l1Proof"` // the L1 block used by the enclave to generate the current batch R, S *big.Int // signature values CrossChainMessages []MessageBus.StructsCrossChainMessage `json:"crossChainMessages"` LatestInboundCrossChainHash common.Hash `json:"inboundCrossChainHash"` // The block hash of the latest block that has been scanned for cross chain messages. LatestInboundCrossChainHeight *big.Int `json:"inboundCrossChainHeight"` // The block height of the latest block that has been scanned for cross chain messages. TransfersTree common.Hash `json:"transfersTree"` // This is a merkle tree of all of the outbound value transfers for the MainNet }
BatchHeader is a public / plaintext struct that holds common properties of batches. Making changes to this struct will require GRPC + GRPC Converters regen
func (*BatchHeader) Hash ¶
func (b *BatchHeader) Hash() L2BatchHash
Hash returns the block hash of the header, which is simply the keccak256 hash of its RLP encoding excluding the signature.
func (*BatchHeader) MarshalJSON ¶
func (b *BatchHeader) MarshalJSON() ([]byte, error)
MarshalJSON custom marshals the BatchHeader into a json
func (*BatchHeader) UnmarshalJSON ¶
func (b *BatchHeader) UnmarshalJSON(data []byte) error
type BatchListingResponse ¶
type BatchListingResponse struct { BatchesData []PublicBatch Total uint64 }
type BatchRequest ¶
type BatchRequest struct { Requester string // The address of the requester, used to direct the response FromSeqNo *big.Int // The requester's view of the current head seq no, or nil if they haven't stored any batches. }
BatchRequest is used when requesting a range of batches from a peer.
type BlockAndReceipts ¶
type BlockAndReceipts struct { Block *types.Block ReceiptsMap map[int]*types.Receipt // sparse map with obscuro-relevant receipts in it Receipts *types.Receipts // contains filtered or unexported fields }
BlockAndReceipts - a structure that contains a fuller view of a block. It allows iterating over the successful transactions, using the receipts. The receipts are bundled in the host node and thus verification is performed over their correctness. To work properly, all of the receipts are required, due to rlp encoding pruning some of the information. The receipts must also be in the correct order.
func ParseBlockAndReceipts ¶
func ParseBlockAndReceipts(block *L1Block, receipts *L1Receipts) (*BlockAndReceipts, error)
ParseBlockAndReceipts - will create a container struct that has preprocessed the receipts and verified if they indeed match the receipt root hash in the block.
func (*BlockAndReceipts) SuccessfulTransactions ¶
func (br *BlockAndReceipts) SuccessfulTransactions() *types.Transactions
SuccessfulTransactions - returns slice containing only the transactions that have receipts with successful status.
type BlockListingResponse ¶
type BlockListingResponse struct { BlocksData []PublicBlock Total uint64 }
type BlockSubmissionResponse ¶
type BlockSubmissionResponse struct { ProducedSecretResponses []*ProducedSecretResponse // The responses to any secret requests in the ingested L1 block. RejectError *errutil.BlockRejectError // If block was rejected, contains information about what block to submit next. }
BlockSubmissionResponse is the response sent from the enclave back to the node after ingesting a block
type CalldataRollupHeader ¶
type CalldataRollupHeader struct { FirstBatchSequence *big.Int FirstCanonBatchHeight *big.Int FirstCanonParentHash L2BatchHash Coinbase common.Address BaseFee *big.Int GasLimit uint64 StartTime uint64 BatchTimeDeltas [][]byte // todo - minimize assuming a default of 1 sec and then store only exceptions L1HeightDeltas [][]byte // delta of the block height. Stored as a byte array because rlp can't encode negative numbers ReOrgs [][]byte `rlp:"optional"` // sparse list of reorged headers - non null only for reorgs. }
CalldataRollupHeader contains all information necessary to reconstruct the batches included in the rollup. This data structure is serialised, compressed, and encrypted, before being serialised again in the rollup.
type ChainFork ¶
type ChainFork struct { NewCanonical *types.Block OldCanonical *types.Block CommonAncestor *types.Block CanonicalPath []L1BlockHash NonCanonicalPath []L1BlockHash }
ChainFork - represents the result of walking the chain when processing a fork
type CrossChainMessage ¶
type CrossChainMessage = MessageBus.StructsCrossChainMessage
type CrossChainMessages ¶
type CrossChainMessages = []CrossChainMessage
type Enclave ¶
type Enclave interface { EnclaveScan // Status checks whether the enclave is ready to process requests - only implemented by the RPC layer Status() (Status, SystemError) // Attestation - Produces an attestation report which will be used to request the shared secret from another enclave. Attestation() (*AttestationReport, SystemError) // GenerateSecret - the genesis enclave is responsible with generating the secret entropy GenerateSecret() (EncryptedSharedEnclaveSecret, SystemError) // InitEnclave - initialise an enclave with a seed received by another enclave InitEnclave(secret EncryptedSharedEnclaveSecret) SystemError // SubmitL1Block - Used for the host to submit L1 blocks to the enclave, these may be: // a. historic block - if the enclave is behind and in the process of catching up with the L1 state // b. the latest block published by the L1, to which the enclave should respond with a rollup // It is the responsibility of the host to gossip the returned rollup // For good functioning the caller should always submit blocks ordered by height // submitting a block before receiving ancestors of it, will result in it being ignored SubmitL1Block(block L1Block, receipts L1Receipts, isLatest bool) (*BlockSubmissionResponse, SystemError) // SubmitTx - user transactions SubmitTx(tx EncryptedTx) (*responses.RawTx, SystemError) // SubmitBatch submits a batch received from the sequencer for processing. SubmitBatch(batch *ExtBatch) SystemError // ObsCall - Execute a smart contract to retrieve data. The equivalent of "Eth_call" // Todo - return the result with a block delay. To prevent frontrunning. ObsCall(encryptedParams EncryptedParamsCall) (*responses.Call, SystemError) // GetTransactionCount returns the nonce of the wallet with the given address (encrypted with the acc viewing key) GetTransactionCount(encryptedParams EncryptedParamsGetTxCount) (*responses.TxCount, SystemError) // Stop gracefully stops the enclave Stop() SystemError // GetTransaction returns a transaction in JSON format, encrypted with the viewing key for the transaction's `from` field. GetTransaction(encryptedParams EncryptedParamsGetTxByHash) (*responses.TxByHash, SystemError) // GetTransactionReceipt returns a transaction receipt given its signed hash, or nil if the transaction is unknown GetTransactionReceipt(encryptedParams EncryptedParamsGetTxReceipt) (*responses.TxReceipt, SystemError) // GetBalance returns the balance of the address on the Obscuro network, encrypted with the viewing key for the // address. GetBalance(encryptedParams EncryptedParamsGetBalance) (*responses.Balance, SystemError) // GetCode returns the code stored at the given address in the state for the given rollup hash. GetCode(address gethcommon.Address, rollupHash *gethcommon.Hash) ([]byte, SystemError) // Subscribe adds a log subscription to the enclave under the given ID, provided the request is authenticated // correctly. The events will be populated in the BlockSubmissionResponse. If there is an existing subscription // with the given ID, it is overwritten. Subscribe(id rpc.ID, encryptedParams EncryptedParamsLogSubscription) SystemError // Unsubscribe removes the log subscription with the given ID from the enclave. If there is no subscription with // the given ID, nothing is deleted. Unsubscribe(id rpc.ID) SystemError // StopClient stops the enclave client if one exists - only implemented by the RPC layer StopClient() SystemError // EstimateGas tries to estimate the gas needed to execute a specific transaction based on the pending state. EstimateGas(encryptedParams EncryptedParamsEstimateGas) (*responses.Gas, SystemError) // GetLogs returns all the logs matching the filter. GetLogs(encryptedParams EncryptedParamsGetLogs) (*responses.Logs, SystemError) // HealthCheck returns whether the enclave is in a healthy state HealthCheck() (bool, SystemError) // GetBatch - retrieve a batch if existing within the enclave db. GetBatch(hash L2BatchHash) (*ExtBatch, SystemError) // GetBatchBySeqNo - retrieve batch by sequencer number if it's in the db GetBatchBySeqNo(seqNo uint64) (*ExtBatch, SystemError) // CreateBatch - creates a new head batch extending the previous one for the latest known L1 head if the node is // a sequencer. Will panic otherwise. CreateBatch(skipIfEmpty bool) SystemError // CreateRollup - will create a new rollup by going through the sequencer if the node is a sequencer // or panic otherwise. CreateRollup(fromSeqNo uint64) (*ExtRollup, SystemError) // DebugTraceTransaction returns the trace of a transaction DebugTraceTransaction(hash gethcommon.Hash, config *tracers.TraceConfig) (json.RawMessage, SystemError) // StreamL2Updates - will stream any new batches as they are created/detected // All will be queued in the channel that has been returned. StreamL2Updates() (chan StreamL2UpdatesResponse, func()) // DebugEventLogRelevancy returns the logs of a transaction DebugEventLogRelevancy(hash gethcommon.Hash) (json.RawMessage, SystemError) }
Enclave represents the API of the service that runs inside the TEE.
type EnclavePublicConfig ¶
type EnclavePublicConfig struct {
L2MessageBusAddress gethcommon.Address
}
type EnclaveScan ¶
type EnclaveScan interface { // GetTotalContractCount returns the total number of contracts that have been deployed GetTotalContractCount() (*big.Int, SystemError) // GetCustomQuery returns the data of a custom query GetCustomQuery(encryptedParams EncryptedParamsGetStorageAt) (*responses.PrivateQueryResponse, SystemError) // GetPublicTransactionData returns a list of public transaction data GetPublicTransactionData(pagination *QueryPagination) (*TransactionListingResponse, SystemError) // EnclavePublicConfig returns network data that is known to the enclave but can be shared publicly EnclavePublicConfig() (*EnclavePublicConfig, SystemError) }
EnclaveScan represents the methods that are used for data scanning in the enclave
type EncodedAttestationReport ¶
type EncodedAttestationReport []byte
func EncodeAttestation ¶
func EncodeAttestation(att *AttestationReport) (EncodedAttestationReport, error)
type EncodedBatchMsg ¶
type EncodedBatchMsg []byte
type EncodedBatchRequest ¶
type EncodedBatchRequest []byte
type EncodedL1Block ¶
type EncodedL1Block []byte
EncodedL1Block the encoded version of an L1 block.
func EncodeBlock ¶
func EncodeBlock(b *types.Block) (EncodedL1Block, error)
func (EncodedL1Block) DecodeBlock ¶
func (eb EncodedL1Block) DecodeBlock() (*types.Block, error)
type EncodedRollup ¶
type EncodedRollup []byte
func EncodeRollup ¶
func EncodeRollup(r *ExtRollup) (EncodedRollup, error)
type EncryptedParamsCall ¶
type EncryptedParamsCall []byte // As above, but for an RPC call request.
type EncryptedParamsEstimateGas ¶
type EncryptedParamsEstimateGas []byte // As above, but for an RPC estimateGas request.
type EncryptedParamsGetBalance ¶
type EncryptedParamsGetBalance []byte // The params for an RPC getBalance request, as a JSON object encrypted with the public key of the enclave.
type EncryptedParamsGetLogs ¶
type EncryptedParamsGetLogs []byte // As above, but for an RPC getLogs request.
type EncryptedParamsGetStorageAt ¶
type EncryptedParamsGetStorageAt []byte
type EncryptedParamsGetTxByHash ¶
type EncryptedParamsGetTxByHash []byte // As above, but for an RPC getTransactionByHash request.
type EncryptedParamsGetTxCount ¶
type EncryptedParamsGetTxCount []byte // As above, but for an RPC getTransactionCount request.
type EncryptedParamsGetTxReceipt ¶
type EncryptedParamsGetTxReceipt []byte // As above, but for an RPC getTransactionReceipt request.
type EncryptedParamsLogSubscription ¶
type EncryptedParamsLogSubscription []byte // As above, but for an RPC logs subscription request.
type EncryptedParamsSendRawTx ¶
type EncryptedParamsSendRawTx []byte // As above, but for an RPC sendRawTransaction request.
type EncryptedSharedEnclaveSecret ¶
type EncryptedSharedEnclaveSecret []byte
type EncryptedSubscriptionLogs ¶
EncryptedSubscriptionLogs - Alias for the event subscription updates going out of the enclave.
type EncryptedTransactions ¶
type EncryptedTransactions []byte // A blob of encrypted transactions, as they're stored in the rollup, with the nonce prepended.
type EncryptedTx ¶
type EncryptedTx []byte // A single transaction, encoded as a JSON list of transaction binary hexes and encrypted using the enclave's public key
type ExtBatch ¶
type ExtBatch struct { Header *BatchHeader // todo - remove TxHashes []TxHash // The hashes of the transactions included in the batch. EncryptedTxBlob EncryptedTransactions // contains filtered or unexported fields }
ExtBatch is an encrypted form of batch used when passing the batch around outside of an enclave. todo (#718) - expand this structure to contain the required fields.
func DecodeExtBatch ¶
func (*ExtBatch) Hash ¶
func (b *ExtBatch) Hash() L2BatchHash
Hash returns the keccak256 hash of the batch's header. The hash is computed on the first call and cached thereafter.
type ExtRollup ¶
type ExtRollup struct { Header *RollupHeader // the fields required by the management contract CalldataRollupHeader []byte // encrypted header useful for recreating the batches BatchPayloads []byte // The transactions included in the rollup, in external/encrypted form. // contains filtered or unexported fields }
ExtRollup is an encrypted form of rollup used when passing the rollup around outside an enclave.
func DecodeRollup ¶
func DecodeRollup(encoded EncodedRollup) (*ExtRollup, error)
func (*ExtRollup) Hash ¶
func (r *ExtRollup) Hash() L2RollupHash
Hash returns the keccak256 hash of the rollup's header. The hash is computed on the first call and cached thereafter.
type FilterCriteriaJSON ¶
type FilterCriteriaJSON struct { BlockHash *common.Hash `json:"blockHash"` FromBlock *rpc.BlockNumber `json:"fromBlock"` ToBlock *rpc.BlockNumber `json:"toBlock"` Addresses interface{} `json:"address"` Topics []interface{} `json:"topics"` }
FilterCriteriaJSON is a structure that JSON-serialises to a format that can be successfully deserialised into a filters.FilterCriteria object (round-tripping a filters.FilterCriteria to JSON and back doesn't work, due to a custom serialiser implemented by filters.FilterCriteria).
type FinalityType ¶
type FinalityType string
const ( MempoolPending FinalityType = "Pending" BatchFinal FinalityType = "Final" )
type IDAndEncLog ¶
IDAndEncLog pairs an encrypted log with the ID of the subscription that generated it.
type L1BlockHash ¶
type L1Receipts ¶
type L1Transaction ¶
type L1Transaction = types.Transaction
type L2Receipts ¶
type L2RollupHash ¶
type L2Transactions ¶
type L2Transactions = types.Transactions
type L2Tx ¶
type L2Tx = types.Transaction
type LogSubscription ¶
type LogSubscription struct { // The account the events relate to. Account *common.Address // A signature over the account address using a private viewing key. Prevents attackers from subscribing to // (encrypted) logs for other accounts to see the pattern of logs. // todo - this does not protect against replay attacks, where someone resends an intercepted subscription request. Signature []byte // PublicViewingKey stores the viewing key used for this subscription PublicViewingKey []byte // A subscriber-defined filter to apply to the stream of logs. Filter *filters.FilterCriteria // Handles the viewing key encryption VkHandler *vkhandler.VKHandler }
LogSubscription is an authenticated subscription to logs.
type ObscuroNetworkInfo ¶
type PrivateCustomQueryListTransactions ¶
type PrivateCustomQueryListTransactions struct { Address common.Address `json:"address"` Pagination QueryPagination `json:"pagination"` }
type PrivateQueryResponse ¶
type ProducedSecretResponse ¶
type ProducedSecretResponse struct { Secret []byte RequesterID gethcommon.Address HostAddress string }
ProducedSecretResponse contains the data to publish to L1 in response to a secret request discovered while processing an L1 block
type PublicBatch ¶
type PublicBatch struct { BatchHeader TxHashes []TxHash `json:"txHashes"` }
type PublicBlock ¶
type PublicTransaction ¶
type PublicTransaction struct { TransactionHash TxHash BatchHeight *big.Int Finality FinalityType }
type QueryPagination ¶
func (*QueryPagination) UnmarshalJSON ¶
func (p *QueryPagination) UnmarshalJSON(data []byte) error
type RollupHeader ¶
type RollupHeader struct { Coinbase common.Address CompressionL1Head L1BlockHash // the l1 block that the sequencer considers canonical at the time when this rollup is created CrossChainMessages []MessageBus.StructsCrossChainMessage `json:"crossChainMessages"` PayloadHash common.Hash // The hash of the compressed batches. TODO R, S *big.Int // signature values LastBatchSeqNo uint64 }
RollupHeader is a public / plaintext struct that holds common properties of rollups. All these fields are processed by the Management contract
func (*RollupHeader) Hash ¶
func (r *RollupHeader) Hash() L2RollupHash
Hash returns the block hash of the header, which is simply the keccak256 hash of its RLP encoding excluding the signature.
func (*RollupHeader) MarshalJSON ¶
func (r *RollupHeader) MarshalJSON() ([]byte, error)
MarshalJSON custom marshals the RollupHeader into a json
type Status ¶
type Status struct { StatusCode StatusCode L1Head gethcommon.Hash L2Head *big.Int }
Status represents the enclave's current state - whether the enclave is healthy and ready to process requests, as well as its latest known heads for the L1 and L2 chains
type StatusCode ¶
type StatusCode int
const ( Running StatusCode = iota // the enclave is running, accepting L1 blocks AwaitingSecret // the enclave has not received the network secret and cannot process L1 blocks )
type StreamL2UpdatesResponse ¶
type StreamL2UpdatesResponse struct { Batch *ExtBatch Logs EncryptedSubscriptionLogs }
StreamL2UpdatesResponse - the struct encoded for each response message when streaming batches out of the enclave. The properties inside need to be encrypted according to the privacy rules.
type SystemError ¶
type SystemError interface {
Error() string
}
SystemError is the interface for the internal errors generated in the Enclave and consumed by the Host
type TransactionListingResponse ¶
type TransactionListingResponse struct { TransactionsData []PublicTransaction Total uint64 }
type ValueTransferEvent ¶
type ValueTransferEvents ¶
type ValueTransferEvents = []ValueTransferEvent
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
nolint
|
nolint |
native
// Package native: This file was copied/adapted from geth - go-ethereum/eth/tracers // // // Copyright 2021 The go-ethereum Authors // This file is part of the go-ethereum library.
|
// Package native: This file was copied/adapted from geth - go-ethereum/eth/tracers // // // Copyright 2021 The go-ethereum Authors // This file is part of the go-ethereum library. |