Skip to content

Commit a67029f

Browse files
authored
Merge branch 'main' into gprusak-dh
2 parents 136a40f + 91ef5cb commit a67029f

File tree

10 files changed

+404
-6
lines changed

10 files changed

+404
-6
lines changed

app/app.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import (
104104
evmrpcconfig "github.com/sei-protocol/sei-chain/evmrpc/config"
105105
gigaexecutor "github.com/sei-protocol/sei-chain/giga/executor"
106106
gigaconfig "github.com/sei-protocol/sei-chain/giga/executor/config"
107+
gigalib "github.com/sei-protocol/sei-chain/giga/executor/lib"
107108
"github.com/sei-protocol/sei-chain/precompiles"
108109
putils "github.com/sei-protocol/sei-chain/precompiles/utils"
109110
"github.com/sei-protocol/sei-chain/sei-db/state_db/ss"
@@ -679,6 +680,11 @@ func New(
679680
app.EvmKeeper.GigaExecutorEnabled = gigaExecutorConfig.Enabled
680681
app.EvmKeeper.GigaOCCEnabled = gigaExecutorConfig.OCCEnabled
681682
if gigaExecutorConfig.Enabled {
683+
evmoneVM, err := gigalib.InitEvmoneVM()
684+
if err != nil {
685+
panic(fmt.Sprintf("failed to load evmone: %s", err))
686+
}
687+
app.EvmKeeper.EvmoneVM = evmoneVM
682688
if gigaExecutorConfig.OCCEnabled {
683689
logger.Info("benchmark: Giga Executor with OCC is ENABLED - using new EVM execution path with parallel execution")
684690
} else {
@@ -1677,7 +1683,7 @@ func (app *App) executeEVMTxWithGigaExecutor(ctx sdk.Context, txIndex int, msg *
16771683
cfg := evmtypes.DefaultChainConfig().EthereumConfigWithSstore(app.EvmKeeper.ChainID(ctx), &sstore)
16781684

16791685
// Create Giga executor VM (wraps evmone)
1680-
gigaExecutor := gigaexecutor.NewEvmoneExecutor(*blockCtx, stateDB, cfg, vm.Config{}, app.EvmKeeper.CustomPrecompiles(ctx))
1686+
gigaExecutor := gigaexecutor.NewEvmoneExecutor(app.EvmKeeper.EvmoneVM, *blockCtx, stateDB, cfg, vm.Config{}, app.EvmKeeper.CustomPrecompiles(ctx))
16811687

16821688
// Execute the transaction through giga VM
16831689
execResult, execErr := gigaExecutor.ExecuteTransaction(ethTx, sender, app.EvmKeeper.GetBaseFee(ctx), &gp)

giga/executor/executor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package executor
33
import (
44
"math/big"
55

6+
"github.com/ethereum/evmc/v12/bindings/go/evmc"
67
"github.com/ethereum/go-ethereum/common"
78
"github.com/ethereum/go-ethereum/core"
89
"github.com/ethereum/go-ethereum/core/types"
@@ -15,10 +16,9 @@ type Executor struct {
1516
evm *vm.EVM
1617
}
1718

18-
func NewEvmoneExecutor(blockCtx vm.BlockContext, stateDB vm.StateDB, chainConfig *params.ChainConfig, config vm.Config, customPrecompiles map[common.Address]vm.PrecompiledContract) *Executor {
19+
func NewEvmoneExecutor(evmoneVM *evmc.VM, blockCtx vm.BlockContext, stateDB vm.StateDB, chainConfig *params.ChainConfig, config vm.Config, customPrecompiles map[common.Address]vm.PrecompiledContract) *Executor {
1920
evm := vm.NewEVM(blockCtx, stateDB, chainConfig, config, customPrecompiles)
20-
// TODO(pdrobnjak): populate evmc.VM and integrate evmone for direct bytecode execution
21-
hostContext := internal.NewHostContext(nil, evm)
21+
hostContext := internal.NewHostContext(evmoneVM, evm)
2222
evm.EVMInterpreter = internal.NewEVMInterpreter(hostContext, evm)
2323
return &Executor{
2424
evm: evm,

giga/executor/lib/evmlib.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package lib
2+
3+
import (
4+
"fmt"
5+
"path/filepath"
6+
"runtime"
7+
8+
"github.com/ethereum/evmc/v12/bindings/go/evmc"
9+
)
10+
11+
// InitEvmoneVM initializes the EVMC VM by loading the platform-specific evmone library.
12+
// It does not verify that the loaded version is compatible with evmc version.
13+
func InitEvmoneVM() (*evmc.VM, error) {
14+
_, path, _, ok := runtime.Caller(0)
15+
if !ok {
16+
return nil, fmt.Errorf("failed to get caller information")
17+
}
18+
19+
libPath := filepath.Join(filepath.Dir(path), libName)
20+
vm, err := evmc.Load(libPath)
21+
if err != nil {
22+
return nil, fmt.Errorf("evmc.Load(%q): %w", libPath, err)
23+
}
24+
25+
return vm, nil
26+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//go:build darwin && arm64
2+
3+
package lib
4+
5+
const libName = "libevmone.0.12.0_darwin_arm64.dylib"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//go:build linux && amd64
2+
3+
package lib
4+
5+
const libName = "libevmone.0.12.0_linux_amd64.so"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build !((linux && amd64) || (darwin && arm64))
2+
3+
package lib
4+
5+
// evmone is not available for this platform.
6+
// Supported platforms: linux/amd64, darwin/arm64
7+
//
8+
// If you see a compile error referencing this file, you are building
9+
// for an unsupported OS/architecture combination.
10+
const libName = evmone_unsupported_platform__only_linux_amd64_and_darwin_arm64_are_supported
302 KB
Binary file not shown.
479 KB
Binary file not shown.

0 commit comments

Comments
 (0)