Skip to content
Draft
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
208 changes: 208 additions & 0 deletions giga/executor/vm/evmc/host_context.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
package evmc

import (
"github.com/ethereum/evmc/v12/bindings/go/evmc"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/tracing"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
)

var _ evmc.HostContext = (*HostContext)(nil)

type HostContext struct {
vm *evmc.VM
evm *vm.EVM
}

func NewHostContext(vm *evmc.VM, evm *vm.EVM) *HostContext {
return &HostContext{vm: vm, evm: evm}
}

func (h *HostContext) AccountExists(addr evmc.Address) bool {
return h.evm.StateDB.Exist(common.Address(addr))
}

func (h *HostContext) GetStorage(addr evmc.Address, key evmc.Hash) evmc.Hash {
return evmc.Hash(h.evm.StateDB.GetState(common.Address(addr), common.Hash(key)))
}

func (h *HostContext) SetStorage(addr evmc.Address, key evmc.Hash, value evmc.Hash) evmc.StorageStatus {
gethAddr := common.Address(addr)
gethKey := common.Hash(key)

current := h.evm.StateDB.GetState(gethAddr, gethKey)
original := h.evm.StateDB.GetCommittedState(gethAddr, gethKey)

dirty := original.Cmp(current) != 0
restored := original.Cmp(common.Hash(value)) == 0
currentIsZero := current.Cmp(common.Hash{}) == 0
valueIsZero := common.Hash(value).Cmp(common.Hash{}) == 0

status := evmc.StorageAssigned
if !dirty && !restored {
if currentIsZero {
status = evmc.StorageAdded
} else if valueIsZero {
status = evmc.StorageDeleted
} else {
status = evmc.StorageModified
}
} else if dirty && !restored {
if currentIsZero && valueIsZero {
status = evmc.StorageDeletedAdded
} else if !currentIsZero && valueIsZero {
status = evmc.StorageModifiedDeleted
}
} else if dirty {
if currentIsZero {
status = evmc.StorageDeletedRestored
} else if valueIsZero {
status = evmc.StorageAddedDeleted
} else {
status = evmc.StorageModifiedRestored
}
}

h.evm.StateDB.SetState(gethAddr, gethKey, common.Hash(value))
return status
}

func (h *HostContext) GetBalance(addr evmc.Address) evmc.Hash {
return h.evm.StateDB.GetBalance(common.Address(addr)).Bytes32()
}

func (h *HostContext) GetCodeSize(addr evmc.Address) int {
return h.evm.StateDB.GetCodeSize(common.Address(addr))
}

func (h *HostContext) GetCodeHash(addr evmc.Address) evmc.Hash {
return evmc.Hash(h.evm.StateDB.GetCodeHash(common.Address(addr)))
}

func (h *HostContext) GetCode(addr evmc.Address) []byte {
return h.evm.StateDB.GetCode(common.Address(addr))
}

// todo(pdrobnjak): support historical selfdestruct logic as well
func (h *HostContext) Selfdestruct(addr evmc.Address, beneficiary evmc.Address) bool {
addrKey := common.Address(addr)
beneficiaryKey := common.Address(beneficiary)
amt := h.evm.StateDB.GetBalance(addrKey)
h.evm.StateDB.SubBalance(addrKey, amt, tracing.BalanceDecreaseSelfdestruct)
h.evm.StateDB.AddBalance(beneficiaryKey, amt, tracing.BalanceIncreaseSelfdestruct)
h.evm.StateDB.SelfDestruct6780(common.Address(addr))
return true
}

func (h *HostContext) GetTxContext() evmc.TxContext {
var gasPrice evmc.Hash
h.evm.TxContext.GasPrice.FillBytes(gasPrice[:])

var prevRandao evmc.Hash
if h.evm.Context.Random != nil {
prevRandao = evmc.Hash(*h.evm.Context.Random)
}

var chainID evmc.Hash
h.evm.ChainConfig().ChainID.FillBytes(chainID[:])

var baseFee evmc.Hash
h.evm.Context.BaseFee.FillBytes(baseFee[:])

var blobBaseFee evmc.Hash
h.evm.Context.BlobBaseFee.FillBytes(blobBaseFee[:])

return evmc.TxContext{
GasPrice: gasPrice,
Origin: evmc.Address(h.evm.TxContext.Origin),
Coinbase: evmc.Address(h.evm.Context.Coinbase),
Number: h.evm.Context.BlockNumber.Int64(),
Timestamp: int64(h.evm.Context.Time),
GasLimit: int64(h.evm.Context.GasLimit),
PrevRandao: prevRandao,
ChainID: chainID,
BaseFee: baseFee,
BlobBaseFee: blobBaseFee,
}
}

func (h *HostContext) GetBlockHash(number int64) evmc.Hash {
return evmc.Hash(h.evm.Context.GetHash(uint64(number)))
}

