Merge remote-tracking branch 'upstream/develop' into bzz

This commit is contained in:
zelig 2015-06-04 00:23:52 +01:00
commit bd277f41b4
30 changed files with 7333 additions and 5959 deletions

View file

@ -164,7 +164,6 @@ func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
//ltxs := make([]*tx, len(txs))
var ltxs []*tx
for _, tx := range txs {
// no need to check err
if from, _ := tx.From(); accountSet.Has(from) {
ltxs = append(ltxs, newTx(tx))
}

View file

@ -364,8 +364,8 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
return UncleError("uncle[%d](%x) is ancestor", i, hash[:4])
}
if !ancestors.Has(uncle.ParentHash) {
return UncleError("uncle[%d](%x)'s parent unknown (%x)", i, hash[:4], uncle.ParentHash[0:4])
if !ancestors.Has(uncle.ParentHash) || uncle.ParentHash == parent.Hash() {
return UncleError("uncle[%d](%x)'s parent is not ancestor (%x)", i, hash[:4], uncle.ParentHash[0:4])
}
if err := sm.ValidateHeader(uncle, ancestorHeaders[uncle.ParentHash], true); err != nil {

View file

@ -522,13 +522,14 @@ type queueEvent struct {
}
func (self *ChainManager) procFutureBlocks() {
blocks := []*types.Block{}
var blocks []*types.Block
self.futureBlocks.Each(func(i int, block *types.Block) {
blocks = append(blocks, block)
})
types.BlockBy(types.Number).Sort(blocks)
self.InsertChain(blocks)
if len(blocks) > 0 {
types.BlockBy(types.Number).Sort(blocks)
self.InsertChain(blocks)
}
}
// InsertChain will attempt to insert the given chain in to the canonical chain or, otherwise, create a fork. It an error is returned
@ -540,17 +541,34 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
self.chainmu.Lock()
defer self.chainmu.Unlock()
// A queued approach to delivering events. This is generally faster than direct delivery and requires much less mutex acquiring.
// A queued approach to delivering events. This is generally
// faster than direct delivery and requires much less mutex
// acquiring.
var (
queue = make([]interface{}, len(chain))
queueEvent = queueEvent{queue: queue}
stats struct{ queued, processed, ignored int }
tstart = time.Now()
nonceDone = make(chan nonceResult, len(chain))
nonceQuit = make(chan struct{})
nonceChecked = make([]bool, len(chain))
)
// Start the parallel nonce verifier.
go verifyNonces(self.pow, chain, nonceQuit, nonceDone)
defer close(nonceQuit)
for i, block := range chain {
if block == nil {
continue
// Wait for block i's nonce to be verified before processing
// its state transition.
for nonceChecked[i] {
r := <-nonceDone
nonceChecked[r.i] = true
if !r.valid {
block := chain[i]
return i, ValidationError("Block (#%v / %x) nonce is invalid (= %x)", block.Number(), block.Hash(), block.Nonce)
}
}
if BadHashes[block.Hash()] {
@ -559,10 +577,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
return i, err
}
// create a nonce channel for parallisation of the nonce check
nonceErrCh := make(chan error)
go verifyBlockNonce(self.pow, block, nonceErrCh)
// Setting block.Td regardless of error (known for example) prevents errors down the line
// in the protocol handler
block.Td = new(big.Int).Set(CalcTD(block, self.GetBlock(block.ParentHash())))
@ -571,9 +585,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
// all others will fail too (unless a known block is returned).
logs, err := self.processor.Process(block)
if err != nil {
// empty the nonce channel
<-nonceErrCh
if IsKnownBlockErr(err) {
stats.ignored++
continue
@ -597,11 +608,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
return i, err
}
// Wait and check nonce channel and make sure it checks out fine
// otherwise return the error
if err := <-nonceErrCh; err != nil {
return i, err
}
cblock := self.currentBlock
// Compare the TD of the last known block in the canonical chain to make sure it's greater.
@ -776,66 +782,42 @@ func blockErr(block *types.Block, err error) {
h := block.Header()
glog.V(logger.Error).Infof("Bad block #%v (%x)\n", h.Number, h.Hash().Bytes())
glog.V(logger.Error).Infoln(err)
glog.V(logger.Debug).Infoln(block)
glog.V(logger.Debug).Infoln(verifyNonces)
}
// verifyNonces verifies nonces of the given blocks in parallel and returns
type nonceResult struct {
i int
valid bool
}
// block verifies nonces of the given blocks in parallel and returns
// an error if one of the blocks nonce verifications failed.
func verifyNonces(pow pow.PoW, blocks []*types.Block) error {
func verifyNonces(pow pow.PoW, blocks []*types.Block, quit <-chan struct{}, done chan<- nonceResult) {
// Spawn a few workers. They listen for blocks on the in channel
// and send results on done. The workers will exit in the
// background when in is closed.
var (
in = make(chan *types.Block)
done = make(chan error, runtime.GOMAXPROCS(0))
in = make(chan int)
nworkers = runtime.GOMAXPROCS(0)
)
defer close(in)
for i := 0; i < cap(done); i++ {
go verifyNonce(pow, in, done)
if len(blocks) < nworkers {
nworkers = len(blocks)
}
// Feed blocks to the workers, aborting at the first invalid nonce.
var (
running, i int
block *types.Block
sendin = in
)
for i < len(blocks) || running > 0 {
if i == len(blocks) {
// Disable sending to in.
sendin = nil
} else {
block = blocks[i]
i++
}
select {
case sendin <- block:
running++
case err := <-done:
running--
if err != nil {
return err
for i := 0; i < nworkers; i++ {
go func() {
for i := range in {
done <- nonceResult{i: i, valid: pow.Verify(blocks[i])}
}
}
}()
}
return nil
}
// verifyNonce is a worker for the verifyNonces method. It will run until
// in is closed.
func verifyNonce(pow pow.PoW, in <-chan *types.Block, done chan<- error) {
for block := range in {
if !pow.Verify(block) {
done <- ValidationError("Block (#%v / %x) nonce is invalid (= %x)", block.Number(), block.Hash(), block.Nonce)
} else {
done <- nil
// Feed block indices to the workers.
for i := range blocks {
select {
case in <- i:
continue
case <-quit:
return
}
}
}
func verifyBlockNonce(pow pow.PoW, block *types.Block, done chan<- error) {
if !pow.Verify(block) {
done <- ValidationError("Block (#%v / %x) nonce is invalid (= %x)", block.Number(), block.Hash(), block.Nonce)
} else {
done <- nil
}
}

View file

@ -62,7 +62,6 @@ type Message interface {
func AddressFromMessage(msg Message) common.Address {
from, _ := msg.From()
return crypto.CreateAddress(from, msg.Nonce())
}
@ -109,9 +108,12 @@ func NewStateTransition(env vm.Environment, msg Message, coinbase *state.StateOb
func (self *StateTransition) Coinbase() *state.StateObject {
return self.state.GetOrNewStateObject(self.coinbase)
}
func (self *StateTransition) From() *state.StateObject {
f, _ := self.msg.From()
return self.state.GetOrNewStateObject(f)
func (self *StateTransition) From() (*state.StateObject, error) {
f, err := self.msg.From()
if err != nil {
return nil, err
}
return self.state.GetOrNewStateObject(f), nil
}
func (self *StateTransition) To() *state.StateObject {
if self.msg == nil {
@ -140,7 +142,10 @@ func (self *StateTransition) AddGas(amount *big.Int) {
func (self *StateTransition) BuyGas() error {
var err error
sender := self.From()
sender, err := self.From()
if err != nil {
return err
}
if sender.Balance().Cmp(MessageGasValue(self.msg)) < 0 {
return fmt.Errorf("insufficient ETH for gas (%x). Req %v, has %v", sender.Address().Bytes()[:4], MessageGasValue(self.msg), sender.Balance())
}
@ -159,10 +164,11 @@ func (self *StateTransition) BuyGas() error {
}
func (self *StateTransition) preCheck() (err error) {
var (
msg = self.msg
sender = self.From()
)
msg := self.msg
sender, err := self.From()
if err != nil {
return err
}
// Make sure this transaction's nonce is correct
if sender.Nonce() != msg.Nonce() {
@ -185,10 +191,8 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
return
}
var (
msg = self.msg
sender = self.From()
)
msg := self.msg
sender, _ := self.From() // err checked in preCheck
// Pay intrinsic gas
if err = self.UseGas(IntrinsicGas(self.msg)); err != nil {
@ -212,7 +216,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
} else {
// Increment the nonce for the next transaction
self.state.SetNonce(sender.Address(), sender.Nonce()+1)
ret, err = vmenv.Call(self.From(), self.To().Address(), self.msg.Data(), self.gas, self.gasPrice, self.value)
ret, err = vmenv.Call(sender, self.To().Address(), self.msg.Data(), self.gas, self.gasPrice, self.value)
}
if err != nil && IsValueTransferErr(err) {
@ -226,7 +230,8 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
}
func (self *StateTransition) refundGas() {
coinbase, sender := self.Coinbase(), self.From()
coinbase := self.Coinbase()
sender, _ := self.From() // err already checked
// Return remaining gas
remaining := new(big.Int).Mul(self.gas, self.msg.GasPrice())
sender.AddBalance(remaining)

View file

@ -112,12 +112,6 @@ func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error {
return ErrInvalidSender
}
// Validate curve param
v, _, _ := tx.Curve()
if v > 28 || v < 27 {
return fmt.Errorf("tx.v != (28 || 27) => %v", v)
}
if !pool.currentState().HasAccount(from) {
return ErrNonExistentAccount
}
@ -280,7 +274,7 @@ func (pool *TxPool) Stop() {
}
func (self *TxPool) queueTx(tx *types.Transaction) {
from, _ := tx.From()
from, _ := tx.From() // already validated
self.queue[from] = append(self.queue[from], tx)
}

View file

@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
@ -93,9 +92,9 @@ func (self *Transaction) SetNonce(AccountNonce uint64) {
}
func (self *Transaction) From() (common.Address, error) {
pubkey := self.PublicKey()
if len(pubkey) == 0 || pubkey[0] != 4 {
return common.Address{}, errors.New("invalid public key")
pubkey, err := self.PublicKey()
if err != nil {
return common.Address{}, err
}
var addr common.Address
@ -110,34 +109,34 @@ func (tx *Transaction) To() *common.Address {
return tx.Recipient
}
func (tx *Transaction) Curve() (v byte, r []byte, s []byte) {
func (tx *Transaction) GetSignatureValues() (v byte, r []byte, s []byte) {
v = byte(tx.V)
r = common.LeftPadBytes(tx.R.Bytes(), 32)
s = common.LeftPadBytes(tx.S.Bytes(), 32)
return
}
func (tx *Transaction) Signature(key []byte) []byte {
hash := tx.Hash()
sig, _ := secp256k1.Sign(hash[:], key)
return sig
}
func (tx *Transaction) PublicKey() ([]byte, error) {
if !crypto.ValidateSignatureValues(tx.V, tx.R, tx.S) {
return nil, errors.New("invalid v, r, s values")
}
func (tx *Transaction) PublicKey() []byte {
hash := tx.Hash()
v, r, s := tx.Curve()
v, r, s := tx.GetSignatureValues()
sig := append(r, s...)
sig = append(sig, v-27)
//pubkey := crypto.Ecrecover(append(hash[:], sig...))
//pubkey, _ := secp256k1.RecoverPubkey(hash[:], sig)
p, err := crypto.SigToPub(hash[:], sig)
if err != nil {
glog.V(logger.Error).Infof("Could not get pubkey from signature: ", err)
return nil
return nil, err
}
pubkey := crypto.FromECDSAPub(p)
return pubkey
if len(pubkey) == 0 || pubkey[0] != 4 {
return nil, errors.New("invalid public key")
}
return pubkey, nil
}
func (tx *Transaction) SetSignatureValues(sig []byte) error {

View file

@ -3,34 +3,45 @@ package vm
import (
"math/big"
"gopkg.in/fatih/set.v0"
"github.com/ethereum/go-ethereum/common"
)
type destinations struct {
set *set.Set
var bigMaxUint64 = new(big.Int).SetUint64(^uint64(0))
// destinations stores one map per contract (keyed by hash of code).
// The maps contain an entry for each location of a JUMPDEST
// instruction.
type destinations map[common.Hash]map[uint64]struct{}
// has checks whether code has a JUMPDEST at dest.
func (d destinations) has(codehash common.Hash, code []byte, dest *big.Int) bool {
// PC cannot go beyond len(code) and certainly can't be bigger than 64bits.
// Don't bother checking for JUMPDEST in that case.
if dest.Cmp(bigMaxUint64) > 0 {
return false
}
m, analysed := d[codehash]
if !analysed {
m = jumpdests(code)
d[codehash] = m
}
_, ok := m[dest.Uint64()]
return ok
}
func (d *destinations) Has(dest *big.Int) bool {
return d.set.Has(string(dest.Bytes()))
}
func (d *destinations) Add(dest *big.Int) {
d.set.Add(string(dest.Bytes()))
}
func analyseJumpDests(code []byte) (dests *destinations) {
dests = &destinations{set.New()}
// jumpdests creates a map that contains an entry for each
// PC location that is a JUMPDEST instruction.
func jumpdests(code []byte) map[uint64]struct{} {
m := make(map[uint64]struct{})
for pc := uint64(0); pc < uint64(len(code)); pc++ {
var op OpCode = OpCode(code[pc])
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:
a := uint64(op) - uint64(PUSH1) + 1
pc += a
case JUMPDEST:
dests.Add(big.NewInt(int64(pc)))
m[pc] = struct{}{}
}
}
return
return m
}

View file

@ -16,6 +16,8 @@ type Context struct {
caller ContextRef
self ContextRef
jumpdests destinations // result of JUMPDEST analysis.
Code []byte
CodeAddr *common.Address
@ -24,10 +26,17 @@ type Context struct {
Args []byte
}
// Create a new context for the given data items
// Create a new context for the given data items.
func NewContext(caller ContextRef, object ContextRef, value, gas, price *big.Int) *Context {
c := &Context{caller: caller, self: object, Args: nil}
if parent, ok := caller.(*Context); ok {
// Reuse JUMPDEST analysis from parent context if available.
c.jumpdests = parent.jumpdests
} else {
c.jumpdests = make(destinations)
}
// Gas should be a pointer so it can safely be reduced through the run
// This pointer will be off the state transition
c.Gas = gas //new(big.Int).Set(gas)

View file

@ -71,18 +71,22 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
}
}
var (
op OpCode
// Don't bother with the execution if there's no code.
if len(code) == 0 {
return context.Return(nil), nil
}
destinations = analyseJumpDests(context.Code)
mem = NewMemory()
stack = newStack()
pc = new(big.Int)
statedb = self.env.State()
var (
op OpCode
codehash = crypto.Sha3Hash(code)
mem = NewMemory()
stack = newStack()
pc = new(big.Int)
statedb = self.env.State()
jump = func(from *big.Int, to *big.Int) error {
nop := context.GetOp(to)
if !destinations.Has(to) {
if !context.jumpdests.has(codehash, code, to) {
nop := context.GetOp(to)
return fmt.Errorf("invalid jump destination (%v) %v", nop, to)
}
@ -95,11 +99,6 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
}
)
// Don't bother with the execution if there's no code.
if len(code) == 0 {
return context.Return(nil), nil
}
for {
// The base for all big integer arithmetic
base := new(big.Int)

View file

@ -10,6 +10,7 @@ import (
"fmt"
"io"
"io/ioutil"
"math/big"
"os"
"encoding/hex"
@ -26,9 +27,12 @@ import (
"golang.org/x/crypto/ripemd160"
)
var secp256k1n *big.Int
func init() {
// specify the params for the s256 curve
ecies.AddParamsForCurve(S256(), ecies.ECIES_AES128_SHA256)
secp256k1n = common.String2Big("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141")
}
func Sha3(data ...[]byte) []byte {
@ -151,6 +155,18 @@ func GenerateKey() (*ecdsa.PrivateKey, error) {
return ecdsa.GenerateKey(S256(), rand.Reader)
}
func ValidateSignatureValues(v byte, r, s *big.Int) bool {
vint := uint32(v)
if r.Cmp(common.Big0) == 0 || s.Cmp(common.Big0) == 0 {
return false
}
if r.Cmp(secp256k1n) < 0 && s.Cmp(secp256k1n) < 0 && (vint == 27 || vint == 28) {
return true
} else {
return false
}
}
func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error) {
s, err := Ecrecover(hash, sig)
if err != nil {

View file

@ -1,171 +1,410 @@
// Copyright 2013 The Go Authors. All rights reserved.
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sha3
// This file implements the core Keccak permutation function necessary for computing SHA3.
// This is implemented in a separate file to allow for replacement by an optimized implementation.
// Nothing in this package is exported.
// For the detailed specification, refer to the Keccak web site (http://keccak.noekeon.org/).
// rc stores the round constants for use in the ι step.
var rc = [...]uint64{
0x0000000000000001,
0x0000000000008082,
0x800000000000808A,
0x8000000080008000,
0x000000000000808B,
0x0000000080000001,
0x8000000080008081,
0x8000000000008009,
0x000000000000008A,
0x0000000000000088,
0x0000000080008009,
0x000000008000000A,
0x000000008000808B,
0x800000000000008B,
0x8000000000008089,
0x8000000000008003,
0x8000000000008002,
0x8000000000000080,
0x000000000000800A,
0x800000008000000A,
0x8000000080008081,
0x8000000000008080,
0x0000000080000001,
0x8000000080008008,
var rc = [24]uint64{
0x0000000000000001,
0x0000000000008082,
0x800000000000808A,
0x8000000080008000,
0x000000000000808B,
0x0000000080000001,
0x8000000080008081,
0x8000000000008009,
0x000000000000008A,
0x0000000000000088,
0x0000000080008009,
0x000000008000000A,
0x000000008000808B,
0x800000000000008B,
0x8000000000008089,
0x8000000000008003,
0x8000000000008002,
0x8000000000000080,
0x000000000000800A,
0x800000008000000A,
0x8000000080008081,
0x8000000000008080,
0x0000000080000001,
0x8000000080008008,
}
// ro_xx represent the rotation offsets for use in the χ step.
// Defining them as const instead of in an array allows the compiler to insert constant shifts.
const (
ro_00 = 0
ro_01 = 36
ro_02 = 3
ro_03 = 41
ro_04 = 18
ro_05 = 1
ro_06 = 44
ro_07 = 10
ro_08 = 45
ro_09 = 2
ro_10 = 62
ro_11 = 6
ro_12 = 43
ro_13 = 15
ro_14 = 61
ro_15 = 28
ro_16 = 55
ro_17 = 25
ro_18 = 21
ro_19 = 56
ro_20 = 27
ro_21 = 20
ro_22 = 39
ro_23 = 8
ro_24 = 14
)
// keccakF1600 applies the Keccak permutation to a 1600b-wide
// state represented as a slice of 25 uint64s.
func keccakF1600(a *[25]uint64) {
// Implementation translated from Keccak-inplace.c
// in the keccak reference code.
var t, bc0, bc1, bc2, bc3, bc4, d0, d1, d2, d3, d4 uint64
// keccakF computes the complete Keccak-f function consisting of 24 rounds with a different
// constant (rc) in each round. This implementation fully unrolls the round function to avoid
// inner loops, as well as pre-calculating shift offsets.
func (d *digest) keccakF() {
for _, roundConstant := range rc {
// θ step
d.c[0] = d.a[0] ^ d.a[5] ^ d.a[10] ^ d.a[15] ^ d.a[20]
d.c[1] = d.a[1] ^ d.a[6] ^ d.a[11] ^ d.a[16] ^ d.a[21]
d.c[2] = d.a[2] ^ d.a[7] ^ d.a[12] ^ d.a[17] ^ d.a[22]
d.c[3] = d.a[3] ^ d.a[8] ^ d.a[13] ^ d.a[18] ^ d.a[23]
d.c[4] = d.a[4] ^ d.a[9] ^ d.a[14] ^ d.a[19] ^ d.a[24]
for i := 0; i < 24; i += 4 {
// Combines the 5 steps in each round into 2 steps.
// Unrolls 4 rounds per loop and spreads some steps across rounds.
d.d[0] = d.c[4] ^ (d.c[1]<<1 ^ d.c[1]>>63)
d.d[1] = d.c[0] ^ (d.c[2]<<1 ^ d.c[2]>>63)
d.d[2] = d.c[1] ^ (d.c[3]<<1 ^ d.c[3]>>63)
d.d[3] = d.c[2] ^ (d.c[4]<<1 ^ d.c[4]>>63)
d.d[4] = d.c[3] ^ (d.c[0]<<1 ^ d.c[0]>>63)
// Round 1
bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
d0 = bc4 ^ (bc1<<1 | bc1>>63)
d1 = bc0 ^ (bc2<<1 | bc2>>63)
d2 = bc1 ^ (bc3<<1 | bc3>>63)
d3 = bc2 ^ (bc4<<1 | bc4>>63)
d4 = bc3 ^ (bc0<<1 | bc0>>63)
d.a[0] ^= d.d[0]
d.a[1] ^= d.d[1]
d.a[2] ^= d.d[2]
d.a[3] ^= d.d[3]
d.a[4] ^= d.d[4]
d.a[5] ^= d.d[0]
d.a[6] ^= d.d[1]
d.a[7] ^= d.d[2]
d.a[8] ^= d.d[3]
d.a[9] ^= d.d[4]
d.a[10] ^= d.d[0]
d.a[11] ^= d.d[1]
d.a[12] ^= d.d[2]
d.a[13] ^= d.d[3]
d.a[14] ^= d.d[4]
d.a[15] ^= d.d[0]
d.a[16] ^= d.d[1]
d.a[17] ^= d.d[2]
d.a[18] ^= d.d[3]
d.a[19] ^= d.d[4]
d.a[20] ^= d.d[0]
d.a[21] ^= d.d[1]
d.a[22] ^= d.d[2]
d.a[23] ^= d.d[3]
d.a[24] ^= d.d[4]
bc0 = a[0] ^ d0
t = a[6] ^ d1
bc1 = t<<44 | t>>(64-44)
t = a[12] ^ d2
bc2 = t<<43 | t>>(64-43)
t = a[18] ^ d3
bc3 = t<<21 | t>>(64-21)
t = a[24] ^ d4
bc4 = t<<14 | t>>(64-14)
a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i]
a[6] = bc1 ^ (bc3 &^ bc2)
a[12] = bc2 ^ (bc4 &^ bc3)
a[18] = bc3 ^ (bc0 &^ bc4)
a[24] = bc4 ^ (bc1 &^ bc0)
// ρ and π steps
d.b[0] = d.a[0]
d.b[1] = d.a[6]<<ro_06 ^ d.a[6]>>(64-ro_06)
d.b[2] = d.a[12]<<ro_12 ^ d.a[12]>>(64-ro_12)
d.b[3] = d.a[18]<<ro_18 ^ d.a[18]>>(64-ro_18)
d.b[4] = d.a[24]<<ro_24 ^ d.a[24]>>(64-ro_24)
d.b[5] = d.a[3]<<ro_15 ^ d.a[3]>>(64-ro_15)
d.b[6] = d.a[9]<<ro_21 ^ d.a[9]>>(64-ro_21)
d.b[7] = d.a[10]<<ro_02 ^ d.a[10]>>(64-ro_02)
d.b[8] = d.a[16]<<ro_08 ^ d.a[16]>>(64-ro_08)
d.b[9] = d.a[22]<<ro_14 ^ d.a[22]>>(64-ro_14)
d.b[10] = d.a[1]<<ro_05 ^ d.a[1]>>(64-ro_05)
d.b[11] = d.a[7]<<ro_11 ^ d.a[7]>>(64-ro_11)
d.b[12] = d.a[13]<<ro_17 ^ d.a[13]>>(64-ro_17)
d.b[13] = d.a[19]<<ro_23 ^ d.a[19]>>(64-ro_23)
d.b[14] = d.a[20]<<ro_04 ^ d.a[20]>>(64-ro_04)
d.b[15] = d.a[4]<<ro_20 ^ d.a[4]>>(64-ro_20)
d.b[16] = d.a[5]<<ro_01 ^ d.a[5]>>(64-ro_01)
d.b[17] = d.a[11]<<ro_07 ^ d.a[11]>>(64-ro_07)
d.b[18] = d.a[17]<<ro_13 ^ d.a[17]>>(64-ro_13)
d.b[19] = d.a[23]<<ro_19 ^ d.a[23]>>(64-ro_19)
d.b[20] = d.a[2]<<ro_10 ^ d.a[2]>>(64-ro_10)
d.b[21] = d.a[8]<<ro_16 ^ d.a[8]>>(64-ro_16)
d.b[22] = d.a[14]<<ro_22 ^ d.a[14]>>(64-ro_22)
d.b[23] = d.a[15]<<ro_03 ^ d.a[15]>>(64-ro_03)
d.b[24] = d.a[21]<<ro_09 ^ d.a[21]>>(64-ro_09)
t = a[10] ^ d0
bc2 = t<<3 | t>>(64-3)
t = a[16] ^ d1
bc3 = t<<45 | t>>(64-45)
t = a[22] ^ d2
bc4 = t<<61 | t>>(64-61)
t = a[3] ^ d3
bc0 = t<<28 | t>>(64-28)
t = a[9] ^ d4
bc1 = t<<20 | t>>(64-20)
a[10] = bc0 ^ (bc2 &^ bc1)
a[16] = bc1 ^ (bc3 &^ bc2)
a[22] = bc2 ^ (bc4 &^ bc3)
a[3] = bc3 ^ (bc0 &^ bc4)
a[9] = bc4 ^ (bc1 &^ bc0)
// χ step
d.a[0] = d.b[0] ^ (^d.b[1] & d.b[2])
d.a[1] = d.b[1] ^ (^d.b[2] & d.b[3])
d.a[2] = d.b[2] ^ (^d.b[3] & d.b[4])
d.a[3] = d.b[3] ^ (^d.b[4] & d.b[0])
d.a[4] = d.b[4] ^ (^d.b[0] & d.b[1])
d.a[5] = d.b[5] ^ (^d.b[6] & d.b[7])
d.a[6] = d.b[6] ^ (^d.b[7] & d.b[8])
d.a[7] = d.b[7] ^ (^d.b[8] & d.b[9])
d.a[8] = d.b[8] ^ (^d.b[9] & d.b[5])
d.a[9] = d.b[9] ^ (^d.b[5] & d.b[6])
d.a[10] = d.b[10] ^ (^d.b[11] & d.b[12])
d.a[11] = d.b[11] ^ (^d.b[12] & d.b[13])
d.a[12] = d.b[12] ^ (^d.b[13] & d.b[14])
d.a[13] = d.b[13] ^ (^d.b[14] & d.b[10])
d.a[14] = d.b[14] ^ (^d.b[10] & d.b[11])
d.a[15] = d.b[15] ^ (^d.b[16] & d.b[17])
d.a[16] = d.b[16] ^ (^d.b[17] & d.b[18])
d.a[17] = d.b[17] ^ (^d.b[18] & d.b[19])
d.a[18] = d.b[18] ^ (^d.b[19] & d.b[15])
d.a[19] = d.b[19] ^ (^d.b[15] & d.b[16])
d.a[20] = d.b[20] ^ (^d.b[21] & d.b[22])
d.a[21] = d.b[21] ^ (^d.b[22] & d.b[23])
d.a[22] = d.b[22] ^ (^d.b[23] & d.b[24])
d.a[23] = d.b[23] ^ (^d.b[24] & d.b[20])
d.a[24] = d.b[24] ^ (^d.b[20] & d.b[21])
t = a[20] ^ d0
bc4 = t<<18 | t>>(64-18)
t = a[1] ^ d1
bc0 = t<<1 | t>>(64-1)
t = a[7] ^ d2
bc1 = t<<6 | t>>(64-6)
t = a[13] ^ d3
bc2 = t<<25 | t>>(64-25)
t = a[19] ^ d4
bc3 = t<<8 | t>>(64-8)
a[20] = bc0 ^ (bc2 &^ bc1)
a[1] = bc1 ^ (bc3 &^ bc2)
a[7] = bc2 ^ (bc4 &^ bc3)
a[13] = bc3 ^ (bc0 &^ bc4)
a[19] = bc4 ^ (bc1 &^ bc0)
// ι step
d.a[0] ^= roundConstant
}
t = a[5] ^ d0
bc1 = t<<36 | t>>(64-36)
t = a[11] ^ d1
bc2 = t<<10 | t>>(64-10)
t = a[17] ^ d2
bc3 = t<<15 | t>>(64-15)
t = a[23] ^ d3
bc4 = t<<56 | t>>(64-56)
t = a[4] ^ d4
bc0 = t<<27 | t>>(64-27)
a[5] = bc0 ^ (bc2 &^ bc1)
a[11] = bc1 ^ (bc3 &^ bc2)
a[17] = bc2 ^ (bc4 &^ bc3)
a[23] = bc3 ^ (bc0 &^ bc4)
a[4] = bc4 ^ (bc1 &^ bc0)
t = a[15] ^ d0
bc3 = t<<41 | t>>(64-41)
t = a[21] ^ d1
bc4 = t<<2 | t>>(64-2)
t = a[2] ^ d2
bc0 = t<<62 | t>>(64-62)
t = a[8] ^ d3
bc1 = t<<55 | t>>(64-55)
t = a[14] ^ d4
bc2 = t<<39 | t>>(64-39)
a[15] = bc0 ^ (bc2 &^ bc1)
a[21] = bc1 ^ (bc3 &^ bc2)
a[2] = bc2 ^ (bc4 &^ bc3)
a[8] = bc3 ^ (bc0 &^ bc4)
a[14] = bc4 ^ (bc1 &^ bc0)
// Round 2
bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
d0 = bc4 ^ (bc1<<1 | bc1>>63)
d1 = bc0 ^ (bc2<<1 | bc2>>63)
d2 = bc1 ^ (bc3<<1 | bc3>>63)
d3 = bc2 ^ (bc4<<1 | bc4>>63)
d4 = bc3 ^ (bc0<<1 | bc0>>63)
bc0 = a[0] ^ d0
t = a[16] ^ d1
bc1 = t<<44 | t>>(64-44)
t = a[7] ^ d2
bc2 = t<<43 | t>>(64-43)
t = a[23] ^ d3
bc3 = t<<21 | t>>(64-21)
t = a[14] ^ d4
bc4 = t<<14 | t>>(64-14)
a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+1]
a[16] = bc1 ^ (bc3 &^ bc2)
a[7] = bc2 ^ (bc4 &^ bc3)
a[23] = bc3 ^ (bc0 &^ bc4)
a[14] = bc4 ^ (bc1 &^ bc0)
t = a[20] ^ d0
bc2 = t<<3 | t>>(64-3)
t = a[11] ^ d1
bc3 = t<<45 | t>>(64-45)
t = a[2] ^ d2
bc4 = t<<61 | t>>(64-61)
t = a[18] ^ d3
bc0 = t<<28 | t>>(64-28)
t = a[9] ^ d4
bc1 = t<<20 | t>>(64-20)
a[20] = bc0 ^ (bc2 &^ bc1)
a[11] = bc1 ^ (bc3 &^ bc2)
a[2] = bc2 ^ (bc4 &^ bc3)
a[18] = bc3 ^ (bc0 &^ bc4)
a[9] = bc4 ^ (bc1 &^ bc0)
t = a[15] ^ d0
bc4 = t<<18 | t>>(64-18)
t = a[6] ^ d1
bc0 = t<<1 | t>>(64-1)
t = a[22] ^ d2
bc1 = t<<6 | t>>(64-6)
t = a[13] ^ d3
bc2 = t<<25 | t>>(64-25)
t = a[4] ^ d4
bc3 = t<<8 | t>>(64-8)
a[15] = bc0 ^ (bc2 &^ bc1)
a[6] = bc1 ^ (bc3 &^ bc2)
a[22] = bc2 ^ (bc4 &^ bc3)
a[13] = bc3 ^ (bc0 &^ bc4)
a[4] = bc4 ^ (bc1 &^ bc0)
t = a[10] ^ d0
bc1 = t<<36 | t>>(64-36)
t = a[1] ^ d1
bc2 = t<<10 | t>>(64-10)
t = a[17] ^ d2
bc3 = t<<15 | t>>(64-15)
t = a[8] ^ d3
bc4 = t<<56 | t>>(64-56)
t = a[24] ^ d4
bc0 = t<<27 | t>>(64-27)
a[10] = bc0 ^ (bc2 &^ bc1)
a[1] = bc1 ^ (bc3 &^ bc2)
a[17] = bc2 ^ (bc4 &^ bc3)
a[8] = bc3 ^ (bc0 &^ bc4)
a[24] = bc4 ^ (bc1 &^ bc0)
t = a[5] ^ d0
bc3 = t<<41 | t>>(64-41)
t = a[21] ^ d1
bc4 = t<<2 | t>>(64-2)
t = a[12] ^ d2
bc0 = t<<62 | t>>(64-62)
t = a[3] ^ d3
bc1 = t<<55 | t>>(64-55)
t = a[19] ^ d4
bc2 = t<<39 | t>>(64-39)
a[5] = bc0 ^ (bc2 &^ bc1)
a[21] = bc1 ^ (bc3 &^ bc2)
a[12] = bc2 ^ (bc4 &^ bc3)
a[3] = bc3 ^ (bc0 &^ bc4)
a[19] = bc4 ^ (bc1 &^ bc0)
// Round 3
bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
d0 = bc4 ^ (bc1<<1 | bc1>>63)
d1 = bc0 ^ (bc2<<1 | bc2>>63)
d2 = bc1 ^ (bc3<<1 | bc3>>63)
d3 = bc2 ^ (bc4<<1 | bc4>>63)
d4 = bc3 ^ (bc0<<1 | bc0>>63)
bc0 = a[0] ^ d0
t = a[11] ^ d1
bc1 = t<<44 | t>>(64-44)
t = a[22] ^ d2
bc2 = t<<43 | t>>(64-43)
t = a[8] ^ d3
bc3 = t<<21 | t>>(64-21)
t = a[19] ^ d4
bc4 = t<<14 | t>>(64-14)
a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+2]
a[11] = bc1 ^ (bc3 &^ bc2)
a[22] = bc2 ^ (bc4 &^ bc3)
a[8] = bc3 ^ (bc0 &^ bc4)
a[19] = bc4 ^ (bc1 &^ bc0)
t = a[15] ^ d0
bc2 = t<<3 | t>>(64-3)
t = a[1] ^ d1
bc3 = t<<45 | t>>(64-45)
t = a[12] ^ d2
bc4 = t<<61 | t>>(64-61)
t = a[23] ^ d3
bc0 = t<<28 | t>>(64-28)
t = a[9] ^ d4
bc1 = t<<20 | t>>(64-20)
a[15] = bc0 ^ (bc2 &^ bc1)
a[1] = bc1 ^ (bc3 &^ bc2)
a[12] = bc2 ^ (bc4 &^ bc3)
a[23] = bc3 ^ (bc0 &^ bc4)
a[9] = bc4 ^ (bc1 &^ bc0)
t = a[5] ^ d0
bc4 = t<<18 | t>>(64-18)
t = a[16] ^ d1
bc0 = t<<1 | t>>(64-1)
t = a[2] ^ d2
bc1 = t<<6 | t>>(64-6)
t = a[13] ^ d3
bc2 = t<<25 | t>>(64-25)
t = a[24] ^ d4
bc3 = t<<8 | t>>(64-8)
a[5] = bc0 ^ (bc2 &^ bc1)
a[16] = bc1 ^ (bc3 &^ bc2)
a[2] = bc2 ^ (bc4 &^ bc3)
a[13] = bc3 ^ (bc0 &^ bc4)
a[24] = bc4 ^ (bc1 &^ bc0)
t = a[20] ^ d0
bc1 = t<<36 | t>>(64-36)
t = a[6] ^ d1
bc2 = t<<10 | t>>(64-10)
t = a[17] ^ d2
bc3 = t<<15 | t>>(64-15)
t = a[3] ^ d3
bc4 = t<<56 | t>>(64-56)
t = a[14] ^ d4
bc0 = t<<27 | t>>(64-27)
a[20] = bc0 ^ (bc2 &^ bc1)
a[6] = bc1 ^ (bc3 &^ bc2)
a[17] = bc2 ^ (bc4 &^ bc3)
a[3] = bc3 ^ (bc0 &^ bc4)
a[14] = bc4 ^ (bc1 &^ bc0)
t = a[10] ^ d0
bc3 = t<<41 | t>>(64-41)
t = a[21] ^ d1
bc4 = t<<2 | t>>(64-2)
t = a[7] ^ d2
bc0 = t<<62 | t>>(64-62)
t = a[18] ^ d3
bc1 = t<<55 | t>>(64-55)
t = a[4] ^ d4
bc2 = t<<39 | t>>(64-39)
a[10] = bc0 ^ (bc2 &^ bc1)
a[21] = bc1 ^ (bc3 &^ bc2)
a[7] = bc2 ^ (bc4 &^ bc3)
a[18] = bc3 ^ (bc0 &^ bc4)
a[4] = bc4 ^ (bc1 &^ bc0)
// Round 4
bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
d0 = bc4 ^ (bc1<<1 | bc1>>63)
d1 = bc0 ^ (bc2<<1 | bc2>>63)
d2 = bc1 ^ (bc3<<1 | bc3>>63)
d3 = bc2 ^ (bc4<<1 | bc4>>63)
d4 = bc3 ^ (bc0<<1 | bc0>>63)
bc0 = a[0] ^ d0
t = a[1] ^ d1
bc1 = t<<44 | t>>(64-44)
t = a[2] ^ d2
bc2 = t<<43 | t>>(64-43)
t = a[3] ^ d3
bc3 = t<<21 | t>>(64-21)
t = a[4] ^ d4
bc4 = t<<14 | t>>(64-14)
a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+3]
a[1] = bc1 ^ (bc3 &^ bc2)
a[2] = bc2 ^ (bc4 &^ bc3)
a[3] = bc3 ^ (bc0 &^ bc4)
a[4] = bc4 ^ (bc1 &^ bc0)
t = a[5] ^ d0
bc2 = t<<3 | t>>(64-3)
t = a[6] ^ d1
bc3 = t<<45 | t>>(64-45)
t = a[7] ^ d2
bc4 = t<<61 | t>>(64-61)
t = a[8] ^ d3
bc0 = t<<28 | t>>(64-28)
t = a[9] ^ d4
bc1 = t<<20 | t>>(64-20)
a[5] = bc0 ^ (bc2 &^ bc1)
a[6] = bc1 ^ (bc3 &^ bc2)
a[7] = bc2 ^ (bc4 &^ bc3)
a[8] = bc3 ^ (bc0 &^ bc4)
a[9] = bc4 ^ (bc1 &^ bc0)
t = a[10] ^ d0
bc4 = t<<18 | t>>(64-18)
t = a[11] ^ d1
bc0 = t<<1 | t>>(64-1)
t = a[12] ^ d2
bc1 = t<<6 | t>>(64-6)
t = a[13] ^ d3
bc2 = t<<25 | t>>(64-25)
t = a[14] ^ d4
bc3 = t<<8 | t>>(64-8)
a[10] = bc0 ^ (bc2 &^ bc1)
a[11] = bc1 ^ (bc3 &^ bc2)
a[12] = bc2 ^ (bc4 &^ bc3)
a[13] = bc3 ^ (bc0 &^ bc4)
a[14] = bc4 ^ (bc1 &^ bc0)
t = a[15] ^ d0
bc1 = t<<36 | t>>(64-36)
t = a[16] ^ d1
bc2 = t<<10 | t>>(64-10)
t = a[17] ^ d2
bc3 = t<<15 | t>>(64-15)
t = a[18] ^ d3
bc4 = t<<56 | t>>(64-56)
t = a[19] ^ d4
bc0 = t<<27 | t>>(64-27)
a[15] = bc0 ^ (bc2 &^ bc1)
a[16] = bc1 ^ (bc3 &^ bc2)
a[17] = bc2 ^ (bc4 &^ bc3)
a[18] = bc3 ^ (bc0 &^ bc4)
a[19] = bc4 ^ (bc1 &^ bc0)
t = a[20] ^ d0
bc3 = t<<41 | t>>(64-41)
t = a[21] ^ d1
bc4 = t<<2 | t>>(64-2)
t = a[22] ^ d2
bc0 = t<<62 | t>>(64-62)
t = a[23] ^ d3
bc1 = t<<55 | t>>(64-55)
t = a[24] ^ d4
bc2 = t<<39 | t>>(64-39)
a[20] = bc0 ^ (bc2 &^ bc1)
a[21] = bc1 ^ (bc3 &^ bc2)
a[22] = bc2 ^ (bc4 &^ bc3)
a[23] = bc3 ^ (bc0 &^ bc4)
a[24] = bc4 ^ (bc1 &^ bc0)
}
}

View file

@ -38,13 +38,10 @@ const stateSize = laneSize * numLanes
// O(2^{outputSize/2}) computations (the birthday lower bound). Future standards may modify the
// capacity/outputSize ratio to allow for more output with lower cryptographic security.
type digest struct {
a [numLanes]uint64 // main state of the hash
b [numLanes]uint64 // intermediate states
c [sliceSize]uint64 // intermediate states
d [sliceSize]uint64 // intermediate states
outputSize int // desired output size in bytes
capacity int // number of bytes to leave untouched during squeeze/absorb
absorbed int // number of bytes absorbed thus far
a [numLanes]uint64 // main state of the hash
outputSize int // desired output size in bytes
capacity int // number of bytes to leave untouched during squeeze/absorb
absorbed int // number of bytes absorbed thus far
}
// minInt returns the lesser of two integer arguments, to simplify the absorption routine.
@ -116,7 +113,7 @@ func (d *digest) Write(p []byte) (int, error) {
// For every rate() bytes absorbed, the state must be permuted via the F Function.
if (d.absorbed)%d.rate() == 0 {
d.keccakF()
keccakF1600(&d.a)
}
}
@ -134,7 +131,7 @@ func (d *digest) Write(p []byte) (int, error) {
d.absorbed += (lastLane - firstLane) * laneSize
// For every rate() bytes absorbed, the state must be permuted via the F Function.
if (d.absorbed)%d.rate() == 0 {
d.keccakF()
keccakF1600(&d.a)
}
offset = 0
@ -167,7 +164,7 @@ func (d *digest) pad() {
// finalize prepares the hash to output data by padding and one final permutation of the state.
func (d *digest) finalize() {
d.pad()
d.keccakF()
keccakF1600(&d.a)
}
// squeeze outputs an arbitrary number of bytes from the hash state.
@ -192,7 +189,7 @@ func (d *digest) squeeze(in []byte, toSqueeze int) []byte {
out = out[laneSize:]
}
if len(out) > 0 {
d.keccakF()
keccakF1600(&d.a)
}
}
return in[:len(in)+toSqueeze] // Re-slice in case we wrote extra data.

View file

@ -46,7 +46,7 @@ var (
defaultBootNodes = []*discover.Node{
// ETH/DEV Go Bootnodes
discover.MustParseNode("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"),
discover.MustParseNode("enode://7f25d3eab333a6b98a8b5ed68d962bb22c876ffcd5561fca54e3c2ef27f754df6f7fd7c9b74cc919067abac154fb8e1f8385505954f161ae440abc355855e034@54.207.93.166:30303"),
discover.MustParseNode("enode://de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786@54.94.239.50:30303"),
// ETH/DEV cpp-ethereum (poc-9.ethdev.com)
discover.MustParseNode("enode://487611428e6c99a11a9795a6abe7b529e81315ca6aad66e2a2fc76e3adf263faba0d35466c2f8f68d561dbefa8878d4df5f1f2ddb1fbeab7f42ffb8cd328bd4a@5.1.83.226:30303"),
}

View file

@ -27,9 +27,10 @@ const (
)
var (
blockTTL = 5 * time.Second // Time it takes for a block request to time out
crossCheckCycle = time.Second // Period after which to check for expired cross checks
minDesiredPeerCount = 5 // Amount of peers desired to start syncing
blockSoftTTL = 3 * time.Second // Request completion threshold for increasing or decreasing a peer's bandwidth
blockHardTTL = 3 * blockSoftTTL // Maximum time allowance before a block request is considered expired
crossCheckCycle = time.Second // Period after which to check for expired cross checks
minDesiredPeerCount = 5 // Amount of peers desired to start syncing
)
var (
@ -324,7 +325,7 @@ func (d *Downloader) fetchHashes(p *peer, h common.Hash) error {
glog.V(logger.Detail).Infof("Cross checking (%s) with %x/%x", active.id, origin, parent)
d.checks[origin] = &crossCheck{
expire: time.Now().Add(blockTTL),
expire: time.Now().Add(blockSoftTTL),
parent: parent,
}
active.getBlocks([]common.Hash{origin})
@ -429,6 +430,7 @@ out:
// Peer did deliver, but some blocks were off, penalize
glog.V(logger.Debug).Infof("Failed delivery for peer %s: %v\n", blockPack.peerId, err)
peer.Demote()
peer.SetIdle()
break
}
if glog.V(logger.Debug) && len(blockPack.blocks) > 0 {
@ -444,7 +446,7 @@ out:
// that badly or poorly behave are removed from the peer set (not banned).
// Bad peers are excluded from the available peer set and therefor won't be
// reused. XXX We could re-introduce peers after X time.
badPeers := d.queue.Expire(blockTTL)
badPeers := d.queue.Expire(blockHardTTL)
for _, pid := range badPeers {
// XXX We could make use of a reputation system here ranking peers
// in their performance
@ -475,7 +477,7 @@ out:
}
// Get a possible chunk. If nil is returned no chunk
// could be returned due to no hashes available.
request := d.queue.Reserve(peer, MaxBlockFetch)
request := d.queue.Reserve(peer)
if request == nil {
continue
}

View file

@ -191,7 +191,7 @@ func (dl *downloadTester) badBlocksPeer(id string, td *big.Int, hash common.Hash
func TestDownload(t *testing.T) {
minDesiredPeerCount = 4
blockTTL = 1 * time.Second
blockHardTTL = 1 * time.Second
targetBlocks := 1000
hashes := createHashes(0, targetBlocks)
@ -240,7 +240,7 @@ func TestMissing(t *testing.T) {
func TestTaking(t *testing.T) {
minDesiredPeerCount = 4
blockTTL = 1 * time.Second
blockHardTTL = 1 * time.Second
targetBlocks := 1000
hashes := createHashes(0, targetBlocks)
@ -281,7 +281,7 @@ func TestInactiveDownloader(t *testing.T) {
func TestCancel(t *testing.T) {
minDesiredPeerCount = 4
blockTTL = 1 * time.Second
blockHardTTL = 1 * time.Second
targetBlocks := 1000
hashes := createHashes(0, targetBlocks)
@ -307,7 +307,7 @@ func TestCancel(t *testing.T) {
func TestThrottling(t *testing.T) {
minDesiredPeerCount = 4
blockTTL = 1 * time.Second
blockHardTTL = 1 * time.Second
targetBlocks := 16 * blockCacheLimit
hashes := createHashes(0, targetBlocks)
@ -461,7 +461,7 @@ func TestInvalidHashOrderAttack(t *testing.T) {
// Tests that if a malicious peer makes up a random hash chain and tries to push
// indefinitely, it actually gets caught with it.
func TestMadeupHashChainAttack(t *testing.T) {
blockTTL = 100 * time.Millisecond
blockSoftTTL = 100 * time.Millisecond
crossCheckCycle = 25 * time.Millisecond
// Create a long chain of hashes without backing blocks
@ -495,10 +495,10 @@ func TestMadeupHashChainDrippingAttack(t *testing.T) {
// Tests that if a malicious peer makes up a random block chain, and tried to
// push indefinitely, it actually gets caught with it.
func TestMadeupBlockChainAttack(t *testing.T) {
defaultBlockTTL := blockTTL
defaultBlockTTL := blockSoftTTL
defaultCrossCheckCycle := crossCheckCycle
blockTTL = 100 * time.Millisecond
blockSoftTTL = 100 * time.Millisecond
crossCheckCycle = 25 * time.Millisecond
// Create a long chain of blocks and simulate an invalid chain by dropping every second
@ -516,7 +516,7 @@ func TestMadeupBlockChainAttack(t *testing.T) {
t.Fatalf("synchronisation error mismatch: have %v, want %v", err, ErrCrossCheckFailed)
}
// Ensure that a valid chain can still pass sync
blockTTL = defaultBlockTTL
blockSoftTTL = defaultBlockTTL
crossCheckCycle = defaultCrossCheckCycle
tester.hashes = hashes
@ -530,10 +530,10 @@ func TestMadeupBlockChainAttack(t *testing.T) {
// attacker make up a valid hashes for random blocks, but also forges the block
// parents to point to existing hashes.
func TestMadeupParentBlockChainAttack(t *testing.T) {
defaultBlockTTL := blockTTL
defaultBlockTTL := blockSoftTTL
defaultCrossCheckCycle := crossCheckCycle
blockTTL = 100 * time.Millisecond
blockSoftTTL = 100 * time.Millisecond
crossCheckCycle = 25 * time.Millisecond
// Create a long chain of blocks and simulate an invalid chain by dropping every second
@ -550,7 +550,7 @@ func TestMadeupParentBlockChainAttack(t *testing.T) {
t.Fatalf("synchronisation error mismatch: have %v, want %v", err, ErrCrossCheckFailed)
}
// Ensure that a valid chain can still pass sync
blockTTL = defaultBlockTTL
blockSoftTTL = defaultBlockTTL
crossCheckCycle = defaultCrossCheckCycle
tester.blocks = blocks

View file

@ -5,10 +5,14 @@ package downloader
import (
"errors"
"math"
"sync"
"sync/atomic"
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"gopkg.in/fatih/set.v0"
)
@ -27,14 +31,15 @@ type peer struct {
head common.Hash // Hash of the peers latest known block
idle int32 // Current activity state of the peer (idle = 0, active = 1)
rep int32 // Simple peer reputation (not used currently)
rep int32 // Simple peer reputation
mu sync.RWMutex
capacity int32 // Number of blocks allowed to fetch per request
started time.Time // Time instance when the last fetch was started
ignored *set.Set
ignored *set.Set // Set of hashes not to request (didn't have previously)
getHashes hashFetcherFn
getBlocks blockFetcherFn
getHashes hashFetcherFn // Method to retrieve a batch of hashes (mockable for testing)
getBlocks blockFetcherFn // Method to retrieve a batch of blocks (mockable for testing)
}
// newPeer create a new downloader peer, with specific hash and block retrieval
@ -43,6 +48,7 @@ func newPeer(id string, head common.Hash, getHashes hashFetcherFn, getBlocks blo
return &peer{
id: id,
head: head,
capacity: 1,
getHashes: getHashes,
getBlocks: getBlocks,
ignored: set.New(),
@ -52,6 +58,7 @@ func newPeer(id string, head common.Hash, getHashes hashFetcherFn, getBlocks blo
// Reset clears the internal state of a peer entity.
func (p *peer) Reset() {
atomic.StoreInt32(&p.idle, 0)
atomic.StoreInt32(&p.capacity, 1)
p.ignored.Clear()
}
@ -61,6 +68,8 @@ func (p *peer) Fetch(request *fetchRequest) error {
if !atomic.CompareAndSwapInt32(&p.idle, 0, 1) {
return errAlreadyFetching
}
p.started = time.Now()
// Convert the hash set to a retrievable slice
hashes := make([]common.Hash, 0, len(request.Hashes))
for hash, _ := range request.Hashes {
@ -72,10 +81,41 @@ func (p *peer) Fetch(request *fetchRequest) error {
}
// SetIdle sets the peer to idle, allowing it to execute new retrieval requests.
// Its block retrieval allowance will also be updated either up- or downwards,
// depending on whether the previous fetch completed in time or not.
func (p *peer) SetIdle() {
// Update the peer's download allowance based on previous performance
scale := 2.0
if time.Since(p.started) > blockSoftTTL {
scale = 0.5
}
for {
// Calculate the new download bandwidth allowance
prev := atomic.LoadInt32(&p.capacity)
next := int32(math.Max(1, math.Min(MaxBlockFetch, float64(prev)*scale)))
// Try to update the old value
if atomic.CompareAndSwapInt32(&p.capacity, prev, next) {
// If we're having problems at 1 capacity, try to find better peers
if next == 1 {
p.Demote()
}
if prev != next {
glog.V(logger.Detail).Infof("%s: changing block download capacity from %d to %d", p.id, prev, next)
}
break
}
}
// Set the peer to idle to allow further block requests
atomic.StoreInt32(&p.idle, 0)
}
// Capacity retrieves the peers block download allowance based on its previously
// discovered bandwidth capacity.
func (p *peer) Capacity() int {
return int(atomic.LoadInt32(&p.capacity))
}
// Promote increases the peer's reputation.
func (p *peer) Promote() {
atomic.AddInt32(&p.rep, 1)

View file

@ -203,7 +203,7 @@ func (q *queue) TakeBlocks() []*Block {
// Reserve reserves a set of hashes for the given peer, skipping any previously
// failed download.
func (q *queue) Reserve(p *peer, max int) *fetchRequest {
func (q *queue) Reserve(p *peer) *fetchRequest {
q.lock.Lock()
defer q.lock.Unlock()
@ -215,11 +215,17 @@ func (q *queue) Reserve(p *peer, max int) *fetchRequest {
if _, ok := q.pendPool[p.id]; ok {
return nil
}
// Calculate an upper limit on the hashes we might fetch (i.e. throttling)
space := len(q.blockCache) - len(q.blockPool)
for _, request := range q.pendPool {
space -= len(request.Hashes)
}
// Retrieve a batch of hashes, skipping previously failed ones
send := make(map[common.Hash]int)
skip := make(map[common.Hash]int)
for len(send) < max && !q.hashQueue.Empty() {
capacity := p.Capacity()
for len(send) < space && len(send) < capacity && !q.hashQueue.Empty() {
hash, priority := q.hashQueue.Pop()
if p.ignored.Has(hash) {
skip[hash.(common.Hash)] = int(priority)

View file

@ -1,8 +1,6 @@
package downloader
import (
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"gopkg.in/fatih/set.v0"
@ -30,32 +28,3 @@ func createBlocksFromHashSet(hashes *set.Set) []*types.Block {
return blocks
}
func TestChunking(t *testing.T) {
queue := newQueue()
peer1 := newPeer("peer1", common.Hash{}, nil, nil)
peer2 := newPeer("peer2", common.Hash{}, nil, nil)
// 99 + 1 (1 == known genesis hash)
hashes := createHashes(0, 99)
queue.Insert(hashes)
chunk1 := queue.Reserve(peer1, 99)
if chunk1 == nil {
t.Errorf("chunk1 is nil")
t.FailNow()
}
chunk2 := queue.Reserve(peer2, 99)
if chunk2 == nil {
t.Errorf("chunk2 is nil")
t.FailNow()
}
if len(chunk1.Hashes) != 99 {
t.Error("expected chunk1 hashes to be 99, got", len(chunk1.Hashes))
}
if len(chunk2.Hashes) != 1 {
t.Error("expected chunk1 hashes to be 1, got", len(chunk2.Hashes))
}
}

View file

@ -18,6 +18,7 @@ func TestBcValidBlockTests(t *testing.T) {
func TestBcUncleTests(t *testing.T) {
runBlockTestsInFile("files/BlockTests/bcUncleTest.json", []string{}, t)
runBlockTestsInFile("files/BlockTests/bcBruncleTest.json", []string{}, t)
}
func TestBcUncleHeaderValidityTests(t *testing.T) {

View file

@ -0,0 +1,265 @@
{
"UncleIsBrother" : {
"blocks" : [
{
"blockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "0x",
"gasLimit" : "0x2fefd8",
"gasUsed" : "0x5208",
"hash" : "b33b222d72b0ac4de8c6a85132ca00d082c858f5d8cd38faaec880bf01948868",
"mixHash" : "4429011a33e2fa9143440b2b3ec09203daaf899201db66fa5e269b17b88de65d",
"nonce" : "5df16caa8f38b720",
"number" : "0x01",
"parentHash" : "12762bcfc4e3a39bc07c594da011f7a1298de685d04fb78281fb808e24d2e922",
"receiptTrie" : "e9244cf7503b79c03d3a099e07a80d2dbc77bb0b502d8a89d51ac0d68dd31313",
"stateRoot" : "2c15e8b5cb6cf880faa558c76c02a591e181ef2c4450ad92e53ae6c21093dc70",
"timestamp" : "0x556cb4da",
"transactionsTrie" : "aa2cd9b3cb075451f4e5ba70792741f966d065b3e900f9338af5e61a992b107c",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"rlp" : "0xf90261f901f9a012762bcfc4e3a39bc07c594da011f7a1298de685d04fb78281fb808e24d2e922a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a02c15e8b5cb6cf880faa558c76c02a591e181ef2c4450ad92e53ae6c21093dc70a0aa2cd9b3cb075451f4e5ba70792741f966d065b3e900f9338af5e61a992b107ca0e9244cf7503b79c03d3a099e07a80d2dbc77bb0b502d8a89d51ac0d68dd31313b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd882520884556cb4da80a04429011a33e2fa9143440b2b3ec09203daaf899201db66fa5e269b17b88de65d885df16caa8f38b720f862f86080018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba0f569d8483892e3d35d84c69db9404e951a8dbd94f4d74dafa2bb47a53d1bec02a0e32607cfa73b4b2af5c08970edb3bba3aade4c05e54d65735f923d7a4c2f5c9bc0",
"transactions" : [
{
"data" : "0x",
"gasLimit" : "0x04cb2f",
"gasPrice" : "0x01",
"nonce" : "0x00",
"r" : "0xf569d8483892e3d35d84c69db9404e951a8dbd94f4d74dafa2bb47a53d1bec02",
"s" : "0xe32607cfa73b4b2af5c08970edb3bba3aade4c05e54d65735f923d7a4c2f5c9b",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"v" : "0x1b",
"value" : "0x0a"
}
],
"uncleHeaders" : [
]
},
{
"blockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020040",
"extraData" : "0x",
"gasLimit" : "0x2fefd8",
"gasUsed" : "0x5208",
"hash" : "5a9cba116901d3e11fa9d93ef421c83762912e348625d3d2f559a661d4455d7e",
"mixHash" : "bad21f7ba41f2e18257ac63c74596d6a24e530cbe2f8ac16e00e5603b90b5879",
"nonce" : "e3ba58fa89603930",
"number" : "0x02",
"parentHash" : "b33b222d72b0ac4de8c6a85132ca00d082c858f5d8cd38faaec880bf01948868",
"receiptTrie" : "5a750181d80a2b69fac54c1b2f7a37ebc4666ea5320e25db6603b90958686b27",
"stateRoot" : "a2a5e3d96e902272adb58e90c364f7b92684c539e0ded77356cf33d966f917fe",
"timestamp" : "0x556cb4dc",
"transactionsTrie" : "87ac5f6dad44a1d936ac91c7adc1af1432c4de558437c28a0310cad080618788",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"rlp" : "0xf90261f901f9a0b33b222d72b0ac4de8c6a85132ca00d082c858f5d8cd38faaec880bf01948868a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0a2a5e3d96e902272adb58e90c364f7b92684c539e0ded77356cf33d966f917fea087ac5f6dad44a1d936ac91c7adc1af1432c4de558437c28a0310cad080618788a05a750181d80a2b69fac54c1b2f7a37ebc4666ea5320e25db6603b90958686b27b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302004002832fefd882520884556cb4dc80a0bad21f7ba41f2e18257ac63c74596d6a24e530cbe2f8ac16e00e5603b90b587988e3ba58fa89603930f862f86001018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba01efcde76a5247d3d54a0a6ba2c41c92eb947d217521eb2bd9336354353d99795a075bb5a9e0cb47db96c827e4e0c813bf0df09e402cbf637c8d6ca904abd0b9b90c0",
"transactions" : [
{
"data" : "0x",
"gasLimit" : "0x04cb2f",
"gasPrice" : "0x01",
"nonce" : "0x01",
"r" : "0x1efcde76a5247d3d54a0a6ba2c41c92eb947d217521eb2bd9336354353d99795",
"s" : "0x75bb5a9e0cb47db96c827e4e0c813bf0df09e402cbf637c8d6ca904abd0b9b90",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"v" : "0x1b",
"value" : "0x0a"
}
],
"uncleHeaders" : [
]
},
{
"rlp" : "0xf903f8f901f7a05a9cba116901d3e11fa9d93ef421c83762912e348625d3d2f559a661d4455d7ea0252fa1b79fd960f83f1e9ec4770a29596996326eb34fd0e91d5e74e79db6c05b948888f1f195afa192cfee860698584c030f4c9db1a0a2a5e3d96e902272adb58e90c364f7b92684c539e0ded77356cf33d966f917fea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefd88084556cb4e280a000f430211f20f7885d46f98cdb697e40a4e8c685b654101ab878ec0bb526ebb588feff31c8314b072ac0f901faf901f7a05a9cba116901d3e11fa9d93ef421c83762912e348625d3d2f559a661d4455d7ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794acde5374fce5edbc8e2a8697c15331677e6ebf0ba0a2a5e3d96e902272adb58e90c364f7b92684c539e0ded77356cf33d966f917fea056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefd88084556cb4de80a059be7526b162cde243feac643a5c8ffc455c6f77fa1fa912961893687b65017188e049f43874907e7c"
}
],
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "0x42",
"gasLimit" : "0x2fefd8",
"gasUsed" : "0x00",
"hash" : "12762bcfc4e3a39bc07c594da011f7a1298de685d04fb78281fb808e24d2e922",
"mixHash" : "72ac0702fd9563f986d604eecd03931452e716b7915e1d81babf77747eb631af",
"nonce" : "efe914e72f8823a7",
"number" : "0x00",
"parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "7dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1",
"timestamp" : "0x54c98c81",
"transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a07dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a072ac0702fd9563f986d604eecd03931452e716b7915e1d81babf77747eb631af88efe914e72f8823a7c0c0",
"lastblockhash" : "5a9cba116901d3e11fa9d93ef421c83762912e348625d3d2f559a661d4455d7e",
"postState" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x14",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"8888f1f195afa192cfee860698584c030f4c9db1" : {
"balance" : "0x29a2241af62ca410",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x09184e71fbdc",
"code" : "0x",
"nonce" : "0x02",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x09184e72a000",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"UncleIsBrother2" : {
"blocks" : [
{
"blockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "0x",
"gasLimit" : "0x2fefd8",
"gasUsed" : "0x5208",
"hash" : "b33b222d72b0ac4de8c6a85132ca00d082c858f5d8cd38faaec880bf01948868",
"mixHash" : "4429011a33e2fa9143440b2b3ec09203daaf899201db66fa5e269b17b88de65d",
"nonce" : "5df16caa8f38b720",
"number" : "0x01",
"parentHash" : "12762bcfc4e3a39bc07c594da011f7a1298de685d04fb78281fb808e24d2e922",
"receiptTrie" : "e9244cf7503b79c03d3a099e07a80d2dbc77bb0b502d8a89d51ac0d68dd31313",
"stateRoot" : "2c15e8b5cb6cf880faa558c76c02a591e181ef2c4450ad92e53ae6c21093dc70",
"timestamp" : "0x556cb4da",
"transactionsTrie" : "aa2cd9b3cb075451f4e5ba70792741f966d065b3e900f9338af5e61a992b107c",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"rlp" : "0xf90261f901f9a012762bcfc4e3a39bc07c594da011f7a1298de685d04fb78281fb808e24d2e922a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a02c15e8b5cb6cf880faa558c76c02a591e181ef2c4450ad92e53ae6c21093dc70a0aa2cd9b3cb075451f4e5ba70792741f966d065b3e900f9338af5e61a992b107ca0e9244cf7503b79c03d3a099e07a80d2dbc77bb0b502d8a89d51ac0d68dd31313b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000001832fefd882520884556cb4da80a04429011a33e2fa9143440b2b3ec09203daaf899201db66fa5e269b17b88de65d885df16caa8f38b720f862f86080018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba0f569d8483892e3d35d84c69db9404e951a8dbd94f4d74dafa2bb47a53d1bec02a0e32607cfa73b4b2af5c08970edb3bba3aade4c05e54d65735f923d7a4c2f5c9bc0",
"transactions" : [
{
"data" : "0x",
"gasLimit" : "0x04cb2f",
"gasPrice" : "0x01",
"nonce" : "0x00",
"r" : "0xf569d8483892e3d35d84c69db9404e951a8dbd94f4d74dafa2bb47a53d1bec02",
"s" : "0xe32607cfa73b4b2af5c08970edb3bba3aade4c05e54d65735f923d7a4c2f5c9b",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"v" : "0x1b",
"value" : "0x0a"
}
],
"uncleHeaders" : [
]
},
{
"blockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020040",
"extraData" : "0x",
"gasLimit" : "0x2fefd8",
"gasUsed" : "0x5208",
"hash" : "5a9cba116901d3e11fa9d93ef421c83762912e348625d3d2f559a661d4455d7e",
"mixHash" : "bad21f7ba41f2e18257ac63c74596d6a24e530cbe2f8ac16e00e5603b90b5879",
"nonce" : "e3ba58fa89603930",
"number" : "0x02",
"parentHash" : "b33b222d72b0ac4de8c6a85132ca00d082c858f5d8cd38faaec880bf01948868",
"receiptTrie" : "5a750181d80a2b69fac54c1b2f7a37ebc4666ea5320e25db6603b90958686b27",
"stateRoot" : "a2a5e3d96e902272adb58e90c364f7b92684c539e0ded77356cf33d966f917fe",
"timestamp" : "0x556cb4dc",
"transactionsTrie" : "87ac5f6dad44a1d936ac91c7adc1af1432c4de558437c28a0310cad080618788",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"rlp" : "0xf90261f901f9a0b33b222d72b0ac4de8c6a85132ca00d082c858f5d8cd38faaec880bf01948868a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a0a2a5e3d96e902272adb58e90c364f7b92684c539e0ded77356cf33d966f917fea087ac5f6dad44a1d936ac91c7adc1af1432c4de558437c28a0310cad080618788a05a750181d80a2b69fac54c1b2f7a37ebc4666ea5320e25db6603b90958686b27b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302004002832fefd882520884556cb4dc80a0bad21f7ba41f2e18257ac63c74596d6a24e530cbe2f8ac16e00e5603b90b587988e3ba58fa89603930f862f86001018304cb2f94095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba01efcde76a5247d3d54a0a6ba2c41c92eb947d217521eb2bd9336354353d99795a075bb5a9e0cb47db96c827e4e0c813bf0df09e402cbf637c8d6ca904abd0b9b90c0",
"transactions" : [
{
"data" : "0x",
"gasLimit" : "0x04cb2f",
"gasPrice" : "0x01",
"nonce" : "0x01",
"r" : "0x1efcde76a5247d3d54a0a6ba2c41c92eb947d217521eb2bd9336354353d99795",
"s" : "0x75bb5a9e0cb47db96c827e4e0c813bf0df09e402cbf637c8d6ca904abd0b9b90",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"v" : "0x1b",
"value" : "0x0a"
}
],
"uncleHeaders" : [
]
},
{
"rlp" : "0xf903f8f901f7a05a9cba116901d3e11fa9d93ef421c83762912e348625d3d2f559a661d4455d7ea0252fa1b79fd960f83f1e9ec4770a29596996326eb34fd0e91d5e74e79db6c05b948888f1f195afa192cfee860698584c030f4c9db1a01b8bf4ebfcd765992f945d162f677e5b5655b464121f9c057163cae9119fc3e9a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefd88084556cb4e280a000f430211f20f7885d46f98cdb697e40a4e8c685b654101ab878ec0bb526ebb588feff31c8314b072ac0f901faf901f7a05a9cba116901d3e11fa9d93ef421c83762912e348625d3d2f559a661d4455d7ea01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794acde5374fce5edbc8e2a8697c15331677e6ebf0ba01b8bf4ebfcd765992f945d162f677e5b5655b464121f9c057163cae9119fc3e9a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302008003832fefd88084556cb4de80a059be7526b162cde243feac643a5c8ffc455c6f77fa1fa912961893687b65017188e049f43874907e7c"
}
],
"genesisBlockHeader" : {
"bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"coinbase" : "8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty" : "0x020000",
"extraData" : "0x42",
"gasLimit" : "0x2fefd8",
"gasUsed" : "0x00",
"hash" : "12762bcfc4e3a39bc07c594da011f7a1298de685d04fb78281fb808e24d2e922",
"mixHash" : "72ac0702fd9563f986d604eecd03931452e716b7915e1d81babf77747eb631af",
"nonce" : "efe914e72f8823a7",
"number" : "0x00",
"parentHash" : "0000000000000000000000000000000000000000000000000000000000000000",
"receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "7dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1",
"timestamp" : "0x54c98c81",
"transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
},
"genesisRLP" : "0xf901fcf901f7a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347948888f1f195afa192cfee860698584c030f4c9db1a07dba07d6b448a186e9612e5f737d1c909dce473e53199901a302c00646d523c1a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b90100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008302000080832fefd8808454c98c8142a072ac0702fd9563f986d604eecd03931452e716b7915e1d81babf77747eb631af88efe914e72f8823a7c0c0",
"lastblockhash" : "5a9cba116901d3e11fa9d93ef421c83762912e348625d3d2f559a661d4455d7e",
"postState" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x14",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"8888f1f195afa192cfee860698584c030f4c9db1" : {
"balance" : "0x29a2241af62ca410",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x09184e71fbdc",
"code" : "0x",
"nonce" : "0x02",
"storage" : {
}
}
},
"pre" : {
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x09184e72a000",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,71 @@
{
"randomStatetest" : {
"env" : {
"currentCoinbase" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
"currentDifficulty" : "0x051d6a3cd647",
"currentGasLimit" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"logs" : [
],
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x00",
"code" : "0x7e24654d920bee1c2af8b3225f6035ea04b87e1d3f2486057268ed05d8d6e5a67f3da4409848b450c9ab9713bf10ec5124e50fda175accc13d0db75bbc03a25a066d85332a97eae6e7219bc62ce53f23690f1df7f7b11c1659165b7c438533bc1f73a59ae2c28e633d8c971763576dd25386518678a15c64a2682c68bf3c1a7433af2e6dd0276f494254235fe7b28b1f997661eba4767c05f37a8b9b7980106e2bbe8744bed6d0f782ac6a99e07d9486451ab20e48c9e99f083973d5a10a57f4c3e7e3fa3bfd63a39006f35f7325ae8b67348d74c87e78d6dc699541fdf8d085697e58b02f9fef3f78554901cc888449b92fe07e74fb3069f7be725f408005886e73e720275f04f63284f6f10b6df25694b3a55936d06ed8c18d03d868d30b7766bd0d6a111f734650113a9f6b31ef3be38904ccd66a304bbf877e9d6ccc3e98fa65a685b0bf181c6dd67c9db728914ff2977b8c19193f67b9053f72c819b5bc5542945bd6a9079965d91f47a11f3862d346cb6b70d29eca71b0d12d01996b89763f13059617d671ddc626d93a3e3fda99999484470e34277f9ac904a6be6b8b9f0a91e98e2759a946222e419d34089491db069bbeeea7d19868e6fef55cd7440fbbdd7bf7cab153de2f407fc2c1f51952d5d5388159f73c98deb0a3f75d04eb70cee4f3dd886b6ba2ab3d1e110db841c50767a4e0ed4abca1bd1d6688861c4bb169fa8b63d253f1a4636a3979396965ae9c16c2197c57851d68f1ee6fff3c92e794d07cc6d2f5b964448fee1c3f52921cd138bfe26f57a3ce26ae8e622c80fcfb7f414b5750048e67dd2c715bdf907a881ef7a77dc8b166b413ebb4261bda628c26666d7ec3d2d20bdc7e117960da38d995574327fc1b63764875b839f395793a937b5f2793db93b23b7160bb44cf7bf515a85769d5f51851260f073969b185817c3e5b658753947f6ae534b0e68afa57a476ff52028737e7d342c1ddc7c5dc786fe6216838882c6f6e8519b16b2d9451ea2f048765576af461aab462031f6a64f0ae07fa9a64d4772252eb9e6aa14429a7e2a1d43482699065e44695fbea176d63d01d22231d221b6f8dfda47f5164a47454ab396f17257ddec269f67ed7c6d17ffac1c61372aaf587427eee43772c5f28fde9d395b65bf2d77e4eaa635bea61396414a53508797e2506ed2f921f29bf2fda1796f4396c4edb6f6ecc6d79fd82d9838a512df1454ce72268d8a32e0971c718b6836e4bcb788766f266a3edfdd24686274f684c4b0a7fd7082159766f4670a09a9e231bf61fe5f955a75b8870744ec89c81940d46be921c40917862e1c186679f354a704fd5537ceb310616acf9779c43c8f585c064fafa775d279d62aec380625fc16d601ef067eddffdf0f1359f386970fe2eb95c063421601a7a5f9256a6398651be88998deb83d16edd603992a27f758bda8c1bf974e49a52cf19c9bc32a79db4778535677e3caeae7f2f6ac54f147d2729c30d694bcb622c13106c3382d4c27bc4ee55eadb4921d97965e605bd3daa1c233230119dce876049813474dc4b3ec1d0ea8d73d182beb19cd3c8f198578d863907a60fd633a65872d93e47dc134fc815d9800bad3f2d58bb97b5776f42800f1f182951ba5aced03a7c3abd859969483189606297788fbf5565010d13f07077752867293dbfe29b7346020ef70d18cacd7508ccb3731b39",
"nonce" : "0x00",
"storage" : {
}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "0x585b6403",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b34f089c2b",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
}
},
"postStateRoot" : "35be6da6c9ec9648acf14171b9d9a2798a7143ba751a2374c3c2678452e2c0de",
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x00",
"code" : "0x7e24654d920bee1c2af8b3225f6035ea04b87e1d3f2486057268ed05d8d6e5a67f3da4409848b450c9ab9713bf10ec5124e50fda175accc13d0db75bbc03a25a066d85332a97eae6e7219bc62ce53f23690f1df7f7b11c1659165b7c438533bc1f73a59ae2c28e633d8c971763576dd25386518678a15c64a2682c68bf3c1a7433af2e6dd0276f494254235fe7b28b1f997661eba4767c05f37a8b9b7980106e2bbe8744bed6d0f782ac6a99e07d9486451ab20e48c9e99f083973d5a10a57f4c3e7e3fa3bfd63a39006f35f7325ae8b67348d74c87e78d6dc699541fdf8d085697e58b02f9fef3f78554901cc888449b92fe07e74fb3069f7be725f408005886e73e720275f04f63284f6f10b6df25694b3a55936d06ed8c18d03d868d30b7766bd0d6a111f734650113a9f6b31ef3be38904ccd66a304bbf877e9d6ccc3e98fa65a685b0bf181c6dd67c9db728914ff2977b8c19193f67b9053f72c819b5bc5542945bd6a9079965d91f47a11f3862d346cb6b70d29eca71b0d12d01996b89763f13059617d671ddc626d93a3e3fda99999484470e34277f9ac904a6be6b8b9f0a91e98e2759a946222e419d34089491db069bbeeea7d19868e6fef55cd7440fbbdd7bf7cab153de2f407fc2c1f51952d5d5388159f73c98deb0a3f75d04eb70cee4f3dd886b6ba2ab3d1e110db841c50767a4e0ed4abca1bd1d6688861c4bb169fa8b63d253f1a4636a3979396965ae9c16c2197c57851d68f1ee6fff3c92e794d07cc6d2f5b964448fee1c3f52921cd138bfe26f57a3ce26ae8e622c80fcfb7f414b5750048e67dd2c715bdf907a881ef7a77dc8b166b413ebb4261bda628c26666d7ec3d2d20bdc7e117960da38d995574327fc1b63764875b839f395793a937b5f2793db93b23b7160bb44cf7bf515a85769d5f51851260f073969b185817c3e5b658753947f6ae534b0e68afa57a476ff52028737e7d342c1ddc7c5dc786fe6216838882c6f6e8519b16b2d9451ea2f048765576af461aab462031f6a64f0ae07fa9a64d4772252eb9e6aa14429a7e2a1d43482699065e44695fbea176d63d01d22231d221b6f8dfda47f5164a47454ab396f17257ddec269f67ed7c6d17ffac1c61372aaf587427eee43772c5f28fde9d395b65bf2d77e4eaa635bea61396414a53508797e2506ed2f921f29bf2fda1796f4396c4edb6f6ecc6d79fd82d9838a512df1454ce72268d8a32e0971c718b6836e4bcb788766f266a3edfdd24686274f684c4b0a7fd7082159766f4670a09a9e231bf61fe5f955a75b8870744ec89c81940d46be921c40917862e1c186679f354a704fd5537ceb310616acf9779c43c8f585c064fafa775d279d62aec380625fc16d601ef067eddffdf0f1359f386970fe2eb95c063421601a7a5f9256a6398651be88998deb83d16edd603992a27f758bda8c1bf974e49a52cf19c9bc32a79db4778535677e3caeae7f2f6ac54f147d2729c30d694bcb622c13106c3382d4c27bc4ee55eadb4921d97965e605bd3daa1c233230119dce876049813474dc4b3ec1d0ea8d73d182beb19cd3c8f198578d863907a60fd633a65872d93e47dc134fc815d9800bad3f2d58bb97b5776f42800f1f182951ba5aced03a7c3abd859969483189606297788fbf5565010d13f07077752867293dbfe29b7346020ef70d18cacd7508ccb3731b39",
"nonce" : "0x00",
"storage" : {
}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "0x2e",
"code" : "0x6000355415600957005b60203560003555",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0de0b6b3a7640000",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
}
},
"transaction" : {
"data" : "0x387814bf0652a6f3aefce6ef7be00599328bbf7e802e1ea22644a96fbf319d273c0e715067e4e5e74ecfc3ae60fd917b9224a4bbaa6db919506fc9e3cd4792dbecb1427e907653a3e359acf57c1e4afae77816fdc406706133e14efc6fe3ed1dc01f663f8e79c5fb6a32685ec748da76ab766d20766430b1775afa280f1c02e5617230d3b68fa16d4d73a1b27ae07b1096d44b02414374765d0907504a2f25e45aee4fdbb17b244e93714f36d9c035346d67ce3c18bf3d3af42f3b5f807689e8f429c0070a5812d602d25c4664cccfa7ddff8188f174c046eef00dcd5355c37d900a2ce940246fcaada0526acdd4eaf98a420bae34e22b37",
"gasLimit" : "0x585b63d5",
"gasPrice" : "0x01",
"nonce" : "0x00",
"secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8",
"to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87",
"value" : "0x72f740ab"
}
}
}

View file

@ -142,21 +142,28 @@
"out" : "0x",
"post" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
"balance" : "0x0de0b6b3a764000a",
"code" : "0x600040600055610101406001557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff40600255",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0f4240",
"2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
"balance" : "0x8cee",
"code" : "0x",
"nonce" : "0x00",
"storage" : {
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x3a3218",
"code" : "0x",
"nonce" : "0x01",
"storage" : {
}
}
},
"postStateRoot" : "06288380a8085485ac48f0b726c86f3e6253946ba969ed0d9e1a0f34d0133b81",
"postStateRoot" : "2a12af36bb359a981bcefc9256eb5fbed4acad1c27be59c2f726b547dfafec2a",
"pre" : {
"095e7baea6a6c7c4c2dfeb977efac326af552d87" : {
"balance" : "0x0de0b6b3a7640000",
@ -166,7 +173,7 @@
}
},
"a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
"balance" : "0x0f4240",
"balance" : "0x3abf10",
"code" : "0x",
"nonce" : "0x00",
"storage" : {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -3073,6 +3073,78 @@
}
}
},
"jumpToUint64maxPlus1" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x0f4240",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x6801000000000000000b565b5b6001600155",
"data" : "0x",
"gas" : "0x0186a0",
"gasPrice" : "0x5af3107a4000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "0x0de0b6b3a7640000"
},
"expect" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"storage" : {
"0x01" : "0x00"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x6801000000000000000b565b5b6001600155",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"jumpToUintmaxPlus1" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x0f4240",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x640100000007565b5b6001600155",
"data" : "0x",
"gas" : "0x0186a0",
"gasPrice" : "0x5af3107a4000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "0x0de0b6b3a7640000"
},
"expect" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"storage" : {
"0x01" : "0x00"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x640100000007565b5b6001600155",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"jumpdestBigList" : {
"callcreates" : [
],
@ -3294,6 +3366,78 @@
}
}
},
"jumpiToUint64maxPlus1" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x0f4240",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x60016801000000000000000d575b5b6001600155",
"data" : "0x",
"gas" : "0x0186a0",
"gasPrice" : "0x5af3107a4000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "0x0de0b6b3a7640000"
},
"expect" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"storage" : {
"0x01" : "0x00"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x60016801000000000000000d575b5b6001600155",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"jumpiToUintmaxPlus1" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x0f4240",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x6001640100000009575b5b6001600155",
"data" : "0x",
"gas" : "0x0186a0",
"gasPrice" : "0x5af3107a4000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "0x0de0b6b3a7640000"
},
"expect" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"storage" : {
"0x01" : "0x00"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x6001640100000009575b5b6001600155",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"jumpi_at_the_end" : {
"callcreates" : [
],

View file

@ -2050,6 +2050,95 @@
}
}
},
"push32Undefined" : {
"callcreates" : [
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x0f4240",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x7f010203600055",
"data" : "0x",
"gas" : "0x0186a0",
"gasPrice" : "0x5af3107a4000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "0x0de0b6b3a7640000"
},
"gas" : "0x01869d",
"logs" : [
],
"out" : "0x",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x7f010203600055",
"nonce" : "0x00",
"storage" : {
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x7f010203600055",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"push32Undefined2" : {
"callcreates" : [
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "0x0100",
"currentGasLimit" : "0x0f4240",
"currentNumber" : "0x00",
"currentTimestamp" : "0x01",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x7f0102030000000000000000000000000000000000000000000000000000000000600055",
"data" : "0x",
"gas" : "0x0186a0",
"gasPrice" : "0x5af3107a4000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "0x0de0b6b3a7640000"
},
"gas" : "0x01387a",
"logs" : [
],
"out" : "0x",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x7f0102030000000000000000000000000000000000000000000000000000000000600055",
"nonce" : "0x00",
"storage" : {
"0x00" : "0x0102030000000000000000000000000000000000000000000000000000000000"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "0x152d02c7e14af6800000",
"code" : "0x7f0102030000000000000000000000000000000000000000000000000000000000600055",
"nonce" : "0x00",
"storage" : {
}
}
}
},
"push33" : {
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",

View file

@ -139,6 +139,10 @@ type Transaction struct {
}
func NewTx(tx *types.Transaction) *Transaction {
sender, err := tx.From()
if err != nil {
return nil
}
hash := tx.Hash().Hex()
var receiver string
@ -147,7 +151,6 @@ func NewTx(tx *types.Transaction) *Transaction {
} else {
receiver = core.AddressFromMessage(tx).Hex()
}
sender, _ := tx.From()
createsContract := core.MessageCreatesContract(tx)
var data string