rpc

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: AGPL-3.0 Imports: 35 Imported by: 0

README

All communication to and from Ten is encrypted. This package handles the encryption logic between end users communicating via RPC with the Ten enclave.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateGasExecute added in v0.22.0

func EstimateGasExecute(builder *CallBuilder[CallParamsWithBlock, hexutil.Uint64], rpc *EncryptionManager) error

func EstimateGasValidate added in v0.22.0

func EstimateGasValidate(reqParams []any, builder *CallBuilder[CallParamsWithBlock, hexutil.Uint64], _ *EncryptionManager) error

func ExtractTx

func ExtractTx(txBinary string) (*common.L2Tx, error)

ExtractTx returns the common.L2Tx from the params of an eth_sendRawTransaction request.

func GetBalanceExecute added in v0.22.0

func GetBalanceExecute(builder *CallBuilder[BalanceReq, hexutil.Big], rpc *EncryptionManager) error

func GetBalanceValidate added in v0.22.0

func GetBalanceValidate(reqParams []any, builder *CallBuilder[BalanceReq, hexutil.Big], _ *EncryptionManager) error

func GetCustomQueryValidate added in v0.22.0

func GetLogsExecute added in v0.22.0

func GetLogsExecute(builder *CallBuilder[filters.FilterCriteria, []*types.Log], rpc *EncryptionManager) error

func GetLogsValidate added in v0.22.0

func GetLogsValidate(reqParams []any, builder *CallBuilder[filters.FilterCriteria, []*types.Log], _ *EncryptionManager) error

func GetTransactionCountExecute added in v0.22.0

func GetTransactionCountExecute(builder *CallBuilder[uint64, string], rpc *EncryptionManager) error

func GetTransactionCountValidate added in v0.22.0

func GetTransactionCountValidate(reqParams []any, builder *CallBuilder[uint64, string], rpc *EncryptionManager) error

func GetTransactionExecute added in v0.22.0

func GetTransactionExecute(builder *CallBuilder[gethcommon.Hash, RpcTransaction], rpc *EncryptionManager) error

func GetTransactionReceiptExecute added in v0.22.0

func GetTransactionReceiptExecute(builder *CallBuilder[gethcommon.Hash, types.Receipt], rpc *EncryptionManager) error

func GetTransactionReceiptValidate added in v0.22.0

func GetTransactionReceiptValidate(reqParams []any, builder *CallBuilder[gethcommon.Hash, types.Receipt], _ *EncryptionManager) error

func GetTransactionValidate added in v0.22.0

func GetTransactionValidate(reqParams []any, builder *CallBuilder[gethcommon.Hash, RpcTransaction], _ *EncryptionManager) error

func SubmitTxExecute added in v0.22.0

func SubmitTxExecute(builder *CallBuilder[common.L2Tx, gethcommon.Hash], rpc *EncryptionManager) error

func SubmitTxValidate added in v0.22.0

func SubmitTxValidate(reqParams []any, builder *CallBuilder[common.L2Tx, gethcommon.Hash], _ *EncryptionManager) error

func TenCallExecute added in v0.22.0

func TenCallExecute(builder *CallBuilder[CallParamsWithBlock, string], rpc *EncryptionManager) error

func TenCallValidate added in v0.22.0

func TenCallValidate(reqParams []any, builder *CallBuilder[CallParamsWithBlock, string], _ *EncryptionManager) error

func WithVKEncryption added in v0.22.0

func WithVKEncryption[P any, R any](
	encManager *EncryptionManager,
	encReq []byte,
	validate func([]any, *CallBuilder[P, R], *EncryptionManager) error,
	execute func(*CallBuilder[P, R], *EncryptionManager) error,
) (*responses.EnclaveResponse, common.SystemError)

WithVKEncryption - handles the decryption, VK, and encryption P - the type of the temporary parameter calculated after phase 1 R - the type of the result validate - extract and validate the arguments execute - execute the user call only after authorising. Make sure to return a default value that makes sense in case of NotAuthorised note - authorisation is specific to each call e.g. - "getTransaction" or "getBalance" have to perform authorisation "Ten_call" , "Estimate_Gas" - have to authenticate the "From" - which will be used by the EVM

Types

type BalanceReq added in v0.22.0

type BalanceReq struct {
	Addr  *common.Address
	Block *rpc.BlockNumber
}

type CallBuilder added in v0.22.0

type CallBuilder[P any, R any] struct {
	Param       *P                                 // value calculated during phase 1 to be used during the execution phase
	VK          *vkhandler.AuthenticatedViewingKey // the vk accompanying the request
	From        *gethcommon.Address                // extracted from the request
	Status      ResourceStatus
	ReturnValue *R    // value to be returned to the user, encrypted
	Err         error // error to be returned to the user, encrypted
}

CallBuilder - builder used during processing of an RPC request, which is a multi-step process

type CallParamsWithBlock added in v0.22.0

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

type EncryptionManager

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

EncryptionManager manages the decryption and encryption of enclave comms.

func NewEncryptionManager

func NewEncryptionManager(enclavePrivateKeyECIES *ecies.PrivateKey, storage storage.Storage, registry components.BatchRegistry, processors *crosschain.Processors, service nodetype.NodeType, config *config.EnclaveConfig, oracle gas.Oracle, blockResolver storage.BlockResolver, l1BlockProcessor components.L1BlockProcessor, chain l2chain.ObscuroChain, logger gethlog.Logger) *EncryptionManager

func (*EncryptionManager) DecryptBytes

func (rpc *EncryptionManager) DecryptBytes(encryptedBytes []byte) ([]byte, error)

DecryptBytes decrypts the bytes with the enclave's private key.

type ResourceStatus added in v0.22.0

type ResourceStatus int

ResourceStatus used as Status for the UserRPCRequests

const (
	NotSet        ResourceStatus = iota // after initialisation
	Found                               // the parameters were parsed correctly and a From found
	NotAuthorised                       // not allowed to access the resource
	NotFound                            // resource not found
)

type RpcTransaction added in v0.22.0

type RpcTransaction struct {
	BlockHash        *gethcommon.Hash    `json:"blockHash"`
	BlockNumber      *hexutil.Big        `json:"blockNumber"`
	From             gethcommon.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             gethcommon.Hash     `json:"hash"`
	Input            hexutil.Bytes       `json:"input"`
	Nonce            hexutil.Uint64      `json:"nonce"`
	To               *gethcommon.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"`
}

Lifted from Geth's internal `ethapi` package.

Jump to

Keyboard shortcuts

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