func (h *HostContext) EmitLog(addr evmc.Address, topics []evmc.Hash, data []byte) {
gethTopics := make([]common.Hash, len(topics))
for i, topic := range topics {
gethTopics[i] = common.Hash(topic)
}
h.evm.StateDB.AddLog(&ethtypes.Log{Address: common.Address(addr), Topics: gethTopics, Data: data})
}

// todo(pdrobnjak): figure out how to populate - evmRevision, delegated, code - probably can be passed down from interpreter
// this will sometimes be called throught interpreter.Run (top level) and sometimes from evmc_execute (child calls)
// which means that sometimes it should delegate to the interpreter and sometimes it should call evm.Call/evm.DelegateCall/...
// we are getting a Frankestein of geth + evmc + evmone
// can this be routed through depth? noup, but we can set an internal flag in HostContext when calling through interpreter.Run
// host HostContext needs to contain the EVM
func (h *HostContext) Call(
kind evmc.CallKind, recipient evmc.Address, sender evmc.Address, value evmc.Hash, input []byte, gas int64,
depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
) ([]byte, int64, int64, evmc.Address, error) {
// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
flag := true
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)

Check failure on line 157 in giga/executor/vm/evmc/host_context.go

View workflow job for this annotation

GitHub Actions / lint

undefined: caller (typecheck)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of ret is never used.

Copilot Autofix

AI 1 day ago

In general, to fix useless assignments, either (a) remove them (and possibly the surrounding code) if they are not needed, or (b) refactor the code so that the computed values are actually used. For Go, if you only need side effects from a call and not its return values, you should call the function without assigning its results, or assign unwanted results to _.

For this function, the best minimal fix that preserves existing behavior is to remove the unused local variables inside the switch and keep only the calls for their side effects. Currently, after the if flag { ... } block, the function always runs h.vm.Execute and returns based on that, completely ignoring any ret, leftoverGas, err, or createAddr produced by h.evm.* calls. Therefore, we can change each case arm to simply call the corresponding h.evm.* method without capturing its return values. This eliminates the useless assignments while leaving side effects and control flow unchanged.

Concretely, in giga/executor/vm/evmc/host_context.go within HostContext.Call, edit lines 156–166 so that each case invokes the EVM methods without := bindings. No new imports or helper methods are required.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of leftoverGas is never used.

Copilot Autofix

AI 1 day ago

In general, to fix a “useless assignment to local variable” you either (a) remove the assignment (and possibly the variable) if it is genuinely unused, or (b) change the code so the assigned value is actually used (for example, by returning it, logging it, or passing it to another call). Using _ is appropriate only when you intentionally ignore some returns while still needing others.

For this function, the entire if flag { switch kind { ... } } block is currently dead in terms of observable behavior: none of the variables assigned within it influence the final return values, and there’s no side effect unique to those assignments. The cleanest way to fix the issue without changing current behavior is to remove that block entirely. The remaining logic, which calls h.vm.Execute(...), already determines the function’s output and is the only active path.

Concretely:

  • In giga/executor/vm/evmc/host_context.go, in func (h *HostContext) Call(...), remove the flag := true declaration, the if flag { ... } block, and the enclosed switch with its case branches.
  • Keep the // ELSE comment and the subsequent evmRevision, delegated, code, and Execute call unchanged, so functional behavior remains the same as before (since the removed block had no effect).

No new methods or imports are required; we’re only deleting unused assignments and their enclosing control flow.


Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -150,21 +150,6 @@
 	depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
 ) ([]byte, int64, int64, evmc.Address, error) {
 	// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
-	flag := true
-	if flag {
-		switch kind {
-		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
-		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
-		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
-		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
-		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
-		}
-	}
 	// ELSE
 	evmRevision := evmc.Frontier
 	delegated := false
EOF
@@ -150,21 +150,6 @@
depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
) ([]byte, int64, int64, evmc.Address, error) {
// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
flag := true
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
evmRevision := evmc.Frontier
delegated := false
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of err is never used.

Copilot Autofix

AI 1 day ago

In general, to fix “useless assignment to local variable” issues, you either (1) remove the assignment if the value is never needed, or (2) replace the variable with the blank identifier _ to preserve the side-effecting call while explicitly discarding the result. Here, the Call method invokes several h.evm.* methods in a switch and assigns their multiple return values to local variables (ret, leftoverGas, createAddr, err), but those locals are never used. We want to keep the h.evm.* calls (for their side effects and correctness) while avoiding unused variables.

The best fix without changing current functionality is to change each short variable declaration in the switch from a full tuple of named variables to a set of blank identifiers, since none of the results are used later. For example, change ret, leftoverGas, err := h.evm.Call(...) to _, _, _ = h.evm.Call(...) (or just _, _, _ := h.evm.Call(...); assignment vs declaration doesn’t matter here as the variables are discarded). Similarly, for the Create and Create2 calls that return four values, use _, _, _, _ = .... This keeps the calls and their side effects intact, removes the unused err and other locals, and eliminates the CodeQL warning. No new imports or additional methods are needed; all changes are confined to the Call method in giga/executor/vm/evmc/host_context.go.


Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			_, _, _ = h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			_, _, _ = h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			_, _, _ = h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			_, _, _, _ = h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			_, _, _, _ = h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
_, _, _ = h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
_, _, _ = h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
_, _, _ = h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
_, _, _, _ = h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
_, _, _, _ = h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)

