Merge branch 'develop' of github.com:ethereum/eth-go into feature/ethutil-refactor
This commit is contained in:
commit
44d0d6abd2
@ -182,11 +182,24 @@ func (sm *StateManager) Process(block *Block, dontReact bool) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if len(receipts) == len(block.Receipts()) {
|
if len(receipts) == len(block.Receipts()) {
|
||||||
for i, receipt := range block.Receipts() {
|
for i, receipt := range block.Receipts() {
|
||||||
statelogger.Debugf("diff (r) %v ~ %x <=> (c) %v ~ %x (%x)\n", receipt.CumulativeGasUsed, receipt.PostState[0:4], receipts[i].CumulativeGasUsed, receipts[i].PostState[0:4], receipt.Tx.Hash())
|
statelogger.Infof("diff (r) %v ~ %x <=> (c) %v ~ %x (%x)\n", receipt.CumulativeGasUsed, receipt.PostState[0:4], receipts[i].CumulativeGasUsed, receipts[i].PostState[0:4], receipt.Tx.Hash())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
statelogger.Warnln("Unable to print receipt diff. Length didn't match", len(receipts), "for", len(block.Receipts()))
|
statelogger.Warnln("Unable to print receipt diff. Length didn't match", len(receipts), "for", len(block.Receipts()))
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
for i, receipt := range receipts {
|
||||||
|
gu := new(big.Int)
|
||||||
|
if i != 0 {
|
||||||
|
gu.Sub(receipt.CumulativeGasUsed, receipts[i-1].CumulativeGasUsed)
|
||||||
|
} else {
|
||||||
|
gu.Set(receipt.CumulativeGasUsed)
|
||||||
|
}
|
||||||
|
|
||||||
|
statelogger.Infof("[r] %v ~ %x (%x)\n", gu, receipt.PostState[0:4], receipt.Tx.Hash())
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -201,8 +201,7 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
// script section for the state object.
|
// script section for the state object.
|
||||||
self.data = nil
|
self.data = nil
|
||||||
|
|
||||||
statelogger.Debugln("~> init")
|
code, err := self.Eval(receiver.Init(), receiver, "init")
|
||||||
code, err := self.Eval(receiver.Init(), receiver)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//self.state.Set(snapshot)
|
//self.state.Set(snapshot)
|
||||||
self.state.ResetStateObject(receiver)
|
self.state.ResetStateObject(receiver)
|
||||||
@ -213,8 +212,7 @@ func (self *StateTransition) TransitionState() (err error) {
|
|||||||
receiver.script = code
|
receiver.script = code
|
||||||
} else {
|
} else {
|
||||||
if len(receiver.Script()) > 0 {
|
if len(receiver.Script()) > 0 {
|
||||||
statelogger.Debugln("~> code")
|
_, err = self.Eval(receiver.Script(), receiver, "code")
|
||||||
_, err = self.Eval(receiver.Script(), receiver)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//self.state.Set(snapshot)
|
//self.state.Set(snapshot)
|
||||||
self.state.ResetStateObject(receiver)
|
self.state.ResetStateObject(receiver)
|
||||||
@ -240,7 +238,7 @@ func (self *StateTransition) transferValue(sender, receiver *StateObject) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StateTransition) Eval(script []byte, context *StateObject) (ret []byte, err error) {
|
func (self *StateTransition) Eval(script []byte, context *StateObject, typ string) (ret []byte, err error) {
|
||||||
var (
|
var (
|
||||||
block = self.block
|
block = self.block
|
||||||
initiator = self.Sender()
|
initiator = self.Sender()
|
||||||
@ -259,6 +257,7 @@ func (self *StateTransition) Eval(script []byte, context *StateObject) (ret []by
|
|||||||
Value: self.value,
|
Value: self.value,
|
||||||
})
|
})
|
||||||
vm.Verbose = true
|
vm.Verbose = true
|
||||||
|
vm.Fn = typ
|
||||||
|
|
||||||
ret, err = Call(vm, closure, self.data)
|
ret, err = Call(vm, closure, self.data)
|
||||||
|
|
||||||
@ -279,7 +278,7 @@ func Call(vm *Vm, closure *Closure, data []byte) (ret []byte, err error) {
|
|||||||
// TODO FIXME ASAP
|
// TODO FIXME ASAP
|
||||||
context.state.trie = t2
|
context.state.trie = t2
|
||||||
|
|
||||||
statelogger.Debugln("Warn: PARANOIA: Different state object roots during copy")
|
statelogger.Infoln("Warn: PARANOIA: Different state object roots during copy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ type Vm struct {
|
|||||||
Hook DebugHook
|
Hook DebugHook
|
||||||
BreakPoints []int64
|
BreakPoints []int64
|
||||||
Stepping bool
|
Stepping bool
|
||||||
|
Fn string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DebugHook func(step int, op OpCode, mem *Memory, stack *Stack, stateObject *StateObject) bool
|
type DebugHook func(step int, op OpCode, mem *Memory, stack *Stack, stateObject *StateObject) bool
|
||||||
@ -107,7 +108,7 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
vmlogger.Debugf("(~) %x gas: %v (d) %x\n", closure.object.Address(), closure.Gas, closure.Args)
|
vmlogger.Debugf("(%s) %x gas: %v (d) %x\n", vm.Fn, closure.object.Address(), closure.Gas, closure.Args)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
op OpCode
|
op OpCode
|
||||||
@ -577,7 +578,7 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
|
|
||||||
stack.Push(val.BigInt())
|
stack.Push(val.BigInt())
|
||||||
|
|
||||||
vm.Printf(" {0x%x} 0x%x", loc.Bytes(), val.Bytes())
|
vm.Printf(" {0x%x : 0x%x}", loc.Bytes(), val.Bytes())
|
||||||
case SSTORE:
|
case SSTORE:
|
||||||
require(2)
|
require(2)
|
||||||
val, loc := stack.Popn()
|
val, loc := stack.Popn()
|
||||||
@ -586,7 +587,7 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
|
|||||||
// Add the change to manifest
|
// Add the change to manifest
|
||||||
vm.state.manifest.AddStorageChange(closure.Object(), loc.Bytes(), val)
|
vm.state.manifest.AddStorageChange(closure.Object(), loc.Bytes(), val)
|
||||||
|
|
||||||
vm.Printf(" {0x%x} 0x%x", loc, val)
|
vm.Printf(" {0x%x : 0x%x}", loc, val)
|
||||||
case JUMP:
|
case JUMP:
|
||||||
require(1)
|
require(1)
|
||||||
pc = stack.Pop()
|
pc = stack.Pop()
|
||||||
|
@ -217,7 +217,7 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, sc
|
|||||||
if ethutil.IsHex(scriptStr) {
|
if ethutil.IsHex(scriptStr) {
|
||||||
script = ethutil.Hex2Bytes(scriptStr[2:])
|
script = ethutil.Hex2Bytes(scriptStr[2:])
|
||||||
} else {
|
} else {
|
||||||
script, err = ethutil.Compile(scriptStr)
|
script, err = ethutil.Compile(scriptStr, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// General compile function
|
// General compile function
|
||||||
func Compile(script string) (ret []byte, err error) {
|
func Compile(script string, silent bool) (ret []byte, err error) {
|
||||||
if len(script) > 2 {
|
if len(script) > 2 {
|
||||||
line := strings.Split(script, "\n")[0]
|
line := strings.Split(script, "\n")[0]
|
||||||
|
|
||||||
if line[0:2] == "#!" {
|
if len(line) > 1 && line[0:2] == "#!" {
|
||||||
switch line {
|
switch line {
|
||||||
case "#!serpent":
|
case "#!serpent":
|
||||||
byteCode, err := serpent.Compile(script)
|
byteCode, err := serpent.Compile(script)
|
||||||
@ -26,6 +26,7 @@ func Compile(script string) (ret []byte, err error) {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
compiler := mutan.NewCompiler(backend.NewEthereumBackend())
|
compiler := mutan.NewCompiler(backend.NewEthereumBackend())
|
||||||
|
compiler.Silent = silent
|
||||||
byteCode, errors := compiler.Compile(strings.NewReader(script))
|
byteCode, errors := compiler.Compile(strings.NewReader(script))
|
||||||
if len(errors) > 0 {
|
if len(errors) > 0 {
|
||||||
var errs string
|
var errs string
|
||||||
|
Loading…
Reference in New Issue
Block a user