Compare commits
6 Commits
master
...
release/1.
Author | SHA1 | Date | |
---|---|---|---|
|
6962eda19d | ||
|
619b37ca37 | ||
|
465e810c66 | ||
|
274f86cd86 | ||
|
b527c9c718 | ||
|
9666db2a44 |
@ -48,10 +48,10 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ClientIdentifier = "Geth"
|
ClientIdentifier = "Geth"
|
||||||
Version = "1.2.0"
|
Version = "1.2.3"
|
||||||
VersionMajor = 1
|
VersionMajor = 1
|
||||||
VersionMinor = 2
|
VersionMinor = 2
|
||||||
VersionPatch = 0
|
VersionPatch = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -804,7 +804,9 @@ func (self *ChainManager) reorg(oldBlock, newBlock *types.Block) error {
|
|||||||
DeleteReceipt(self.chainDb, tx.Hash())
|
DeleteReceipt(self.chainDb, tx.Hash())
|
||||||
DeleteTransaction(self.chainDb, tx.Hash())
|
DeleteTransaction(self.chainDb, tx.Hash())
|
||||||
}
|
}
|
||||||
self.eventMux.Post(RemovedTransactionEvent{diff})
|
// Must be posted in a goroutine because of the transaction pool trying
|
||||||
|
// to acquire the chain manager lock
|
||||||
|
go self.eventMux.Post(RemovedTransactionEvent{diff})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@ type Environment interface {
|
|||||||
|
|
||||||
Origin() common.Address
|
Origin() common.Address
|
||||||
BlockNumber() *big.Int
|
BlockNumber() *big.Int
|
||||||
GetHash(n uint64) common.Hash
|
// The n'th hash ago from this block number
|
||||||
|
GetHash(uint64) common.Hash
|
||||||
|
// The handler's address
|
||||||
Coinbase() common.Address
|
Coinbase() common.Address
|
||||||
Time() *big.Int
|
Time() *big.Int
|
||||||
Difficulty() *big.Int
|
Difficulty() *big.Int
|
||||||
|
@ -59,8 +59,10 @@ func (self *VMEnv) SetDepth(i int) { self.depth = i }
|
|||||||
func (self *VMEnv) VmType() vm.Type { return self.typ }
|
func (self *VMEnv) VmType() vm.Type { return self.typ }
|
||||||
func (self *VMEnv) SetVmType(t vm.Type) { self.typ = t }
|
func (self *VMEnv) SetVmType(t vm.Type) { self.typ = t }
|
||||||
func (self *VMEnv) GetHash(n uint64) common.Hash {
|
func (self *VMEnv) GetHash(n uint64) common.Hash {
|
||||||
if block := self.chain.GetBlockByNumber(n); block != nil {
|
for block := self.chain.GetBlock(self.header.ParentHash); block != nil; block = self.chain.GetBlock(block.ParentHash()) {
|
||||||
return block.Hash()
|
if block.NumberU64() == n {
|
||||||
|
return block.Hash()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.Hash{}
|
return common.Hash{}
|
||||||
|
@ -816,7 +816,7 @@ func (d *Downloader) fetchBlocks61(from uint64) error {
|
|||||||
}
|
}
|
||||||
// Send a download request to all idle peers, until throttled
|
// Send a download request to all idle peers, until throttled
|
||||||
throttled := false
|
throttled := false
|
||||||
for _, peer := range d.peers.IdlePeers() {
|
for _, peer := range d.peers.IdlePeers(eth61) {
|
||||||
// Short circuit if throttling activated
|
// Short circuit if throttling activated
|
||||||
if d.queue.Throttle() {
|
if d.queue.Throttle() {
|
||||||
throttled = true
|
throttled = true
|
||||||
@ -1255,7 +1255,7 @@ func (d *Downloader) fetchBodies(from uint64) error {
|
|||||||
}
|
}
|
||||||
// Send a download request to all idle peers, until throttled
|
// Send a download request to all idle peers, until throttled
|
||||||
queuedEmptyBlocks, throttled := false, false
|
queuedEmptyBlocks, throttled := false, false
|
||||||
for _, peer := range d.peers.IdlePeers() {
|
for _, peer := range d.peers.IdlePeers(eth62) {
|
||||||
// Short circuit if throttling activated
|
// Short circuit if throttling activated
|
||||||
if d.queue.Throttle() {
|
if d.queue.Throttle() {
|
||||||
throttled = true
|
throttled = true
|
||||||
|
@ -205,9 +205,17 @@ func (dl *downloadTester) newSlowPeer(id string, version int, hashes []common.Ha
|
|||||||
dl.lock.Lock()
|
dl.lock.Lock()
|
||||||
defer dl.lock.Unlock()
|
defer dl.lock.Unlock()
|
||||||
|
|
||||||
err := dl.downloader.RegisterPeer(id, version, hashes[0],
|
var err error
|
||||||
dl.peerGetRelHashesFn(id, delay), dl.peerGetAbsHashesFn(id, delay), dl.peerGetBlocksFn(id, delay),
|
switch version {
|
||||||
dl.peerGetRelHeadersFn(id, delay), dl.peerGetAbsHeadersFn(id, delay), dl.peerGetBodiesFn(id, delay))
|
case 61:
|
||||||
|
err = dl.downloader.RegisterPeer(id, version, hashes[0], dl.peerGetRelHashesFn(id, delay), dl.peerGetAbsHashesFn(id, delay), dl.peerGetBlocksFn(id, delay), nil, nil, nil)
|
||||||
|
case 62:
|
||||||
|
err = dl.downloader.RegisterPeer(id, version, hashes[0], nil, nil, nil, dl.peerGetRelHeadersFn(id, delay), dl.peerGetAbsHeadersFn(id, delay), dl.peerGetBodiesFn(id, delay))
|
||||||
|
case 63:
|
||||||
|
err = dl.downloader.RegisterPeer(id, version, hashes[0], nil, nil, nil, dl.peerGetRelHeadersFn(id, delay), dl.peerGetAbsHeadersFn(id, delay), dl.peerGetBodiesFn(id, delay))
|
||||||
|
case 64:
|
||||||
|
err = dl.downloader.RegisterPeer(id, version, hashes[0], nil, nil, nil, dl.peerGetRelHeadersFn(id, delay), dl.peerGetAbsHeadersFn(id, delay), dl.peerGetBodiesFn(id, delay))
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Assign the owned hashes and blocks to the peer (deep copy)
|
// Assign the owned hashes and blocks to the peer (deep copy)
|
||||||
dl.peerHashes[id] = make([]common.Hash, len(hashes))
|
dl.peerHashes[id] = make([]common.Hash, len(hashes))
|
||||||
@ -618,6 +626,41 @@ func testMultiSynchronisation(t *testing.T, protocol int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that synchronisations behave well in multi-version protocol environments
|
||||||
|
// and not wreak havok on other nodes in the network.
|
||||||
|
func TestMultiProtocolSynchronisation61(t *testing.T) { testMultiProtocolSynchronisation(t, 61) }
|
||||||
|
func TestMultiProtocolSynchronisation62(t *testing.T) { testMultiProtocolSynchronisation(t, 62) }
|
||||||
|
func TestMultiProtocolSynchronisation63(t *testing.T) { testMultiProtocolSynchronisation(t, 63) }
|
||||||
|
func TestMultiProtocolSynchronisation64(t *testing.T) { testMultiProtocolSynchronisation(t, 64) }
|
||||||
|
|
||||||
|
func testMultiProtocolSynchronisation(t *testing.T, protocol int) {
|
||||||
|
// Create a small enough block chain to download
|
||||||
|
targetBlocks := blockCacheLimit - 15
|
||||||
|
hashes, blocks := makeChain(targetBlocks, 0, genesis)
|
||||||
|
|
||||||
|
// Create peers of every type
|
||||||
|
tester := newTester()
|
||||||
|
tester.newPeer("peer 61", 61, hashes, blocks)
|
||||||
|
tester.newPeer("peer 62", 62, hashes, blocks)
|
||||||
|
tester.newPeer("peer 63", 63, hashes, blocks)
|
||||||
|
tester.newPeer("peer 64", 64, hashes, blocks)
|
||||||
|
|
||||||
|
// Synchronise with the requestd peer and make sure all blocks were retrieved
|
||||||
|
if err := tester.sync(fmt.Sprintf("peer %d", protocol), nil); err != nil {
|
||||||
|
t.Fatalf("failed to synchronise blocks: %v", err)
|
||||||
|
}
|
||||||
|
if imported := len(tester.ownBlocks); imported != targetBlocks+1 {
|
||||||
|
t.Fatalf("synchronised block mismatch: have %v, want %v", imported, targetBlocks+1)
|
||||||
|
}
|
||||||
|
// Check that no peers have been dropped off
|
||||||
|
for _, version := range []int{61, 62, 63, 64} {
|
||||||
|
peer := fmt.Sprintf("peer %d", version)
|
||||||
|
if _, ok := tester.peerHashes[peer]; !ok {
|
||||||
|
t.Errorf("%s dropped", peer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tests that if a block is empty (i.e. header only), no body request should be
|
// Tests that if a block is empty (i.e. header only), no body request should be
|
||||||
// made, and instead the header should be assembled into a whole block in itself.
|
// made, and instead the header should be assembled into a whole block in itself.
|
||||||
func TestEmptyBlockShortCircuit62(t *testing.T) { testEmptyBlockShortCircuit(t, 62) }
|
func TestEmptyBlockShortCircuit62(t *testing.T) { testEmptyBlockShortCircuit(t, 62) }
|
||||||
|
@ -312,14 +312,16 @@ func (ps *peerSet) AllPeers() []*peer {
|
|||||||
|
|
||||||
// IdlePeers retrieves a flat list of all the currently idle peers within the
|
// IdlePeers retrieves a flat list of all the currently idle peers within the
|
||||||
// active peer set, ordered by their reputation.
|
// active peer set, ordered by their reputation.
|
||||||
func (ps *peerSet) IdlePeers() []*peer {
|
func (ps *peerSet) IdlePeers(version int) []*peer {
|
||||||
ps.lock.RLock()
|
ps.lock.RLock()
|
||||||
defer ps.lock.RUnlock()
|
defer ps.lock.RUnlock()
|
||||||
|
|
||||||
list := make([]*peer, 0, len(ps.peers))
|
list := make([]*peer, 0, len(ps.peers))
|
||||||
for _, p := range ps.peers {
|
for _, p := range ps.peers {
|
||||||
if atomic.LoadInt32(&p.idle) == 0 {
|
if (version == eth61 && p.version == eth61) || (version >= eth62 && p.version >= eth62) {
|
||||||
list = append(list, p)
|
if atomic.LoadInt32(&p.idle) == 0 {
|
||||||
|
list = append(list, p)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := 0; i < len(list); i++ {
|
for i := 0; i < len(list); i++ {
|
||||||
|
@ -131,8 +131,8 @@ type Env struct {
|
|||||||
initial bool
|
initial bool
|
||||||
Gas *big.Int
|
Gas *big.Int
|
||||||
|
|
||||||
origin common.Address
|
origin common.Address
|
||||||
//parent common.Hash
|
parent common.Hash
|
||||||
coinbase common.Address
|
coinbase common.Address
|
||||||
|
|
||||||
number *big.Int
|
number *big.Int
|
||||||
@ -163,7 +163,7 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues
|
|||||||
env := NewEnv(state)
|
env := NewEnv(state)
|
||||||
|
|
||||||
env.origin = common.HexToAddress(exeValues["caller"])
|
env.origin = common.HexToAddress(exeValues["caller"])
|
||||||
//env.parent = common.Hex2Bytes(envValues["previousHash"])
|
env.parent = common.HexToHash(envValues["previousHash"])
|
||||||
env.coinbase = common.HexToAddress(envValues["currentCoinbase"])
|
env.coinbase = common.HexToAddress(envValues["currentCoinbase"])
|
||||||
env.number = common.Big(envValues["currentNumber"])
|
env.number = common.Big(envValues["currentNumber"])
|
||||||
env.time = common.Big(envValues["currentTimestamp"])
|
env.time = common.Big(envValues["currentTimestamp"])
|
||||||
@ -174,10 +174,8 @@ func NewEnvFromMap(state *state.StateDB, envValues map[string]string, exeValues
|
|||||||
return env
|
return env
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Env) Origin() common.Address { return self.origin }
|
func (self *Env) Origin() common.Address { return self.origin }
|
||||||
func (self *Env) BlockNumber() *big.Int { return self.number }
|
func (self *Env) BlockNumber() *big.Int { return self.number }
|
||||||
|
|
||||||
//func (self *Env) PrevHash() []byte { return self.parent }
|
|
||||||
func (self *Env) Coinbase() common.Address { return self.coinbase }
|
func (self *Env) Coinbase() common.Address { return self.coinbase }
|
||||||
func (self *Env) Time() *big.Int { return self.time }
|
func (self *Env) Time() *big.Int { return self.time }
|
||||||
func (self *Env) Difficulty() *big.Int { return self.difficulty }
|
func (self *Env) Difficulty() *big.Int { return self.difficulty }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user