Check failure on line 159 in giga/executor/vm/evmc/host_context.go

View workflow job for this annotation

GitHub Actions / lint

undefined: originCaller (typecheck)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of ret is never used.

Copilot Autofix

AI 1 day ago

In general, when you must call a function but don’t need some or all of its return values, you should assign the unwanted results to the blank identifier _ rather than to named variables. This makes it explicit that the values are intentionally ignored and avoids “useless assignment” warnings.

For this specific HostContext.Call implementation in giga/executor/vm/evmc/host_context.go, the behavior after the if flag block is already determined solely by the later h.vm.Execute call. To preserve existing behavior while fixing the CodeQL warning, we should:

  • Keep the calls to h.evm.Call, DelegateCall, CallCode, Create, and Create2 exactly as they are (to preserve any side effects), but
  • Replace the assignments to local variables (ret, leftoverGas, err, createAddr, endowment) with assignments to _.

Concretely, on lines 157–165:

  • Change ret, leftoverGas, err := ... to _, _, _ := ....
  • Change ret, createAddr, leftoverGas, err := ... to _, _, _, _ := ....
  • Change ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt) so that all returned values are assigned to _ (you may need to match the actual signature; based on the existing code, keep the same arity and use _ for each position).

No imports, type definitions, or additional methods are required; we are only changing how existing function return values are bound to local variables.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			_, _, _ := h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			_, _, _ := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			_, _, _ := h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			_, _, _, _ := h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			_, _, _, _ := h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
_, _, _ := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
_, _, _ := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
_, _, _ := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
_, _, _, _ := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
_, _, _, _ := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of leftoverGas is never used.

Copilot Autofix

AI 1 day ago

In general, to fix “useless assignment to local variable” you either (1) remove the assignment entirely if the called function has no required side-effects, or (2) keep the call but ignore return values explicitly using the blank identifier _ so that no named-but-unused locals are created. Here, the intent seems to be to keep the h.evm.* calls inside the switch, but the results are not yet integrated; thus we should keep the calls (to preserve any side effects) and discard all return values explicitly.

The single best way to fix this without altering current functionality is to replace each short declaration of ret, leftoverGas, err (and createAddr) with assignment to _. For example, change:

ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)

to:

_, _, _ := h.evm.Call(caller, addr, input, gas, value)

and similarly for DelegateCall, CallCode, Create, and Create2, matching the exact number of returned values from those functions. This preserves all calls (and therefore side effects) but makes it explicit that their results are intentionally unused, eliminating the useless local variables and the CodeQL warning. All changes occur in giga/executor/vm/evmc/host_context.go within the shown Call method; no new imports or helper methods are required.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			_, _, _ := h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			_, _, _ := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			_, _, _ := h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			_, _, _, _ := h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			_, _, _, _ := h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
_, _, _ := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
_, _, _ := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
_, _, _ := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
_, _, _, _ := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
_, _, _, _ := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of err is never used.

Copilot Autofix

AI 1 day ago

In general, to fix useless assignments you either (a) remove the assignments entirely when the values are not needed, or (b) replace the variable with the blank identifier _ when you need to preserve side effects of the function call but not the returned values. Here, the switch block in the flag branch is completely unused: all assigned variables are local to their case scope and never read, and the function’s actual behavior comes from the later Execute call. If we want to preserve current external behavior (which does not use these calls), the best fix is to remove the dead flag branch entirely. This simplifies the function and eliminates all useless assignments without changing any behavior, because flag is a constant true and the result of the switch is not used.

Concretely, in giga/executor/vm/evmc/host_context.go, inside the Call method, remove the lines:

	// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
	flag := true
	if flag {
		switch kind {
		case evmc.Call:
			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
		case evmc.DelegateCall:
			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
		case evmc.CallCode:
			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
		case evmc.Create:
			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
		case evmc.Create2:
			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
		}
	}
	// ELSE

and leave the Execute call as the only execution path. No new imports or helper methods are required.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -150,22 +150,6 @@
 	depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
 ) ([]byte, int64, int64, evmc.Address, error) {
 	// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
-	flag := true
-	if flag {
-		switch kind {
-		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
-		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
-		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
-		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
-		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
-		}
-	}
-	// ELSE
 	evmRevision := evmc.Frontier
 	delegated := false
 	var code []byte
EOF
@@ -150,22 +150,6 @@
depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
) ([]byte, int64, int64, evmc.Address, error) {
// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
flag := true
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
evmRevision := evmc.Frontier
delegated := false
var code []byte
Copilot is powered by AI and may make mistakes. Always verify output.
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)

Check failure on line 161 in giga/executor/vm/evmc/host_context.go

View workflow job for this annotation

GitHub Actions / lint

undefined: caller (typecheck)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of ret is never used.

