Integrate with geth 1.5.3 (1.5.4-unstable). Fixes #67

This commit is contained in:
Victor Farazdagi 2016-11-26 12:43:31 +03:00
parent 4415ee65f6
commit 8855cad7be
8 changed files with 39 additions and 10 deletions

View File

@ -30,7 +30,7 @@ import (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 5 // Minor version component of the current release
VersionPatch = 3 // Patch version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionMeta = "unstable" // Version metadata to append to the version string
)

View File

@ -21,4 +21,5 @@ import "github.com/ethereum/go-ethereum/common"
// Set of manually tracked bad hashes (usually hard forks)
var BadHashes = map[common.Hash]bool{
common.HexToHash("05bef30ef572270f654746da22639a7a0c97dd97a7050b9e252391996aaeb689"): true,
common.HexToHash("7d05d08cbc596a2e5e4f13b80a743e53e09221b5323c3a61946b20873e58583f"): true,
}

View File

@ -38,9 +38,6 @@ type PendingLogsEvent struct {
// PendingStateEvent is posted pre mining and notifies of pending state changes.
type PendingStateEvent struct{}
// NewBlockEvent is posted when a block has been imported.
type NewBlockEvent struct{ Block *types.Block }
// NewMinedBlockEvent is posted when a block has been imported.
type NewMinedBlockEvent struct{ Block *types.Block }

View File

@ -67,10 +67,13 @@ type (
addLogChange struct {
txhash common.Hash
}
touchChange struct {
account *common.Address
prev bool
}
)
func (ch createObjectChange) undo(s *StateDB) {
s.GetStateObject(*ch.account).deleted = true
delete(s.stateObjects, *ch.account)
delete(s.stateObjectsDirty, *ch.account)
}
@ -87,6 +90,15 @@ func (ch suicideChange) undo(s *StateDB) {
}
}
var ripemd = common.HexToAddress("0000000000000000000000000000000000000003")
func (ch touchChange) undo(s *StateDB) {
if !ch.prev && *ch.account != ripemd {
delete(s.stateObjects, *ch.account)
delete(s.stateObjectsDirty, *ch.account)
}
}
func (ch balanceChange) undo(s *StateDB) {
s.GetStateObject(*ch.account).setBalance(ch.prev)
}

View File

@ -87,6 +87,7 @@ type StateObject struct {
// during the "update" phase of the state transition.
dirtyCode bool // true if the code was updated
suicided bool
touched bool
deleted bool
onDirty func(addr common.Address) // Callback method to mark a state object newly dirty
}
@ -139,6 +140,18 @@ func (self *StateObject) markSuicided() {
}
}
func (c *StateObject) touch() {
c.db.journal = append(c.db.journal, touchChange{
account: &c.address,
prev: c.touched,
})
if c.onDirty != nil {
c.onDirty(c.Address())
c.onDirty = nil
}
c.touched = true
}
func (c *StateObject) getTrie(db trie.Database) *trie.SecureTrie {
if c.trie == nil {
var err error
@ -231,7 +244,11 @@ func (self *StateObject) CommitTrie(db trie.Database, dbw trie.DatabaseWriter) e
func (c *StateObject) AddBalance(amount *big.Int) {
// EIP158: We must check emptiness for the objects such that the account
// clearing (0,0,0 objects) can take effect.
if amount.Cmp(common.Big0) == 0 && !c.empty() {
if amount.Cmp(common.Big0) == 0 {
if c.empty() {
c.touch()
}
return
}
c.SetBalance(new(big.Int).Add(c.Balance(), amount))

View File

@ -72,6 +72,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
}
// Iterate over and process the individual transactions
for i, tx := range block.Transactions() {
//fmt.Println("tx:", i)
statedb.StartRecord(tx.Hash(), block.Hash(), i)
receipt, logs, _, err := ApplyTransaction(p.config, p.bc, gp, statedb, header, tx, totalUsedGas, cfg)
if err != nil {

View File

@ -1142,7 +1142,7 @@ func (s *PublicTransactionPoolAPI) CompleteQueuedTransaction(ctx context.Context
}
signer := types.MakeSigner(s.b.ChainConfig(), s.b.CurrentBlock().Number())
signature, err := s.b.AccountManager().SignWithPassphrase(args.From, passphrase, signer.Hash(tx).Bytes())
signature, err := s.b.AccountManager().SignWithPassphrase(args.From, passphrase, tx.SigHash(signer).Bytes())
if err != nil {
return common.Hash{}, err
}

View File

@ -50,8 +50,6 @@ type Miner struct {
worker *worker
MinAcceptedGasPrice *big.Int
threads int
coinbase common.Address
mining int32
@ -107,12 +105,15 @@ out:
}
}
func (m *Miner) GasPrice() *big.Int {
return new(big.Int).Set(m.worker.gasPrice)
}
func (m *Miner) SetGasPrice(price *big.Int) {
// FIXME block tests set a nil gas price. Quick dirty fix
if price == nil {
return
}
m.worker.setGasPrice(price)
}