evm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: AGPL-3.0 Imports: 29 Imported by: 0

README

TEN executes EVM compatible transactions on top of a database that implements the Go-Ethereum interfaces.

The entry point is the evm_facade.

The approach we took was to depend on Go-Ethereum, mock out all consensus related dependencies, and just use the transaction execution functionality.

Documentation

Index

Constants

View Source
const (
	BalanceDecreaseL1Payment       tracing.BalanceChangeReason = 100
	BalanceIncreaseL1Payment       tracing.BalanceChangeReason = 101
	BalanceRevertDecreaseL1Payment tracing.BalanceChangeReason = 102
	BalanceRevertIncreaseL1Payment tracing.BalanceChangeReason = 103
)

Variables

View Source
var ContractTranspMetaData = &bind.MetaData{
	ABI: "[{\"inputs\":[],\"name\":\"visibilityRules\",\"outputs\":[{\"components\":[{\"internalType\":\"enumContractTransparencyConfig.ContractCfg\",\"name\":\"contractCfg\",\"type\":\"uint8\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"eventSignature\",\"type\":\"bytes32\"},{\"internalType\":\"enumContractTransparencyConfig.Field[]\",\"name\":\"visibleTo\",\"type\":\"uint8[]\"}],\"internalType\":\"structContractTransparencyConfig.EventLogConfig[]\",\"name\":\"eventLogConfigs\",\"type\":\"tuple[]\"}],\"internalType\":\"structContractTransparencyConfig.VisibilityConfig\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}]",
}

ContractTranspMetaData contains all meta data concerning the TransparencyConfig contract.

View Source
var ErrGasNotEnoughForL1 = errors.New("gas limit too low to pay for execution and l1 fees")
View Source
var PoolAddress = common.HexToAddress("0x0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A")