Copilot Autofix

AI 1 day ago

In general, to fix a "useless assignment to local variable" you either remove the assignment entirely (if the value is not needed) or, if only some return values are irrelevant, you assign unwanted values to the blank identifier _ so that only meaningful values are kept.

For this specific function, the if flag { ... } block currently serves no functional purpose: its internal ret, leftoverGas, createAddr, and err variables are never used afterwards, and the function always proceeds to the h.vm.Execute call and returns its result. To fix the issue without changing behaviour, we should remove the unused variable declarations. Because the branch is guarded by flag := true, it will always run, but since its results are unused, calling those methods at all is effectively redundant. The most conservative change that preserves current semantics is to (a) stop declaring the unused variables, and (b) keep or remove the calls themselves depending on whether they are needed for side effects. Given that the current code clearly intends to eventually “route” calls differently and that these calls are placeholders, the cleanest behaviour‑preserving fix is to leave the control structure but drop the variable assignments and simply invoke the EVM methods without capturing their return values. This eliminates the useless assignments while keeping any potential side effects of the calls.

Concretely, in giga/executor/vm/evmc/host_context.go, inside HostContext.Call, lines 153–166 should be updated so that each case calls the corresponding h.evm.* method without :=/= bindings; i.e., remove ret, leftoverGas, err := / ret, createAddr, leftoverGas, err := and just call the methods. No new imports or helper methods are required.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of leftoverGas is never used.

Copilot Autofix

AI 1 day ago

In general, to fix "useless assignment to local variable" you either remove the assignment entirely or, when you need to preserve side effects of a call but not its results, bind unused results to the blank identifier _. This tells both humans and tools that the values are intentionally ignored.

Here, inside HostContext.Call, the switch under if flag invokes methods like h.evm.Call, h.evm.DelegateCall, etc. All returned values (ret, leftoverGas, createAddr, err) are currently unused. To resolve CodeQL’s complaint about leftoverGas without changing behavior, we should keep the calls (to preserve any side effects) but replace the named variables with _ in each assignment. That way, there is no useless local variable, and the code more clearly documents that the return values are intentionally ignored for now.

Concretely, in giga/executor/vm/evmc/host_context.go, lines 157–165 in the provided snippet should be updated so that each := assignment uses _ for all returned values. No additional imports or helper methods are needed.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			_, _, _ := h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			_, _, _ := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			_, _, _ := h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			_, _, _, _ := h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			_, _, _, _ := h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
_, _, _ := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
_, _, _ := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
_, _, _ := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
_, _, _, _ := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
_, _, _, _ := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of err is never used.

Copilot Autofix

AI 1 day ago

In general, to fix "useless assignment" issues in Go, either remove the unused assignments entirely, or, if you must keep the call for its side effects, use the blank identifier (_) for any return values you do not read. This makes it explicit that the results are intentionally ignored and prevents creation of unused local variables.

Here, the if flag block appears to be placeholder logic that may later delegate to h.evm.* calls. Currently, the function always takes the EVMC execution path after this if, and none of ret, leftoverGas, createAddr, or err from that switch are ever used. The smallest, safest change that preserves existing behavior is to keep the calls (in case they are temporarily valuable for side effects or compilation experiments) but assign all their return values to _ instead of creating named variables. That removes the unused-variable definitions, including the highlighted err, without altering control flow or behavior.

Concretely, in giga/executor/vm/evmc/host_context.go, within HostContext.Call, update each h.evm.* invocation in the switch (lines 157–165) to use _ for all return values. Do not introduce new imports or additional logic; just replace ret, leftoverGas, err := ... with _, _, _ := ... and similarly for the Create/Create2 calls with four return values.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			_, _, _ := h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			_, _, _ := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			_, _, _ := h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			_, _, _, _ := h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			_, _, _, _ := h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
_, _, _ := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
_, _, _ := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
_, _, _ := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
_, _, _, _ := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
_, _, _, _ := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)

Check failure on line 163 in giga/executor/vm/evmc/host_context.go

View workflow job for this annotation

GitHub Actions / lint

undefined: caller (typecheck)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of ret is never used.

Copilot Autofix

AI 1 day ago

In general, a “useless assignment” should be removed or refactored so that any intentionally ignored values are either not bound at all or are explicitly discarded using _. Here, the simplest fix without changing behaviour is to eliminate the unused short‑declared variables inside the switch or to comment out the entire unused block, since none of its results influence the return values and flag is hardcoded to true.

The single best minimal‑behaviour‑preserving change is to remove the flag block and the switch entirely, leaving only the existing h.vm.Execute path that already determines the return values. This keeps the observable behaviour identical (because the flag block currently has no effects) and eliminates all the unused assignments (ret, leftoverGas, err, createAddr). If you prefer to keep the skeleton for future routing, you could instead comment out the block, but since you asked for a code fix, the cleanest solution is to delete it.

