Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions giga/evmonly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ The target execution model is based on the `sei-v3` executor:

The current implementation executes raw RLP transactions with go-ethereum
against an EVM-native state backend, then returns a changeset plus Ethereum
receipts. Custom precompiles are still placeholders. The open work is to port
them behind an EVM-native context that is visible to the executor's conflict
tracking without reintroducing Cosmos keeper dependencies.
receipts. The staking custom precompile is the first SDK-free implementation;
other custom precompiles are still placeholders. The open work is to port them
behind an EVM-native context that is visible to the executor's conflict tracking
without reintroducing Cosmos keeper dependencies.

## Current implementation

Expand All @@ -31,7 +32,7 @@ The `evmonly` package currently provides:
- Ethereum receipt construction with logs, bloom, gas, tx hash, block metadata,
contract address, and effective gas price
- a map-backed `MemoryState` for tests and early integration
- fail-closed custom precompile placeholders
- fail-closed custom precompile placeholders plus an SDK-free staking precompile

The executor accepts config for nonce checks, gas-price checks, minimum gas
price, chain config, and the custom precompile registry.
Expand Down Expand Up @@ -109,7 +110,7 @@ receipts and RPC responses. `GasUsed` is the total EVM gas consumed by the block

## Open precompile work

Native custom precompiles still need a separate design. If they introduce state
Most native custom precompiles still need a separate design. If they introduce state
outside balance, nonce, code, and storage, that state must either become part of
the EVM-native changeset or be represented through an explicit extension that is
visible to the OCC conflict tracker.
Expand All @@ -119,9 +120,10 @@ state as contract storage owned by that precompile address. With no range reads
and no side state, precompile reads and writes can then flow through ordinary
`(address, slot)` storage tracking.

Until that design is implemented, the `evmonly` executor accepts a custom
precompile registry only as a fail-closed placeholder. Calls to registered
custom precompile addresses return `ErrCustomPrecompilesOpen`.
The staking precompile under `giga/evmonly/precompiles/staking` follows this
shape with a byte-key store backed by storage slots owned by the staking
precompile address. Registry entries without an implementation still fail
closed with `ErrCustomPrecompilesOpen`.

## Current limitations

Expand Down
36 changes: 5 additions & 31 deletions giga/evmonly/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/tracing"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/sei-protocol/sei-chain/giga/evmonly/precompiles"
)

// Executor runs raw EVM transactions against an EVM-native state backend.
Expand Down Expand Up @@ -48,10 +46,6 @@ func (e *Executor) Config() Config {
}

func (e *Executor) ExecuteBlock(ctx context.Context, req BlockRequest) (*BlockResult, error) {
if len(req.Txs) == 0 {
return &BlockResult{}, nil
}

chainConfig := e.chainConfig(req.Context)
signer := ethtypes.MakeSigner(chainConfig, new(big.Int).SetUint64(req.Context.Number), req.Context.Time)
parsed, err := parseBlockTxs(ctx, req.Txs, signer)
Expand Down Expand Up @@ -93,6 +87,11 @@ func (e *Executor) ExecuteBlock(ctx context.Context, req BlockRequest) (*BlockRe
result.GasUsed += txResult.GasUsed
txIndexUint++
}
validatorUpdates, err := runCustomPrecompileEndBlock(e.cfg.CustomPrecompiles, evm)
if err != nil {
return nil, fmt.Errorf("run custom precompile end block: %w", err)
}
result.ValidatorUpdates = validatorUpdates
stateDB.Finalise(true)
result.ChangeSet = stateDB.ChangeSet()
return result, nil
Expand Down Expand Up @@ -205,31 +204,6 @@ func buildBlockContext(ctx BlockContext) vm.BlockContext {
}
}

type unresolvedCustomPrecompile struct{}

func (unresolvedCustomPrecompile) RequiredGas([]byte) uint64 {
return 0
}

func (unresolvedCustomPrecompile) Run(*vm.EVM, common.Address, common.Address, []byte, *big.Int, bool, bool, *tracing.Hooks) ([]byte, error) {
return nil, precompiles.ErrCustomPrecompilesOpen
}

func customPrecompileMap(registry precompiles.Registry) map[common.Address]vm.PrecompiledContract {
if registry == nil {
return nil
}
addresses := registry.Addresses()
if len(addresses) == 0 {
return nil
}
contracts := make(map[common.Address]vm.PrecompiledContract, len(addresses))
for _, addr := range addresses {
contracts[addr] = unresolvedCustomPrecompile{}
}
return contracts
}

func (e *Executor) chainConfig(ctx BlockContext) *params.ChainConfig {
var cfg params.ChainConfig
if e.cfg.ChainConfig != nil {
Expand Down
Loading
Loading