aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/instructions.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/vm/instructions.go')
-rw-r--r--core/vm/instructions.go40
1 files changed, 24 insertions, 16 deletions
diff --git a/core/vm/instructions.go b/core/vm/instructions.go
index 2e868521e..26f7671ff 100644
--- a/core/vm/instructions.go
+++ b/core/vm/instructions.go
@@ -337,7 +337,7 @@ func opOrigin(instr instruction, pc *uint64, env Environment, contract *Contract
}
func opCaller(instr instruction, pc *uint64, env Environment, contract *Contract, memory *Memory, stack *stack) {
- stack.push(common.Bytes2Big(contract.caller.Address().Bytes()))
+ stack.push(contract.Caller().Big())
}
func opCallValue(instr instruction, pc *uint64, env Environment, contract *Contract, memory *Memory, stack *stack) {
@@ -485,7 +485,6 @@ func opSload(instr instruction, pc *uint64, env Environment, contract *Contract,
func opSstore(instr instruction, pc *uint64, env Environment, contract *Contract, memory *Memory, stack *stack) {
loc := common.BigToHash(stack.pop())
val := stack.pop()
-
env.Db().SetState(contract.Address(), loc, common.BigToHash(val))
}
@@ -514,25 +513,19 @@ func opCreate(instr instruction, pc *uint64, env Environment, contract *Contract
offset, size = stack.pop(), stack.pop()
input = memory.Get(offset.Int64(), size.Int64())
gas = new(big.Int).Set(contract.Gas)
- addr common.Address
- ret []byte
- suberr error
)
-
contract.UseGas(contract.Gas)
- ret, addr, suberr = env.Create(contract, input, gas, contract.Price, value)
- if suberr != nil {
+ _, addr, suberr := env.Create(contract, input, gas, contract.Price, value)
+ // Push item on the stack based on the returned error. If the ruleset is
+ // homestead we must check for CodeStoreOutOfGasError (homestead only
+ // rule) and treat as an error, if the ruleset is frontier we must
+ // ignore this error and pretend the operation was successful.
+ if params.IsHomestead(env.BlockNumber()) && suberr == CodeStoreOutOfGasError {
+ stack.push(new(big.Int))
+ } else if suberr != nil && suberr != CodeStoreOutOfGasError {
stack.push(new(big.Int))
} else {
- // gas < len(ret) * Createinstr.dataGas == NO_CODE
- dataGas := big.NewInt(int64(len(ret)))
- dataGas.Mul(dataGas, params.CreateDataGas)
- if contract.UseGas(dataGas) {
- env.Db().SetCode(addr, ret)
- }
-
stack.push(addr.Big())
-
}
}
@@ -598,6 +591,21 @@ func opCallCode(instr instruction, pc *uint64, env Environment, contract *Contra
}
}
+func opDelegateCall(instr instruction, pc *uint64, env Environment, contract *Contract, memory *Memory, stack *stack) {
+ gas, to, inOffset, inSize, outOffset, outSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
+
+ toAddr := common.BigToAddress(to)
+ args := memory.Get(inOffset.Int64(), inSize.Int64())
+ ret, err := env.DelegateCall(contract, toAddr, args, gas, contract.Price)
+
+ if err != nil {
+ stack.push(new(big.Int))
+ } else {
+ stack.push(big.NewInt(1))
+ memory.Set(outOffset.Uint64(), outSize.Uint64(), ret)
+ }
+}
+
func opReturn(instr instruction, pc *uint64, env Environment, contract *Contract, memory *Memory, stack *stack) {
}
func opStop(instr instruction, pc *uint64, env Environment, contract *Contract, memory *Memory, stack *stack) {