Concretely, in giga/executor/vm/evmc/host_context.go, within func (h *HostContext) Call(...), remove lines 152–167 containing flag := true, the if flag { ... } and the switch kind { ... } body. No new imports or helper methods are required.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -150,22 +150,9 @@
 	depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
 ) ([]byte, int64, int64, evmc.Address, error) {
 	// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
-	flag := true
-	if flag {
-		switch kind {
-		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
-		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
-		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
-		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
-		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
-		}
-	}
-	// ELSE
+	// NOTE: routing through h.evm (Call/DelegateCall/CallCode/Create/Create2) is not yet implemented here.
+	// The current implementation always executes via h.vm.Execute below.
+
 	evmRevision := evmc.Frontier
 	delegated := false
 	var code []byte
EOF
@@ -150,22 +150,9 @@
depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
) ([]byte, int64, int64, evmc.Address, error) {
// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
flag := true
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
// NOTE: routing through h.evm (Call/DelegateCall/CallCode/Create/Create2) is not yet implemented here.
// The current implementation always executes via h.vm.Execute below.

evmRevision := evmc.Frontier
delegated := false
var code []byte
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of createAddr is never used.

Copilot Autofix

AI 1 day ago

In general, to fix “useless assignment to local variable” you either (1) remove the unused variable and its assignment if the value is not needed, or (2) explicitly ignore the value using the blank identifier _ when you must call a function but do not care about one or more of its return values. This clarifies intent and avoids dead locals.

Here, the only place the issue arises is in the Create and Create2 cases in HostContext.Call, where createAddr is bound but never used. The existing behavior does not propagate this address anywhere—the method always returns evmc.Address{} with a TODO about populating it later. To fix the warning without changing functionality, keep the call to h.evm.Create / Create2 but replace createAddr with _ in the multiple assignment. This discards the address result explicitly and removes the unused local, while leaving ret, leftoverGas, and err handling exactly as before (noting that those are also currently unused, but CodeQL only flagged createAddr in the provided report).

Concretely: in giga/executor/vm/evmc/host_context.go, in the HostContext.Call method’s switch kind statement, change the Create and Create2 cases from ret, createAddr, leftoverGas, err := ... to ret, _, leftoverGas, err := .... No imports or additional definitions are required.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -160,9 +160,9 @@
 		case evmc.CallCode:
 			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			ret, _, leftoverGas, err := h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			ret, _, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -160,9 +160,9 @@
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
ret, _, leftoverGas, err := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
ret, _, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of leftoverGas is never used.

Copilot Autofix

AI 1 day ago

To fix the problem without changing existing behavior, we should avoid declaring local variables for return values that are never read. In Go, when the result of a function call is not needed, we can either (a) not capture it at all (just call the function), or (b) bind unwanted results to the blank identifier _. Since none of the return values from the h.evm.* calls are used anywhere, we can safely replace the named assignments with assignments to _, keeping the calls (and any side effects) while eliminating the unused local variables.

Specifically, in giga/executor/vm/evmc/host_context.go, inside func (h *HostContext) Call(...), at the switch kind { ... } block under if flag {, we should change:

  • ret, leftoverGas, err := ..._, _, _ = ...
  • ret, createAddr, leftoverGas, err := ..._, _, _, _ = ...

This preserves the fact that the underlying methods are invoked (and any side effects they may have) but stops introducing unused local variables like leftoverGas. No new imports or helper methods are required; only the variable bindings in this switch need adjustment.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			_, _, _ = h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			_, _, _ = h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			_, _, _ = h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			_, _, _, _ = h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			_, _, _, _ = h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
_, _, _ = h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
_, _, _ = h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
_, _, _ = h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
_, _, _, _ = h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
_, _, _, _ = h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of err is never used.

Copilot Autofix

AI 1 day ago

Generally, to fix this issue you either (a) remove dead assignments entirely, or (b) if you must call the function for its side effects but don’t use some or all return values, assign those to the blank identifier _ instead of named locals. This prevents creation of unused variables and makes the intent explicit.

For this specific HostContext.Call method in giga/executor/vm/evmc/host_context.go, we want to preserve the call to the underlying h.evm.* methods (in case they have side effects) but avoid introducing unused local variables ret, leftoverGas, createAddr, and err. The simplest change is:

  • In each case of the switch kind (lines 156–165), replace ret, leftoverGas, err := ... with _, _, _ = ... and ret, createAddr, leftoverGas, err := ... with _, _, _, _ = .... This keeps the calls while discarding all return values.
  • Do not touch the later executionResult, err := h.vm.Execute(...) or its subsequent if err != nil block, since that is the err actually used for control flow.
  • No new imports or helper functions are needed.

This keeps existing behavior (still calling the h.evm.* methods when flag is true) while eliminating the useless assignments that CodeQL flagged.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			_, _, _ = h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			_, _, _ = h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			_, _, _ = h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			_, _, _, _ = h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			_, _, _, _ = h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
_, _, _ = h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
_, _, _ = h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
_, _, _ = h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
_, _, _, _ = h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
_, _, _, _ = h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of ret is never used.

Copilot Autofix

AI 1 day ago

In general, to fix a “useless assignment to local variable” where a function is called only for side effects and the return values are intentionally ignored, you should replace the named variables with the blank identifier _. This keeps the call and its side effects, while making it explicit that the results are unused and eliminating unused‑variable warnings.

Here, inside HostContext.Call, for each case in the switch kind, we should keep the calls to h.evm.Call, DelegateCall, CallCode, Create, and Create2 (assuming they are needed for side effects) but stop assigning their return values to named locals that are never read. The minimal, behavior‑preserving change is to replace e.g.:

ret, leftoverGas, err := h.evm.Call(...)

with:

_, _, _ = h.evm.Call(...)

and similarly for the other cases, using the appropriate number of _ placeholders. This change is entirely local to giga/executor/vm/evmc/host_context.go within the Call method’s switch block, and it does not require any new imports or type changes.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -154,15 +154,15 @@
 	if flag {
 		switch kind {
 		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
+			_, _, _ = h.evm.Call(caller, addr, input, gas, value)
 		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
+			_, _, _ = h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
 		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
+			_, _, _ = h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			_, _, _, _ = h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			_, _, _, _ = h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -154,15 +154,15 @@
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
_, _, _ = h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
_, _, _ = h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
_, _, _ = h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
_, _, _, _ = h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
_, _, _, _ = h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of createAddr is never used.

Copilot Autofix

AI 1 day ago

In general, to fix "useless assignment to local variable" you either (1) remove the unused variable and its assignment, or (2) if the value must be computed for side effects, assign it to the blank identifier _ for any parts that are intentionally unused. Here, createAddr is returned by h.evm.Create / Create2 but not used anywhere, while the function’s public API already has a dedicated return slot for the create address (4th return value), which is currently always evmc.Address{}. The cleanest fix, without changing existing external behavior, is to stop binding the unused result to a named variable and instead assign it to _. This preserves the function calls and their side effects while eliminating the unused local variable.

Concretely, in giga/executor/vm/evmc/host_context.go within HostContext.Call, change the Create and Create2 cases so that they use _ instead of createAddr in the multiple assignment from h.evm.Create and h.evm.Create2. No other logic or return values are altered, and you do not need any new imports or helper methods.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -160,9 +160,9 @@
 		case evmc.CallCode:
 			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
 		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
+			ret, _, leftoverGas, err := h.evm.Create(caller, code, gas, value)
 		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
+			ret, _, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
 		}
 	}
 	// ELSE
EOF
@@ -160,9 +160,9 @@
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
ret, _, leftoverGas, err := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
ret, _, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of leftoverGas is never used.

Copilot Autofix

AI 1 day ago

In general, to fix a "useless assignment to local variable" where a value is never read, you either remove the variable from the assignment list or eliminate the whole statement if all assigned variables are unused. If you must still call the function for its side effects but do not need some return values, you can assign them to the blank identifier _ instead of naming them, or ignore all results.

In this specific function, the if flag { ... } block does not affect the function’s return values or control flow: flag is always true, but everything inside the switch only declares case-local variables that are never read. The real execution and returned values come from the later h.vm.Execute call. The cleanest fix that doesn’t change visible behavior is to remove the entire if flag { ... } block (including the flag := true line), because it is dead code and the methods (h.evm.Call, DelegateCall, etc.) are not contributing to the result. This automatically removes the unused leftoverGas definition (line 165) and the other unused locals.

Concretely, in giga/executor/vm/evmc/host_context.go, in the Call method, delete lines 153–167:

  • Remove flag := true.
  • Remove the if flag { ... } block and its switch kind with the h.evm.* calls.

No new imports, methods, or definitions are needed, and the rest of the function (the // ELSE section starting at line 169) remains unchanged.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -150,21 +150,6 @@
 	depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
 ) ([]byte, int64, int64, evmc.Address, error) {
 	// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
-	flag := true
-	if flag {
-		switch kind {
-		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
-		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
-		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
-		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
-		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
-		}
-	}
 	// ELSE
 	evmRevision := evmc.Frontier
 	delegated := false
EOF
@@ -150,21 +150,6 @@
depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
) ([]byte, int64, int64, evmc.Address, error) {
// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
flag := true
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
evmRevision := evmc.Frontier
delegated := false
Copilot is powered by AI and may make mistakes. Always verify output.

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of err is never used.

Copilot Autofix

AI 1 day ago

In general, to fix "useless assignment to local variable" issues, remove assignments whose results are never read, or, if you only need side effects, avoid binding the returned values. In this case, the entire flag/switch block only assigns to local variables (ret, leftoverGas, err, createAddr) that are never used, and the branch is guarded by a constant flag := true, so the block is always executed but has no effect on the returned values.

The best fix that preserves existing observable behavior is to remove this dead if flag { switch ... } block entirely. Currently, the function's behavior is fully determined by the later h.vm.Execute call and its error handling; removing the dead code does not change that. Specifically, in giga/executor/vm/evmc/host_context.go, lines 152–167 (the flag := true declaration, the if flag { and the entire switch kind { ... } body, and the closing brace) should be deleted, leaving the // ELSE comment and subsequent Execute call untouched. No new imports, methods, or definitions are required.

Suggested changeset 1
giga/executor/vm/evmc/host_context.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/giga/executor/vm/evmc/host_context.go b/giga/executor/vm/evmc/host_context.go
--- a/giga/executor/vm/evmc/host_context.go
+++ b/giga/executor/vm/evmc/host_context.go
@@ -150,21 +150,6 @@
 	depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
 ) ([]byte, int64, int64, evmc.Address, error) {
 	// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
-	flag := true
-	if flag {
-		switch kind {
-		case evmc.Call:
-			ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
-		case evmc.DelegateCall:
-			ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
-		case evmc.CallCode:
-			ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
-		case evmc.Create:
-			ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
-		case evmc.Create2:
-			ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
-		}
-	}
 	// ELSE
 	evmRevision := evmc.Frontier
 	delegated := false
EOF
@@ -150,21 +150,6 @@
depth int, static bool, salt evmc.Hash, codeAddress evmc.Address,
) ([]byte, int64, int64, evmc.Address, error) {
// evmc -> opdelegatecall -> HostContext.Call (here we should route ) -> evm.DelegateCall -> intepreter.Run -> HostContext.Call
flag := true
if flag {
switch kind {
case evmc.Call:
ret, leftoverGas, err := h.evm.Call(caller, addr, input, gas, value)
case evmc.DelegateCall:
ret, leftoverGas, err := h.evm.DelegateCall(originCaller, caller, addr, input, gas, value)
case evmc.CallCode:
ret, leftoverGas, err := h.evm.CallCode(caller, addr, input, gas, value)
case evmc.Create:
ret, createAddr, leftoverGas, err := h.evm.Create(caller, code, gas, value)
case evmc.Create2:
ret, createAddr, leftoverGas, err := h.evm.Create2(caller, code, gas, endowment, salt)
}
}
// ELSE
evmRevision := evmc.Frontier
delegated := false
Copilot is powered by AI and may make mistakes. Always verify output.
}
}
// ELSE
evmRevision := evmc.Frontier
delegated := false
var code []byte
executionResult, err := h.vm.Execute(
h, evmRevision, kind, static, delegated, depth,
gas, recipient, sender, input, value, code,
)
if err != nil {
return nil, 0, 0, [20]byte{}, err
}

//todo(pdrobnjak): figure out how to populate createAddr
return executionResult.Output, executionResult.GasLeft, executionResult.GasRefund, evmc.Address{}, nil
}

