Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6dca538
Add alias addresses and chainID related blockchain hooks
Sep 12, 2024
fdf704a
Enhance executeOnSameContext with extra parameters, split baseOps int…
Sep 12, 2024
b7c110d
Expose IsOutOfVMFunctionExecution method
Sep 12, 2024
3000aef
Fix issue with initial cost for indirect new contracts
Sep 12, 2024
a872372
Separate nonce logic for new accounts, expose runtime code related me…
Sep 12, 2024
e0b4d13
Prevent saving of compiled code if not ready, prevent unnecessary che…
Sep 12, 2024
a0da6e8
Add adjusted EVM (started from geth v1.13.15 codebase - Cancun), add …
Sep 12, 2024
b108ff6
Switch to using external toggle for enabling function name checks, co…
Sep 13, 2024
4f2ea01
Encode function selector to hex for evm calls
Sep 17, 2024
66208ad
Add host parameter for omitting standard flow code changes (evm does …
Sep 17, 2024
372a758
Remove reduction of gas before create and call opcodes (in the contex…
Sep 23, 2024
06f3ba9
Merge MVX changes into ONE branch
Nov 4, 2024
561cb68
Toggle MoreAccountsAllowed flag for evm adder test
Nov 5, 2024
285df70
Merge MVX changes into ONE branch
Dec 18, 2024
3931c49
Merge remote-tracking branch 'evm/one' into merge-evm-into-sovereign-…
axenteoctavian Apr 10, 2025
176da57
update go.mod
axenteoctavian Apr 10, 2025
4192880
update go.mod
axenteoctavian Apr 10, 2025
f8cc5ef
update go.mod
axenteoctavian Apr 10, 2025
c2b2ec4
update go.mod
axenteoctavian Apr 10, 2025
5619ab5
fix linter error
axenteoctavian Apr 10, 2025
c324897
Merge branch 'feat/evm-extension' into merge-evm-into-sovereign-10-apr
axenteoctavian Oct 17, 2025
0041678
Update go.mod
axenteoctavian Oct 17, 2025
181329d
Update go.mod
axenteoctavian Oct 17, 2025
b9ebb69
fixes after merge
axenteoctavian Oct 17, 2025
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
43 changes: 43 additions & 0 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,49 @@
ManagedMapRemove = 10
ManagedMapContains = 10

[EVMOpcodeCost]
QuickStep = 1
FastestStep = 1
FastStep = 1
MidStep = 1
SlowStep = 1
ExtStep = 1
Ecrecover = 1
Sha256PerWord = 1
Sha256Base = 1
Ripemd160PerWord = 1
Ripemd160Base = 1
IdentityPerWord = 1
IdentityBase = 1
Bn256Add = 1
Bn256ScalarMul = 1
Bn256PairingBase = 1
Bn256PairingPerPoint = 1
BlobTxPointEvaluation = 1
Keccak256 = 1
Balance = 1
ExtcodeSize = 1
ExtcodeCopy = 1
ExtcodeHash = 1
Sload = 1
Sstore = 1
Jumpdest = 1
Tload = 1
Tstore = 1
Create = 1
Call = 1
Create2 = 1
Selfdestruct = 1
Memory = 1
Copy = 1
Log = 1
LogTopic = 1
LogData = 1
Keccak256Word = 1
InitCodeWord = 1
ExpByte = 1
Exp = 1

[WASMOpcodeCost]
AtomicFence = 1
AtomicNotify = 1
Expand Down
1 change: 1 addition & 0 deletions config/gasCost.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type GasCost struct {
ManagedBufferAPICost ManagedBufferAPICost
ManagedMapAPICost ManagedMapAPICost
CryptoAPICost CryptoAPICost
EVMOpcodeCost *executor.EVMOpcodeCost
WASMOpcodeCost *executor.WASMOpcodeCost
DynamicStorageLoad DynamicStorageLoadCostCoefficients
}
Expand Down
62 changes: 62 additions & 0 deletions config/gasSchedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ func CreateGasConfig(gasMap GasScheduleMap) (*GasCost, error) {
return nil, err
}

evmOps := &executor.EVMOpcodeCost{}
err = mapstructure.Decode(gasMap["EVMOpcodeCost"], evmOps)
if err != nil {
return nil, err
}

err = checkForZeroUint64Fields(*evmOps)
if err != nil {
return nil, err
}

wasmOps := &executor.WASMOpcodeCost{}
err = mapstructure.Decode(gasMap["WASMOpcodeCost"], wasmOps)
if err != nil {
Expand Down Expand Up @@ -127,6 +138,7 @@ func CreateGasConfig(gasMap GasScheduleMap) (*GasCost, error) {
BaseOpsAPICost: *baseOpsAPI,
CryptoAPICost: *cryptOps,
ManagedBufferAPICost: *MBufferOps,
EVMOpcodeCost: evmOps,
WASMOpcodeCost: wasmOps,
DynamicStorageLoad: *dynamicStorageLoadParams,
ManagedMapAPICost: *managedMapOps,
Expand Down Expand Up @@ -211,6 +223,7 @@ func FillGasMap(gasMap GasScheduleMap, value, asyncCallbackGasLock uint64) GasSc
gasMap["BigFloatAPICost"] = FillGasMapBigFloatAPICosts(value)
gasMap["CryptoAPICost"] = FillGasMapCryptoAPICosts(value)
gasMap["ManagedBufferAPICost"] = FillGasMapManagedBufferAPICosts(value)
gasMap["EVMOpcodeCost"] = FillGasMapEVMOpcodeCosts(value)
gasMap["WASMOpcodeCost"] = FillGasMapWASMOpcodeValues(value)
gasMap["DynamicStorageLoad"] = FillGasMapDynamicStorageLoad()

Expand Down Expand Up @@ -500,6 +513,55 @@ func FillGasMapManagedBufferAPICosts(value uint64) map[string]uint64 {
return gasMap
}

// FillGasMapEVMOpcodeCosts fills the evm opcodes costs
func FillGasMapEVMOpcodeCosts(value uint64) map[string]uint64 {
gasMap := make(map[string]uint64)

gasMap["QuickStep"] = value
gasMap["FastestStep"] = value
gasMap["FastStep"] = value
gasMap["MidStep"] = value
gasMap["SlowStep"] = value
gasMap["ExtStep"] = value
gasMap["Ecrecover"] = value
gasMap["Sha256PerWord"] = value
gasMap["Sha256Base"] = value
gasMap["Ripemd160PerWord"] = value
gasMap["Ripemd160Base"] = value
gasMap["IdentityPerWord"] = value
gasMap["IdentityBase"] = value
gasMap["Bn256Add"] = value
gasMap["Bn256ScalarMul"] = value
gasMap["Bn256PairingBase"] = value
gasMap["Bn256PairingPerPoint"] = value
gasMap["BlobTxPointEvaluation"] = value
gasMap["Keccak256"] = value
gasMap["Balance"] = value
gasMap["ExtcodeSize"] = value
gasMap["ExtcodeCopy"] = value
gasMap["ExtcodeHash"] = value
gasMap["Sload"] = value
gasMap["Sstore"] = value
gasMap["Jumpdest"] = value
gasMap["Tload"] = value
gasMap["Tstore"] = value
gasMap["Create"] = value
gasMap["Call"] = value
gasMap["Create2"] = value
gasMap["Selfdestruct"] = value
gasMap["Memory"] = value
gasMap["Copy"] = value
gasMap["Log"] = value
gasMap["LogTopic"] = value
gasMap["LogData"] = value
gasMap["Keccak256Word"] = value
gasMap["InitCodeWord"] = value
gasMap["ExpByte"] = value
gasMap["Exp"] = value

return gasMap
}

// FillGasMapWASMOpcodeValues fills the wasm opcodes costs
func FillGasMapWASMOpcodeValues(value uint64) map[string]uint64 {
gasMap := make(map[string]uint64)
Expand Down
9 changes: 9 additions & 0 deletions evm/evmError.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package evm

import "errors"

var ErrActionNotSupported = errors.New("action not supported on EVM")

var ErrCodeNotCompiled = errors.New("code is not compiled")

var ErrExecutionAborted = errors.New("execution aborted")
103 changes: 103 additions & 0 deletions evm/evmExecutor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package evm

import (
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
evm "github.com/multiversx/mx-chain-vm-go/evm/interpreter"
"github.com/multiversx/mx-chain-vm-go/executor"
)

var _ executor.Executor = (*EVMExecutor)(nil)

// EVMExecutor oversees the creation of EVM instances and execution.
type EVMExecutor struct {
evmHooks executor.EVMHooks
gasConfig *evm.GasConfig
instructionSet evm.JumpTable
}

// CreateExecutor creates a new EVM executor.
func CreateExecutor(args executor.ExecutorFactoryArgs) (*EVMExecutor, error) {
evmExecutor := &EVMExecutor{evmHooks: args.EvmHooks}
evmExecutor.SetOpcodeCosts(args.OpcodeCosts)
return evmExecutor, nil
}

func (evmExecutor *EVMExecutor) SetOpcodeCosts(opcodeCost executor.VMOpcodeCost) {
if opcodeCost.EVMOpcodeCost != nil {
evmExecutor.gasConfig = extractOpcodeCost(opcodeCost.EVMOpcodeCost)
evmExecutor.instructionSet = evm.NewCancunInstructionSet(evmExecutor.gasConfig)
}
}

func (evmExecutor *EVMExecutor) FunctionNames() vmcommon.FunctionNames {
return map[string]struct{}{}
}

// NewInstanceWithOptions creates a new EVM instance from EVM bytecode,
// respecting the provided options
func (evmExecutor *EVMExecutor) NewInstanceWithOptions(
contractCode []byte,
options executor.CompilationOptions,
) (executor.Instance, error) {
return newInstance(evmExecutor, false, contractCode, options)
}

// NewInstanceFromCompiledCodeWithOptions creates a new EVM instance from compiled code,
// respecting the provided options
func (evmExecutor *EVMExecutor) NewInstanceFromCompiledCodeWithOptions(
compiledCode []byte,
options executor.CompilationOptions,
) (executor.Instance, error) {
return newInstance(evmExecutor, true, compiledCode, options)
}

// IsInterfaceNil returns true if underlying object is nil
func (evmExecutor *EVMExecutor) IsInterfaceNil() bool {
return evmExecutor == nil
}

func extractOpcodeCost(opcodeCost *executor.EVMOpcodeCost) *evm.GasConfig {
return &evm.GasConfig{
QuickStep: opcodeCost.QuickStep,
FastestStep: opcodeCost.FastestStep,
FastStep: opcodeCost.FastStep,
MidStep: opcodeCost.MidStep,
SlowStep: opcodeCost.SlowStep,
ExtStep: opcodeCost.ExtStep,
Ecrecover: opcodeCost.Ecrecover,
Sha256PerWord: opcodeCost.Sha256PerWord,
Sha256Base: opcodeCost.Sha256Base,
Ripemd160PerWord: opcodeCost.Ripemd160PerWord,
Ripemd160Base: opcodeCost.Ripemd160Base,
IdentityPerWord: opcodeCost.IdentityPerWord,
IdentityBase: opcodeCost.IdentityBase,
Bn256Add: opcodeCost.Bn256Add,
Bn256ScalarMul: opcodeCost.Bn256ScalarMul,
Bn256PairingBase: opcodeCost.Bn256PairingBase,
Bn256PairingPerPoint: opcodeCost.Bn256PairingPerPoint,
BlobTxPointEvaluation: opcodeCost.BlobTxPointEvaluation,
Keccak256: opcodeCost.Keccak256,
Balance: opcodeCost.Balance,
ExtcodeSize: opcodeCost.ExtcodeSize,
ExtcodeCopy: opcodeCost.ExtcodeCopy,
ExtcodeHash: opcodeCost.ExtcodeHash,
Sload: opcodeCost.Sload,
Sstore: opcodeCost.Sstore,
Jumpdest: opcodeCost.Jumpdest,
Tload: opcodeCost.Tload,
Tstore: opcodeCost.Tstore,
Create: opcodeCost.Create,
Call: opcodeCost.Call,
Create2: opcodeCost.Create2,
Selfdestruct: opcodeCost.Selfdestruct,
Memory: opcodeCost.Memory,
Copy: opcodeCost.Copy,
Log: opcodeCost.Log,
LogTopic: opcodeCost.LogTopic,
LogData: opcodeCost.LogData,
Keccak256Word: opcodeCost.Keccak256Word,
InitCodeWord: opcodeCost.InitCodeWord,
ExpByte: opcodeCost.ExpByte,
Exp: opcodeCost.Exp,
}
}
25 changes: 25 additions & 0 deletions evm/evmExecutorFactory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package evm

import (
"github.com/multiversx/mx-chain-vm-go/executor"
)

var _ = (executor.ExecutorAbstractFactory)((*EVMExecutorFactory)(nil))

// EVMExecutorFactory builds EVM Executors.
type EVMExecutorFactory struct{}

// ExecutorFactory returns the EVM executor factory.
func ExecutorFactory() *EVMExecutorFactory {
return &EVMExecutorFactory{}
}

// CreateExecutor creates a new Executor instance.
func (eef *EVMExecutorFactory) CreateExecutor(args executor.ExecutorFactoryArgs) (executor.Executor, error) {
return CreateExecutor(args)
}

// IsInterfaceNil returns true if there is no value under the interface
func (eef *EVMExecutorFactory) IsInterfaceNil() bool {
return eef == nil
}
Loading
Loading