PoolAddress - address of the pool where the gas will go todo (#627) - this has to be reworked when the gas/fee work starts

Functions

func ExecuteCall added in v1.0.0

func ExecuteCall(
	ctx context.Context,
	msg *gethcore.Message,
	s *state.StateDB,
	header *common.BatchHeader,
	storage storage.Storage,
	gethEncodingService gethencoding.EncodingService,
	chainConfig *params.ChainConfig,
	gasEstimationCap uint64,
	config enclaveconfig.EnclaveConfig,
	logger gethlog.Logger,
) (*gethcore.ExecutionResult, error)
func logReceipt(r *types.Receipt, logger gethlog.Logger) {
	if logger.Enabled(context.Background(), gethlog.LevelTrace) {
		logger.Trace("Receipt", log.TxKey, r.TxHash, "Result", receiptToString(r))
	}
}
func receiptToString(r *types.Receipt) string {
	receiptJSON, err := r.MarshalJSON()
	if err != nil {
		if r.Status == types.ReceiptStatusFailed {
			return "Unsuccessful (status != 1) (but could not print receipt as JSON)"
		}
		return "Successfully executed (but could not print receipt as JSON)"
	}
	if r.Status == types.ReceiptStatusFailed {
		return fmt.Sprintf("Unsuccessful (status != 1). Receipt: %s", string(receiptJSON))
	}
	return fmt.Sprintf("Successfully executed. Receipt: %s", string(receiptJSON))
}

ExecuteCall - executes the eth_call call

func ExecuteTransaction added in v1.0.0

func ExecuteTransaction(
	tx *common.L2PricedTransaction,
	s *state.StateDB,
	header *types.Header,
	chain *TenChainContext,
	cc *params.ChainConfig,
	gp *gethcore.GasPool,
	usedGas *uint64,
	vmCfg vm.Config,
	tCount int,
	logger gethlog.Logger,
) *core.TxExecResult

func TransactionToMessageNoSender added in v0.28.0

func TransactionToMessageNoSender(tx *types.Transaction, baseFee *big.Int) *core.Message

func TransactionToMessageWithOverrides added in v0.28.0

func TransactionToMessageWithOverrides(
	tx *common.L2PricedTransaction,
	config *params.ChainConfig,
	header *types.Header,
) (*core.Message, error)

TransactionToMessageWithOverrides is used to convert a transaction to a message to be applied to the evm. Overrides can change how stuff in the message is derived, e.g. the sender. This is useful for synthetic transactions, where we do not want to do signature validation or have a private key.

Types

type ContractTransparencyConfigEventLogConfig added in v0.28.0

type ContractTransparencyConfigEventLogConfig struct {
	EventSignature common.Hash
	VisibleTo      []uint8
}

ContractTransparencyConfigEventLogConfig is an auto generated low-level Go binding around an user-defined struct.

type ContractTransparencyConfigVisibilityConfig added in v0.28.0

type ContractTransparencyConfigVisibilityConfig struct {
	ContractCfg     uint8
	EventLogConfigs []ContractTransparencyConfigEventLogConfig
}

ContractTransparencyConfigVisibilityConfig is an auto generated low-level Go binding around an user-defined struct.

type NoOpConsensusEngine added in v1.0.0

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

NoOpConsensusEngine - implements the geth consensus.Engine, but doesn't do anything This is needed for running evm transactions

func (*NoOpConsensusEngine) APIs added in v1.0.0

func (*NoOpConsensusEngine) Author added in v1.0.0

Author is used to determine where to send the gas collected from the fees.

func (*NoOpConsensusEngine) CalcDifficulty added in v1.0.0

func (*NoOpConsensusEngine) Close added in v1.0.0

func (e *NoOpConsensusEngine) Close() error

func (*NoOpConsensusEngine) Finalize added in v1.0.0

func (*NoOpConsensusEngine) FinalizeAndAssemble added in v1.0.0

func (e *NoOpConsensusEngine) FinalizeAndAssemble(_ consensus.ChainHeaderReader, _ *types.Header, _ *state.StateDB, _ *types.Body, _ []*types.Receipt) (*types.Block, error)

func (*NoOpConsensusEngine) Prepare added in v1.0.0

func (*NoOpConsensusEngine) Seal added in v1.0.0

func (e *NoOpConsensusEngine) Seal(_ consensus.ChainHeaderReader, _ *types.Block, _ chan<- *types.Block, _ <-chan struct{}) error

func (*NoOpConsensusEngine) SealHash added in v1.0.0

func (e *NoOpConsensusEngine) SealHash(_ *types.Header) common.Hash

func (*NoOpConsensusEngine) VerifyHeader added in v1.0.0

func (*NoOpConsensusEngine) VerifyHeaders added in v1.0.0

func (e *NoOpConsensusEngine) VerifyHeaders(_ consensus.ChainHeaderReader, _ []*types.Header) (chan<- struct{}, <-chan error)

func (*NoOpConsensusEngine) VerifyUncles added in v1.0.0

func (e *NoOpConsensusEngine) VerifyUncles(_ consensus.ChainReader, _ *types.Block) error

type TenChainContext added in v1.0.0

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

TenChainContext - basic implementation of the ChainContext needed for the EVM integration

func NewTenChainContext added in v1.0.0

func NewTenChainContext(storage storage.Storage, gethEncodingService gethencoding.EncodingService, config config.EnclaveConfig, logger gethlog.Logger) *TenChainContext

NewTenChainContext returns a new instance of the TenChainContext given a storage ( and logger )

func (*TenChainContext) Engine added in v1.0.0

func (occ *TenChainContext) Engine() consensus.Engine

func (*TenChainContext) GetHeader added in v1.0.0

func (occ *TenChainContext) GetHeader(hash common.Hash, _ uint64) *types.Header

type TransparencyConfig added in v0.28.0

type TransparencyConfig struct {
	TransparencyConfigCaller // Read-only binding to the contract
}

TransparencyConfig is an auto generated Go binding around an Ethereum contract.

type TransparencyConfigCaller added in v0.28.0

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

TransparencyConfigCaller is an auto generated read-only Go binding around an Ethereum contract.

func NewTransparencyConfigCaller added in v0.28.0

func NewTransparencyConfigCaller(address common.Address, caller bind.ContractCaller) (*TransparencyConfigCaller, error)

NewTransparencyConfigCaller creates a new read-only instance of TransparencyConfig, bound to a specific deployed contract.

func (*TransparencyConfigCaller) VisibilityRules added in v0.28.0

func (_ContractTransp *TransparencyConfigCaller) VisibilityRules(opts *bind.CallOpts) (ContractTransparencyConfigVisibilityConfig, error)

VisibilityRules is a free data retrieval call binding the contract method 0x30173dd1.

Solidity: function visibilityRules() pure returns((bool,(bytes,bool,bool,bool,bool,bool)[]))

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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