func (h *HostContext) AccessAccount(addr evmc.Address) evmc.AccessStatus {
addrInAccessList := h.evm.StateDB.AddressInAccessList(common.Address(addr))
if addrInAccessList {
return evmc.WarmAccess
}
// todo(pdrobnjak): poll something similar to - https://github.com/sei-protocol/sei-v3/blob/cd50388d4d423501b15a544612643073680aa8de/execute/store/types/types.go#L23 - temporarily we can expose access via our statedb impl for testing
return evmc.ColdAccess
}

func (h *HostContext) AccessStorage(addr evmc.Address, key evmc.Hash) evmc.AccessStatus {
addrInAccessList, slotInAccessList := h.evm.StateDB.SlotInAccessList(common.Address(addr), common.Hash(key))
if addrInAccessList && slotInAccessList {
return evmc.WarmAccess
}
// todo(pdrobnjak): poll something similar to - https://github.com/sei-protocol/sei-v3/blob/cd50388d4d423501b15a544612643073680aa8de/execute/store/types/types.go#L22 - temporarily we can expose access via our statedb impl for testing
return evmc.ColdAccess
}

func (h *HostContext) GetTransientStorage(addr evmc.Address, key evmc.Hash) evmc.Hash {
return evmc.Hash(h.evm.StateDB.GetTransientState(common.Address(addr), common.Hash(key)))
}

