aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd/ethtest/main.go4
-rw-r--r--state/statedb.go18
-rw-r--r--tests/vm/gh_test.go6
-rw-r--r--vm/vm.go6
4 files changed, 21 insertions, 13 deletions
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go
index 7c4a727f6..cc5139da1 100644
--- a/cmd/ethtest/main.go
+++ b/cmd/ethtest/main.go
@@ -38,6 +38,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
+ "github.com/ethereum/go-ethereum/vm"
)
type Log struct {
@@ -164,7 +165,7 @@ func RunVmTest(r io.Reader) (failed int) {
}
if !bytes.Equal(ethutil.Hex2Bytes(test.PostStateRoot), statedb.Root()) {
- fmt.Printf("%s's : Post state root error. Expected %s, got %x", name, test.PostStateRoot, statedb.Root())
+ fmt.Printf("%s's : Post state root error. Expected %s, got %x\n", name, test.PostStateRoot, statedb.Root())
failed = 1
}
@@ -194,6 +195,7 @@ func RunVmTest(r io.Reader) (failed int) {
func main() {
helper.Logger.SetLogLevel(5)
+ vm.Debug = true
if len(os.Args) > 1 {
os.Exit(RunVmTest(strings.NewReader(os.Args[1])))
diff --git a/state/statedb.go b/state/statedb.go
index 0a4156461..a0dc7732f 100644
--- a/state/statedb.go
+++ b/state/statedb.go
@@ -54,7 +54,7 @@ func (self *StateDB) Refund(addr []byte, gas *big.Int) {
// Retrieve the balance from the given address or 0 if object not found
func (self *StateDB) GetBalance(addr []byte) *big.Int {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
return stateObject.balance
}
@@ -63,14 +63,14 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
}
func (self *StateDB) AddBalance(addr []byte, amount *big.Int) {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.AddBalance(amount)
}
}
func (self *StateDB) GetNonce(addr []byte) uint64 {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
return stateObject.nonce
}
@@ -79,7 +79,7 @@ func (self *StateDB) GetNonce(addr []byte) uint64 {
}
func (self *StateDB) GetCode(addr []byte) []byte {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
return stateObject.code
}
@@ -88,7 +88,7 @@ func (self *StateDB) GetCode(addr []byte) []byte {
}
func (self *StateDB) GetState(a, b []byte) []byte {
- stateObject := self.GetOrNewStateObject(a)
+ stateObject := self.GetStateObject(a)
if stateObject != nil {
return stateObject.GetState(b).Bytes()
}
@@ -97,28 +97,28 @@ func (self *StateDB) GetState(a, b []byte) []byte {
}
func (self *StateDB) SetNonce(addr []byte, nonce uint64) {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.SetNonce(nonce)
}
}
func (self *StateDB) SetCode(addr, code []byte) {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.SetCode(code)
}
}
func (self *StateDB) SetState(addr, key []byte, value interface{}) {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.SetState(key, ethutil.NewValue(value))
}
}
func (self *StateDB) Delete(addr []byte) bool {
- stateObject := self.GetOrNewStateObject(addr)
+ stateObject := self.GetStateObject(addr)
if stateObject != nil {
stateObject.MarkForDeletion()
stateObject.balance = new(big.Int)
diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go
index 959f20463..6195a684d 100644
--- a/tests/vm/gh_test.go
+++ b/tests/vm/gh_test.go
@@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
+ "github.com/ethereum/go-ethereum/vm"
)
type Account struct {
@@ -80,6 +81,11 @@ func RunVmTest(p string, t *testing.T) {
helper.CreateFileTests(t, p, &tests)
for name, test := range tests {
+ vm.Debug = true
+ helper.Logger.SetLogLevel(4)
+ if name != "signextend_Overflow_dj42" {
+ continue
+ }
db, _ := ethdb.NewMemDatabase()
statedb := state.New(nil, db)
for addr, account := range test.Pre {
diff --git a/vm/vm.go b/vm/vm.go
index 0cf1f9af3..97f2fef62 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -235,9 +235,9 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
stack.push(base)
case SIGNEXTEND:
- back := stack.pop().Uint64()
- if back < 31 {
- bit := uint(back*8 + 7)
+ back := stack.pop()
+ if back.Cmp(big.NewInt(31)) < 0 {
+ bit := uint(back.Uint64()*8 + 7)
num := stack.pop()
mask := new(big.Int).Lsh(ethutil.Big1, bit)
mask.Sub(mask, ethutil.Big1)