mirror of https://github.com/poanetwork/quorum.git
merge upstream; fix port in use warning; new logger API
This commit is contained in:
commit
da38faa8f7
|
@ -18,7 +18,7 @@ func Disassemble(script []byte) (asm []string) {
|
||||||
// Get the opcode (it must be an opcode!)
|
// Get the opcode (it must be an opcode!)
|
||||||
op := OpCode(val)
|
op := OpCode(val)
|
||||||
|
|
||||||
asm = append(asm, fmt.Sprintf("%v", op))
|
asm = append(asm, fmt.Sprintf("%04v: %v", pc, op))
|
||||||
|
|
||||||
switch op {
|
switch op {
|
||||||
case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32:
|
case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32:
|
||||||
|
@ -28,7 +28,7 @@ func Disassemble(script []byte) (asm []string) {
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
data = []byte{0}
|
data = []byte{0}
|
||||||
}
|
}
|
||||||
asm = append(asm, fmt.Sprintf("0x%x", data))
|
asm = append(asm, fmt.Sprintf("%04v: 0x%x", pc, data))
|
||||||
|
|
||||||
pc.Add(pc, big.NewInt(a-1))
|
pc.Add(pc, big.NewInt(a-1))
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,18 +176,12 @@ func (bc *BlockChain) ResetTillBlockHash(hash []byte) error {
|
||||||
bc.LastBlockHash = bc.genesisBlock.Hash()
|
bc.LastBlockHash = bc.genesisBlock.Hash()
|
||||||
bc.LastBlockNumber = 1
|
bc.LastBlockNumber = 1
|
||||||
} else {
|
} else {
|
||||||
// TODO: Somehow this doesn't really give the right numbers, double check.
|
|
||||||
// TODO: Change logs into debug lines
|
|
||||||
returnTo = bc.GetBlock(hash)
|
returnTo = bc.GetBlock(hash)
|
||||||
bc.CurrentBlock = returnTo
|
bc.CurrentBlock = returnTo
|
||||||
bc.LastBlockHash = returnTo.Hash()
|
bc.LastBlockHash = returnTo.Hash()
|
||||||
//info := bc.BlockInfo(returnTo)
|
|
||||||
bc.LastBlockNumber = returnTo.Number.Uint64()
|
bc.LastBlockNumber = returnTo.Number.Uint64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Why are we resetting? This is the block chain, it has nothing to do with states
|
|
||||||
//bc.Ethereum.StateManager().PrepareDefault(returnTo)
|
|
||||||
|
|
||||||
// Manually reset the last sync block
|
// Manually reset the last sync block
|
||||||
err := ethutil.Config.Db.Delete(lastBlock.Hash())
|
err := ethutil.Config.Db.Delete(lastBlock.Hash())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -233,6 +227,11 @@ func (bc *BlockChain) GetChainFromHash(hash []byte, max uint64) []interface{} {
|
||||||
for i := uint64(0); bytes.Compare(currentHash, hash) != 0 && num >= parentNumber && i < count; i++ {
|
for i := uint64(0); bytes.Compare(currentHash, hash) != 0 && num >= parentNumber && i < count; i++ {
|
||||||
// Get the block of the chain
|
// Get the block of the chain
|
||||||
block := bc.GetBlock(currentHash)
|
block := bc.GetBlock(currentHash)
|
||||||
|
if block == nil {
|
||||||
|
chainlogger.Debugf("Unexpected error during GetChainFromHash: Unable to find %x\n", currentHash)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
currentHash = block.PrevHash
|
currentHash = block.PrevHash
|
||||||
|
|
||||||
chain = append(chain, block.Value().Val)
|
chain = append(chain, block.Value().Val)
|
||||||
|
|
|
@ -102,22 +102,21 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
||||||
|
|
||||||
vmlogger.Debugf("(~) %x gas: %v (d) %x\n", closure.object.Address(), closure.Gas, closure.Args)
|
vmlogger.Debugf("(~) %x gas: %v (d) %x\n", closure.object.Address(), closure.Gas, closure.Args)
|
||||||
|
|
||||||
// Memory for the current closure
|
var (
|
||||||
mem := &Memory{}
|
op OpCode
|
||||||
// New stack (should this be shared?)
|
|
||||||
stack := NewStack()
|
|
||||||
require := func(m int) {
|
|
||||||
if stack.Len() < m {
|
|
||||||
isRequireError = true
|
|
||||||
panic(fmt.Sprintf("stack err = %d, req = %d", stack.Len(), m))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Program counter
|
mem = &Memory{}
|
||||||
pc := big.NewInt(0)
|
stack = NewStack()
|
||||||
// Current step count
|
pc = big.NewInt(0)
|
||||||
step := 0
|
step = 0
|
||||||
prevStep := 0
|
prevStep = 0
|
||||||
|
require = func(m int) {
|
||||||
|
if stack.Len() < m {
|
||||||
|
isRequireError = true
|
||||||
|
panic(fmt.Sprintf("%04v (%v) stack err size = %d, required = %d", pc, op, stack.Len(), m))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
prevStep = step
|
prevStep = step
|
||||||
|
@ -128,7 +127,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
||||||
// Get the memory location of pc
|
// Get the memory location of pc
|
||||||
val := closure.Get(pc)
|
val := closure.Get(pc)
|
||||||
// Get the opcode (it must be an opcode!)
|
// Get the opcode (it must be an opcode!)
|
||||||
op := OpCode(val.Uint())
|
op = OpCode(val.Uint())
|
||||||
|
|
||||||
gas := new(big.Int)
|
gas := new(big.Int)
|
||||||
addStepGasUsage := func(amount *big.Int) {
|
addStepGasUsage := func(amount *big.Int) {
|
||||||
|
|
|
@ -342,7 +342,7 @@ func (s *Ethereum) Start(seed bool) {
|
||||||
// Bind to addr and port
|
// Bind to addr and port
|
||||||
ln, err := net.Listen("tcp", ":"+s.Port)
|
ln, err := net.Listen("tcp", ":"+s.Port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ethlogger.Warnln("Connection listening disabled. Acting as client")
|
ethlogger.Warnf("Port %s in use. Connection listening disabled. Acting as client", s.Port)
|
||||||
s.listening = false
|
s.listening = false
|
||||||
} else {
|
} else {
|
||||||
s.listening = true
|
s.listening = true
|
||||||
|
|
|
@ -22,7 +22,6 @@ func Compile(script string) (ret []byte, err error) {
|
||||||
} else {
|
} else {
|
||||||
compiler := mutan.NewCompiler(backend.NewEthereumBackend())
|
compiler := mutan.NewCompiler(backend.NewEthereumBackend())
|
||||||
byteCode, errors := compiler.Compile(strings.NewReader(script))
|
byteCode, errors := compiler.Compile(strings.NewReader(script))
|
||||||
//byteCode, errors := mutan.Compile(strings.NewReader(script), false)
|
|
||||||
if len(errors) > 0 {
|
if len(errors) > 0 {
|
||||||
var errs string
|
var errs string
|
||||||
for _, er := range errors {
|
for _, er := range errors {
|
||||||
|
|
|
@ -47,7 +47,7 @@ func (cache *Cache) Put(v interface{}) interface{} {
|
||||||
value := NewValue(v)
|
value := NewValue(v)
|
||||||
|
|
||||||
enc := value.Encode()
|
enc := value.Encode()
|
||||||
if len(enc) >= 32 {
|
if len(enc) < 32 {
|
||||||
sha := Sha3Bin(enc)
|
sha := Sha3Bin(enc)
|
||||||
|
|
||||||
cache.nodes[string(sha)] = NewNode(sha, value, true)
|
cache.nodes[string(sha)] = NewNode(sha, value, true)
|
||||||
|
|
Loading…
Reference in New Issue