Skip to content

Commit

Permalink
Check that blocks without ceremonial txs go in a row (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbidenaio authored Apr 19, 2021
1 parent efa81ed commit ad930b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 6 additions & 4 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func NewBlockchain(config *config.Config, db dbm.DB, txpool *mempool.TxPool, app
indexer: newBlockchainIndexer(db, bus, config, keyStore),
subManager: subManager,
upgrader: upgrader,
ipfsLoadQueue: make(chan *attachments.StoreToIpfsAttachment, 100),
ipfsLoadQueue: make(chan *attachments.StoreToIpfsAttachment, 100),
}
}

Expand Down Expand Up @@ -783,6 +783,8 @@ func (chain *Blockchain) applyGlobalParams(appState *appstate.AppState, block *t
}
if !has {
appState.State.IncBlocksCntWithoutCeremonialTxs()
} else if chain.config.Consensus.ResetBlocksWithoutCeremonialTxs && appState.State.BlocksCntWithoutCeremonialTxs() > 0 {
appState.State.ResetBlocksCntWithoutCeremonialTxs()
}
}

Expand Down Expand Up @@ -1496,7 +1498,7 @@ func (chain *Blockchain) filterTxs(appState *appstate.AppState, txs []*types.Tra
if err := validation.ValidateTx(appState, tx, minFeePerGas, validation.InBlockTx); err != nil {
continue
}
if f, r, err := chain.ApplyTxOnState(appState, vm, tx, false,nil); err == nil {
if f, r, err := chain.ApplyTxOnState(appState, vm, tx, false, nil); err == nil {
gas := uint64(fee.CalculateGas(tx))
if r != nil {
receipts = append(receipts, r)
Expand Down Expand Up @@ -1635,7 +1637,7 @@ func (chain *Blockchain) validateBlock(checkState *appstate.AppState, block *typ
var err error
var receipts types.TxReceipts
var usedGas uint64
if totalFee, totalTips, receipts, usedGas, err = chain.processTxs(checkState, block, false,nil); err != nil {
if totalFee, totalTips, receipts, usedGas, err = chain.processTxs(checkState, block, false, nil); err != nil {
return err
}

Expand Down Expand Up @@ -2321,7 +2323,7 @@ func (chain *Blockchain) ipfsLoad() {
if err == nil {
c, _ := cid2.Cast(item.Cid)
chain.log.Debug("content loaded to local ipfs", "item", c.String())
} else{
} else {
chain.log.Debug("error while loading ipfs content", "err", err)
}
}
Expand Down
6 changes: 4 additions & 2 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ConsensusConf struct {
DisableSavedInviteRewards bool
FixPoolRewardEvents bool
EnableStoreToIpfsTx bool
ResetBlocksWithoutCeremonialTxs bool
}

type ConsensusVerson uint16
Expand Down Expand Up @@ -136,11 +137,12 @@ func ApplyConsensusVersion(ver ConsensusVerson, cfg *ConsensusConf) {
case ConsensusV5:
cfg.FixPoolRewardEvents = true
cfg.EnableStoreToIpfsTx = true
cfg.ResetBlocksWithoutCeremonialTxs = true
cfg.Version = ConsensusV5
cfg.MigrationTimeout = 0
cfg.GenerateGenesisAfterUpgrade = true
cfg.StartActivationDate = time.Date(2021, 04, 20, 8, 0, 0, 0, time.UTC).Unix()
cfg.EndActivationDate = time.Date(2021, 04, 27, 0, 0, 0, 0, time.UTC).Unix()
cfg.StartActivationDate = time.Date(2021, 04, 27, 8, 0, 0, 0, time.UTC).Unix()
cfg.EndActivationDate = time.Date(2021, 05, 4, 0, 0, 0, 0, time.UTC).Unix()
}
}

Expand Down

0 comments on commit ad930b8

Please sign in to comment.