Skip to content

Commit

Permalink
Merge pull request expanse-org#23 from happyuc-project/debug/v0.0.2
Browse files Browse the repository at this point in the history
Debug/v0.0.2
  • Loading branch information
ldcc committed May 22, 2018
2 parents 5d4434d + 71790b7 commit e60c02b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions consensus/huchash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func calcDifficultyHomestead(time uint64, parent *types.Header) *big.Int {
// https://github.com/happyuc-project/HIPs/blob/master/EIPS/eip-2.md
// algorithm:
// diff = (parent_diff +
// (parent_diff / 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99))
// (parent_diff / 2048 * max(1 - (block_timestamp - parent_timestamp) / 10, -99))
// ) + 2^(periodCount - 2)

bigTime := new(big.Int).SetUint64(time)
Expand All @@ -396,16 +396,16 @@ func calcDifficultyHomestead(time uint64, parent *types.Header) *big.Int {
x := new(big.Int)
y := new(big.Int)

// 1 - (block_timestamp - parent_timestamp) // 10
// 1 - (block_timestamp - parent_timestamp) / 10
x.Sub(bigTime, bigParentTime)
x.Div(x, big10)
x.Sub(big1, x)

// max(1 - (block_timestamp - parent_timestamp) // 10, -99)
// max(1 - (block_timestamp - parent_timestamp) / 10, -99)
if x.Cmp(bigMinus99) < 0 {
x.Set(bigMinus99)
}
// (parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99))
// (parent_diff + parent_diff / 2048 * max(1 - (block_timestamp - parent_timestamp) / 10, -99))
y.Div(parent.Difficulty, params.DifficultyBoundDivisor)
x.Mul(y, x)
x.Add(parent.Difficulty, x)
Expand Down
2 changes: 1 addition & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func DefaultGenesisBlock() *Genesis {
return &Genesis{
Config: params.MainnetChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa"),
ExtraData: hexutil.MustDecode("0x6861707079536f667477617265"),
GasLimit: 4700000,
Difficulty: big.NewInt(1048576),
Alloc: decodePrealloc(mainnetAllocData),
Expand Down
2 changes: 1 addition & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ func (pool *TxPool) Content() (map[common.Address]types.Transactions, map[common
func (pool *TxPool) Pending() (map[common.Address]types.Transactions, error) {
pool.mu.Lock()
defer pool.mu.Unlock()

pending := make(map[common.Address]types.Transactions)
for addr, list := range pool.pending {
pending[addr] = list.Flatten()
Expand Down Expand Up @@ -620,6 +619,7 @@ func (pool *TxPool) journalTx(from common.Address, tx *types.Transaction) {
// whitelisted, preventing any associated transaction from being dropped out of
// the pool due to pricing constraints.
func (pool *TxPool) add(tx *types.Transaction, local bool) (bool, error) {
fmt.Println("add tx:", tx)
// If the transaction is already known, discard it
hash := tx.Hash()
if pool.all[hash] != nil {
Expand Down
7 changes: 3 additions & 4 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ func (self *worker) makeCurrent(parent *types.Block, header *types.Header) error

// push sends a new work task to currently live miner agents.
func (self *worker) push(work *Work) {

for agent := range self.agents {
atomic.AddInt32(&self.atWork, 1)
if ch := agent.Work(); ch != nil {
Expand Down Expand Up @@ -553,7 +552,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
// Check whether the tx is replay protected. If we're not in the EIP155 hf
// phase, start ignoring the sender until we do.
if tx.Protected() && !env.config.IsEIP155(env.header.Number) {
log.Crit("Ignoring reply protected transaction", "hash", tx.Hash(), "eip155", env.config.EIP155Block)
log.Trace("Ignoring reply protected transaction", "hash", tx.Hash(), "eip155", env.config.EIP155Block)

txs.Pop()
continue
Expand Down Expand Up @@ -583,8 +582,8 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
default:
// Strange error, discard the transaction and get the next in line (note, the
// nonce-too-high clause will prevent us from executing in vain).
log.Warn("Transaction failed, account skipped", "hash", tx.Hash(), "err", err)
txs.Pop()
log.Debug("Transaction failed, account skipped", "hash", tx.Hash(), "err", err)
txs.Shift()
}
}

Expand Down
10 changes: 5 additions & 5 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ import (
)

var (
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on
MainnetGenesisHash = common.HexToHash("0x5edb680bd141442fff52006a8db1526a32e0f72f57ef5f285f3e032af5bdacb5") // Mainnet genesis hash to enforce below configs on
TestnetGenesisHash = common.HexToHash("0x389d168191585e7a14b01a654c02058053abf3ca3d167efb69a51dec86d9cfbc") // Testnet genesis hash to enforce below configs on
)

var (
// MainnetChainConfig is the chain parameters to run a node on the main network.
MainnetChainConfig = &ChainConfig{
ChainId: big.NewInt(1),
HomesteadBlock: big.NewInt(1150000),
DAOForkBlock: big.NewInt(1920000),
DAOForkSupport: true,
HomesteadBlock: nil,
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: nil,
EIP150Hash: common.Hash{},
EIP155Block: nil,
Expand Down

0 comments on commit e60c02b

Please sign in to comment.