aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/execution.go4
-rw-r--r--tests/files/StateTests/stPreCompiledContracts.json42
-rw-r--r--tests/files/StateTests/stSystemOperationsTest.json16
-rw-r--r--tests/files/VMTests/RandomTests/randomTest.json46
-rw-r--r--tests/files/VMTests/vmSha3Test.json2
-rw-r--r--vm/common.go2
-rw-r--r--vm/virtual_machine.go1
-rw-r--r--vm/vm_debug.go19
8 files changed, 85 insertions, 47 deletions
diff --git a/core/execution.go b/core/execution.go
index 5176f7351..a464abc66 100644
--- a/core/execution.go
+++ b/core/execution.go
@@ -32,7 +32,7 @@ func (self *Execution) Call(codeAddr []byte, caller vm.ClosureRef) ([]byte, erro
return self.exec(code, codeAddr, caller)
}
-func (self *Execution) exec(code, caddr []byte, caller vm.ClosureRef) (ret []byte, err error) {
+func (self *Execution) exec(code, contextAddr []byte, caller vm.ClosureRef) (ret []byte, err error) {
env := self.vm.Env()
chainlogger.Debugf("pre state %x\n", env.State().Root())
@@ -57,7 +57,7 @@ func (self *Execution) exec(code, caddr []byte, caller vm.ClosureRef) (ret []byt
} else {
self.object = to
// Pre-compiled contracts (address.go) 1, 2 & 3.
- naddr := ethutil.BigD(caddr).Uint64()
+ naddr := ethutil.BigD(contextAddr).Uint64()
if p := vm.Precompiled[naddr]; p != nil {
if self.Gas.Cmp(p.Gas(len(self.input))) >= 0 {
ret = p.Call(self.input)
diff --git a/tests/files/StateTests/stPreCompiledContracts.json b/tests/files/StateTests/stPreCompiledContracts.json
index 5830ecafc..0f1db1275 100644
--- a/tests/files/StateTests/stPreCompiledContracts.json
+++ b/tests/files/StateTests/stPreCompiledContracts.json
@@ -726,14 +726,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "1232",
+ "balance" : "1182",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999898768",
+ "balance" : "999999999999898818",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -796,14 +796,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "1236",
+ "balance" : "1286",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999898764",
+ "balance" : "999999999999898714",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -866,14 +866,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "1236",
+ "balance" : "1286",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999898764",
+ "balance" : "999999999999898714",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -1070,19 +1070,18 @@
"code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000620f42406000600060036101f4f1600255600051600055",
"nonce" : "0",
"storage" : {
- "0x" : "0x953450193f7389363135b31dc0f371f22f3947db",
- "0x02" : "0x01"
+ "0x" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "32484",
+ "balance" : "32684",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999867516",
+ "balance" : "999999999999867316",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -1214,14 +1213,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "1232",
+ "balance" : "1182",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999898768",
+ "balance" : "999999999999898818",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -1284,14 +1283,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "1232",
+ "balance" : "1182",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999898768",
+ "balance" : "999999999999898818",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -1354,14 +1353,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "1236",
+ "balance" : "1286",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999898764",
+ "balance" : "999999999999898714",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -1424,14 +1423,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "1236",
+ "balance" : "1286",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999898764",
+ "balance" : "999999999999898714",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -1628,19 +1627,18 @@
"code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005260206000620f42406000600060026101f4f1600255600051600055",
"nonce" : "0",
"storage" : {
- "0x" : "0x739d5000bbe364e92a2fe28d62c17a6dfd4f32105420c30b97ec0180300a2dae",
- "0x02" : "0x01"
+ "0x" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "32484",
+ "balance" : "32684",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999867516",
+ "balance" : "999999999999867316",
"code" : "0x",
"nonce" : "1",
"storage" : {
diff --git a/tests/files/StateTests/stSystemOperationsTest.json b/tests/files/StateTests/stSystemOperationsTest.json
index 64915bead..8a7e0e6c3 100644
--- a/tests/files/StateTests/stSystemOperationsTest.json
+++ b/tests/files/StateTests/stSystemOperationsTest.json
@@ -5144,14 +5144,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "917",
+ "balance" : "997",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999899083",
+ "balance" : "999999999999899003",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -5388,14 +5388,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "507",
+ "balance" : "512",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999899493",
+ "balance" : "999999999999899488",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -5449,14 +5449,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "507",
+ "balance" : "517",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999899493",
+ "balance" : "999999999999899483",
"code" : "0x",
"nonce" : "1",
"storage" : {
@@ -5510,14 +5510,14 @@
}
},
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
- "balance" : "508",
+ "balance" : "673",
"code" : "0x",
"nonce" : "0",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
- "balance" : "999999999999899492",
+ "balance" : "999999999999899327",
"code" : "0x",
"nonce" : "1",
"storage" : {
diff --git a/tests/files/VMTests/RandomTests/randomTest.json b/tests/files/VMTests/RandomTests/randomTest.json
new file mode 100644
index 000000000..dad2ee4a2
--- /dev/null
+++ b/tests/files/VMTests/RandomTests/randomTest.json
@@ -0,0 +1,46 @@
+{
+ "randomVMtest" : {
+ "callcreates" : [
+ ],
+ "env" : {
+ "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
+ "currentDifficulty" : "256",
+ "currentGasLimit" : "1000000",
+ "currentNumber" : "0",
+ "currentTimestamp" : "1",
+ "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
+ },
+ "exec" : {
+ "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
+ "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "code" : "0x675545",
+ "data" : "0x",
+ "gas" : "10000",
+ "gasPrice" : "100000000000000",
+ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
+ "value" : "1000000000000000000"
+ },
+ "gas" : "9999",
+ "logs" : [
+ ],
+ "out" : "0x",
+ "post" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x675545",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ },
+ "pre" : {
+ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
+ "balance" : "1000000000000000000",
+ "code" : "0x675545",
+ "nonce" : "0",
+ "storage" : {
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/files/VMTests/vmSha3Test.json b/tests/files/VMTests/vmSha3Test.json
index bd430ec9d..b9e6b46a1 100644
--- a/tests/files/VMTests/vmSha3Test.json
+++ b/tests/files/VMTests/vmSha3Test.json
@@ -20,7 +20,7 @@
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "1000000000000000000"
},
- "gas" : "99999999677",
+ "gas" : "99999999687",
"logs" : [
],
"out" : "0x",
diff --git a/vm/common.go b/vm/common.go
index 5fd512687..592d44ccd 100644
--- a/vm/common.go
+++ b/vm/common.go
@@ -20,7 +20,7 @@ const (
var (
GasStep = big.NewInt(1)
- GasSha = big.NewInt(20)
+ GasSha = big.NewInt(10)
GasSLoad = big.NewInt(20)
GasSStore = big.NewInt(100)
GasSStoreRefund = big.NewInt(100)
diff --git a/vm/virtual_machine.go b/vm/virtual_machine.go
index 5738075fb..3b6f98ab2 100644
--- a/vm/virtual_machine.go
+++ b/vm/virtual_machine.go
@@ -5,7 +5,6 @@ import "math/big"
type VirtualMachine interface {
Env() Environment
Run(me, caller ClosureRef, code []byte, value, gas, price *big.Int, data []byte) ([]byte, error)
- Depth() int
Printf(string, ...interface{}) VirtualMachine
Endl() VirtualMachine
}
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index 5b7258cc5..e9139ae19 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -25,8 +25,6 @@ type DebugVm struct {
Fn string
Recoverable bool
-
- depth int
}
func NewDebugVm(env Environment) *DebugVm {
@@ -116,7 +114,7 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
return closure.Return(nil), nil
}
- vmlogger.Debugf("(%d) %x gas: %v (d) %x\n", self.depth, closure.Address(), closure.Gas, callData)
+ vmlogger.Debugf("(%d) %x gas: %v (d) %x\n", self.env.Depth(), closure.Address(), closure.Gas, callData)
for {
prevStep = step
@@ -867,14 +865,16 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
// Get the arguments from the memory
args := mem.Get(inOffset.Int64(), inSize.Int64())
- var executeAddr []byte
+ var (
+ ret []byte
+ err error
+ )
if op == CALLCODE {
- executeAddr = closure.Address()
+ ret, err = self.env.CallCode(closure, addr.Bytes(), args, gas, price, value)
} else {
- executeAddr = addr.Bytes()
+ ret, err = self.env.Call(closure, addr.Bytes(), args, gas, price, value)
}
- ret, err := self.env.Call(closure, executeAddr, args, gas, price, value)
if err != nil {
stack.Push(ethutil.BigFalse)
@@ -914,7 +914,6 @@ func (self *DebugVm) Run(me, caller ClosureRef, code []byte, value, gas, price *
default:
vmlogger.Debugf("(pc) %-3v Invalid opcode %x\n", pc, op)
- //panic(fmt.Sprintf("Invalid opcode %x", op))
closure.ReturnGas(big.NewInt(1), nil)
return closure.Return(nil), fmt.Errorf("Invalid opcode %x", op)
@@ -963,7 +962,3 @@ func (self *DebugVm) Endl() VirtualMachine {
func (self *DebugVm) Env() Environment {
return self.env
}
-
-func (self *DebugVm) Depth() int {
- return self.depth
-}