Skip to content

Commit

Permalink
Merge pull request #23 from SiaFoundation/fix-v1-v2-panic
Browse files Browse the repository at this point in the history
Fix manager panic
  • Loading branch information
ChrisSchinnerl committed Feb 19, 2024
2 parents 32abe2b + ca6ce92 commit 12c5ec4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions chain/db.go
Expand Up @@ -526,8 +526,12 @@ func (db *DBStore) BestIndex(height uint64) (index types.ChainIndex, ok bool) {

// SupplementTipTransaction implements Store.
func (db *DBStore) SupplementTipTransaction(txn types.Transaction) (ts consensus.V1TransactionSupplement) {
height := db.getHeight()
if height >= db.n.HardforkV2.RequireHeight {
return consensus.V1TransactionSupplement{}
}
// get tip state, for proof-trimming
index, _ := db.BestIndex(db.getHeight())
index, _ := db.BestIndex(height)
cs, _ := db.State(index.ID)
numLeaves := cs.Elements.NumLeaves

Expand Down Expand Up @@ -559,8 +563,13 @@ func (db *DBStore) SupplementTipTransaction(txn types.Transaction) (ts consensus

// SupplementTipBlock implements Store.
func (db *DBStore) SupplementTipBlock(b types.Block) (bs consensus.V1BlockSupplement) {
height := db.getHeight()
if height >= db.n.HardforkV2.RequireHeight {
return consensus.V1BlockSupplement{Transactions: make([]consensus.V1TransactionSupplement, len(b.Transactions))}
}

// get tip state, for proof-trimming
index, _ := db.BestIndex(db.getHeight())
index, _ := db.BestIndex(height)
cs, _ := db.State(index.ID)
numLeaves := cs.Elements.NumLeaves

Expand Down

0 comments on commit 12c5ec4

Please sign in to comment.