Skip to content

Commit

Permalink
fix distributeToSystem (#539)
Browse files Browse the repository at this point in the history
* fix distributeToSystem
  • Loading branch information
blxdyx authored Oct 21, 2024
1 parent 3b3ea57 commit 989e182
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,12 @@ func (p *Parlia) finalize(header *types.Header, ibs *state.IntraBlockState, txs
}
}
}
finish, err = p.distributeToSystem(header.Coinbase, ibs, header, &txs, &receipts, &systemTxs, &header.GasUsed, mining, systemTxCall, &curIndex, &txIndex)
if err != nil || finish {
//log.Error("distributeIncoming", "block hash", header.Hash(), "error", err, "systemTxs", len(systemTxs))
return nil, nil, nil, err
if !p.chainConfig.IsKepler(header.Number.Uint64(), header.Time) {
finish, err = p.distributeToSystem(header.Coinbase, ibs, header, &txs, &receipts, &systemTxs, &header.GasUsed, mining, systemTxCall, &curIndex, &txIndex)
if err != nil || finish {
//log.Error("distributeIncoming", "block hash", header.Hash(), "error", err, "systemTxs", len(systemTxs))
return nil, nil, nil, err
}
}

finish, err = p.distributeToValidator(header.Coinbase, ibs, header, &txs, &receipts, &systemTxs, &header.GasUsed, mining, systemTxCall, &curIndex, &txIndex)
Expand Down Expand Up @@ -1381,7 +1383,7 @@ func (p *Parlia) initContract(state *state.IntraBlockState, header *types.Header
return false, err
}
for _, c := range contracts {
p.logger.Info("Init contracts", "len(systemTxs)", len(*systemTxs), "len(txs)", len(*txs))
// p.logger.Info("Init contracts", "len(systemTxs)", len(*systemTxs), "len(txs)", len(*txs))
if *curIndex == *txIndex {
return p.applyTransaction(header.Coinbase, c, u256.Num0, data, state, header, txs, receipts, systemTxs, usedGas, mining, systemTxCall, curIndex)
}
Expand All @@ -1398,8 +1400,7 @@ func (p *Parlia) distributeToSystem(val libcommon.Address, ibs *state.IntraBlock
if balance.Cmp(u256.Num0) <= 0 {
return false, nil
}
doDistributeSysReward := !p.chainConfig.IsKepler(header.Number.Uint64(), header.Time) &&
ibs.GetBalance(systemcontracts.SystemRewardContract).Cmp(maxSystemBalance) < 0
doDistributeSysReward := ibs.GetBalance(systemcontracts.SystemRewardContract).Cmp(maxSystemBalance) < 0
if doDistributeSysReward {
rewards := new(uint256.Int)
rewards = rewards.Rsh(balance, systemRewardPercent)
Expand All @@ -1411,9 +1412,9 @@ func (p *Parlia) distributeToSystem(val libcommon.Address, ibs *state.IntraBlock
txs, receipts, systemTxs, usedGas, mining, systemTxCall, curIndex)
}
}
return false, nil
} else if *(*txs)[*curIndex].GetTo() == systemcontracts.SystemRewardContract {
*curIndex++
}
*curIndex++
return false, nil
}

Expand Down
2 changes: 1 addition & 1 deletion turbo/snapshotsync/freezeblocks/block_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ func (r *BlockReader) ReadBlobByNumber(ctx context.Context, tx kv.Getter, blockH
}
return r.bs.ReadBlobSidecars(ctx, blockHeight, blockHash)
}
log.Info("Read BlobSidecar from snapshots")
//log.Info("Read BlobSidecar from snapshots")
blobs, err := r.bscSn.ReadBlobSidecars(blockHeight)
if err != nil {
return nil, false, err
Expand Down

0 comments on commit 989e182

Please sign in to comment.