func (h *HostContext) SetTransientStorage(addr evmc.Address, key evmc.Hash, value evmc.Hash) {
h.evm.StateDB.SetTransientState(common.Address(addr), common.Hash(key), common.Hash(value))
}
54 changes: 54 additions & 0 deletions giga/executor/vm/evmc/interpreter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package evmc

import (
"github.com/ethereum/evmc/v12/bindings/go/evmc"
"github.com/ethereum/go-ethereum/core/vm"
)

var _ vm.IEVMInterpreter = (*EVMInterpreter)(nil)

type EVMInterpreter struct {
hostContext evmc.HostContext
evm *vm.EVM
readOnly bool
}

func NewEVMInterpreter(hostContext evmc.HostContext, evm *vm.EVM) *EVMInterpreter {
return &EVMInterpreter{hostContext: hostContext, evm: evm}
}

func (e *EVMInterpreter) Run(contract *vm.Contract, input []byte, readOnly bool) ([]byte, error) {
// todo(pdrobnjak): figure out if there is a way to avoid this, probably not, I'll have to replicate every interpreter side effect
// PASTED FROM GETH
// Increment the call depth which is restricted to 1024
e.evm.depth++
defer func() { e.evm.depth-- }()

// Make sure the readOnly is only set if we aren't in readOnly yet.
// This also makes sure that the readOnly flag isn't removed for child calls.
if readOnly && !e.readOnly {
e.readOnly = true
defer func() { e.readOnly = false }()
}
// PASTED FROM GETH

// todo(pdrobnjak): figure out how to access these values and how to validate if they are populated correctly
callKind := evmc.Call
recipient := evmc.Address{}
sender := evmc.Address{}
static := false
// irrelevant as it is only used for CREATE2 - geth is handling our CREATE2 logic
salt := evmc.Hash{}
codeAddress := evmc.Address{}
output, _, _, _, err := e.hostContext.Call(callKind, recipient, sender, contract.Value().Bytes32(), input,
int64(contract.Gas), e.evm.GetDepth(), static, salt, codeAddress)
if err != nil {
return nil, err
}

return output, nil
}

