Skip to content

Commit

Permalink
criminal hacks
Browse files Browse the repository at this point in the history
Signed-off-by: Ignacio Hagopian <[email protected]>
  • Loading branch information
jsign committed Oct 12, 2024
1 parent 26452f4 commit 4d4eabc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,9 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
if err != nil || !scope.Contract.UseGas(dynamicCost) {
return nil, ErrOutOfGas
}
if memSize > 0 {
scope.Memory.Resize(memSize)
}

interpreter.evm.callGasTemp, err = callGas(interpreter.evm.chainRules.IsEIP150, scope.Contract.Gas, 0, scope.Stack.Back(0))
if err != nil {
Expand Down Expand Up @@ -886,6 +889,9 @@ func opCallCode(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([
if err != nil || !scope.Contract.UseGas(dynamicCost) {
return nil, ErrOutOfGas
}
if memSize > 0 {
scope.Memory.Resize(memSize)
}
interpreter.evm.callGasTemp, err = callGas(interpreter.evm.chainRules.IsEIP150, scope.Contract.Gas, 0, scope.Stack.Back(0))
if err != nil {
return nil, err
Expand Down Expand Up @@ -940,6 +946,9 @@ func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
if err != nil || !scope.Contract.UseGas(dynamicCost) {
return nil, ErrOutOfGas
}
if memSize > 0 {
scope.Memory.Resize(memSize)
}
interpreter.evm.callGasTemp, err = callGas(interpreter.evm.chainRules.IsEIP150, scope.Contract.Gas, 0, scope.Stack.Back(0))
if err != nil {
return nil, err
Expand Down Expand Up @@ -988,6 +997,9 @@ func opStaticCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
if err != nil || !scope.Contract.UseGas(dynamicCost) {
return nil, ErrOutOfGas
}
if memSize > 0 {
scope.Memory.Resize(memSize)
}
interpreter.evm.callGasTemp, err = callGas(interpreter.evm.chainRules.IsEIP150, scope.Contract.Gas, 0, scope.Stack.Back(0))
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
in.evm.Config.Tracer.CaptureState(pc, op, gasCopy, cost, callContext, in.returnData, in.evm.depth, err)
logged = true
}
if memorySize > 0 {
// TODO(hack): remove if conditions
if op != CALL && op != CALLCODE && op != DELEGATECALL && op != STATICCALL && memorySize > 0 {
mem.Resize(memorySize)
}
} else if debug {
Expand Down

0 comments on commit 4d4eabc

Please sign in to comment.