func (e *EVMInterpreter) ReadOnly() bool {
return e.readOnly
}
36 changes: 16 additions & 20 deletions giga/executor/vm/evmc/vm.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
package evmc

import (
"math"

"github.com/ethereum/evmc/v12/bindings/go/evmc"
"github.com/sei-protocol/sei-chain/giga/executor/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/params"
)

type VMImpl struct {
hostContext evmc.HostContext
}

func NewVM(hostContext evmc.HostContext) types.VM {
return &VMImpl{hostContext: hostContext}
evm *vm.EVM
}

func (v *VMImpl) Create(sender types.Address, code []byte, gas uint64, value types.Hash) (ret []byte, contractAddr types.Address, gasLeft uint64, err error) {
if gas > math.MaxInt64 {
panic("gas overflow")
// this should bootstrap evmone - receive a configuration or something similar, we can do it the same way we did in v3
func NewVM(blockCtx vm.BlockContext, stateDB vm.StateDB, chainConfig *params.ChainConfig, config vm.Config, customPrecompiles map[common.Address]vm.PrecompiledContract) *VMImpl {
evm := vm.NewEVM(blockCtx, stateDB, chainConfig, config, customPrecompiles)
// todo(pdrobnjak): populate evmc.VM
hostContext := NewHostContext(nil, evm)
evm.EVMInterpreter = NewEVMInterpreter(hostContext, evm)
return &VMImpl{
evm: evm,
}
ret, left, _, addr, err := v.hostContext.Call(evmc.Create, evmc.Address{}, evmc.Address(sender), evmc.Hash(value), code, int64(gas), 0, false, evmc.Hash{}, evmc.Address{})
return ret, types.Address(addr), uint64(left), err //nolint:gosec
}

func (v *VMImpl) Call(sender types.Address, to types.Address, input []byte, gas uint64, value types.Hash) (ret []byte, gasLeft uint64, err error) {
if gas > math.MaxInt64 {
panic("gas overflow")
}
ret, left, _, _, err := v.hostContext.Call(evmc.Call, evmc.Address(to), evmc.Address(sender), evmc.Hash(value), input, int64(gas), 0, false, evmc.Hash{}, evmc.Address(to))
return ret, uint64(left), err //nolint:gosec
func (v *VMImpl) ApplyMessage(msg *core.Message, gp *core.GasPool) (*core.ExecutionResult, error) {
executionResult, err := core.ApplyMessage(v.evm, msg, gp)
return executionResult, err
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ replace (
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.2
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => ./sei-cosmos
github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.15.7-sei-7.0.20250929182230-93350978bb7c
github.com/ethereum/go-ethereum => ../go-ethereum
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
// Latest goleveldb is broken, we have to stick to this version
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1921,8 +1921,6 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/securego/gosec/v2 v2.13.1 h1:7mU32qn2dyC81MH9L2kefnQyRMUarfDER3iQyMHcjYM=
github.com/securego/gosec/v2 v2.13.1/go.mod h1:EO1sImBMBWFjOTFzMWfTRrZW6M15gm60ljzrmy/wtHo=
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/sei-protocol/go-ethereum v1.15.7-sei-7.0.20250929182230-93350978bb7c h1:p3Q8KgwlYEZW5Iyr/X6RJ63cezc+GG3tVQ3BCnfxEgo=
github.com/sei-protocol/go-ethereum v1.15.7-sei-7.0.20250929182230-93350978bb7c/go.mod h1:+S9k+jFzlyVTNcYGvqFhzN/SFhI6vA+aOY4T5tLSPL0=
github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA=
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
github.com/sei-protocol/sei-load v0.0.0-20251007135253-78fbdc141082 h1:f2sY8OcN60UL1/6POx+HDMZ4w04FTZtSScnrFSnGZHg=
Expand Down
2 changes: 2 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ use (
./sei-cosmos
./sei-tendermint
)

replace github.com/ethereum/go-ethereum => ../go-ethereum
Loading
Loading