Skip to content

Commit 8a67545

Browse files
committed
fix bugs
1 parent bad59bd commit 8a67545

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

action/receipt.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ func (receipt *Receipt) TransferLogs(accountContractAddr string, logIndex uint32
219219
return logs, nil
220220
}
221221

222-
func (receipt *Receipt) FixAndClone() *Receipt {
222+
func (receipt *Receipt) CloneFixed() *Receipt {
223223
var cls []*Log
224224
if receipt.logs != nil {
225225
cls = make([]*Log, len(receipt.logs))
@@ -253,16 +253,24 @@ func (receipt *Receipt) FixAndClone() *Receipt {
253253
}
254254
}
255255
}
256+
var blobGasPrice *big.Int
257+
if receipt.BlobGasPrice != nil {
258+
blobGasPrice = new(big.Int).Set(receipt.BlobGasPrice)
259+
}
260+
var effectiveGasPrice *big.Int
261+
if receipt.EffectiveGasPrice != nil {
262+
effectiveGasPrice = new(big.Int).Set(receipt.EffectiveGasPrice)
263+
}
256264
return &Receipt{
257265
Status: receipt.Status,
258266
BlockHeight: receipt.BlockHeight,
259267
ActionHash: receipt.ActionHash,
260268
GasConsumed: receipt.GasConsumed,
261269
BlobGasUsed: receipt.BlobGasUsed,
262-
BlobGasPrice: new(big.Int).Set(receipt.BlobGasPrice),
270+
BlobGasPrice: blobGasPrice,
263271
ContractAddress: receipt.ContractAddress,
264272
TxIndex: receipt.TxIndex,
265-
EffectiveGasPrice: new(big.Int).Set(receipt.EffectiveGasPrice),
273+
EffectiveGasPrice: effectiveGasPrice,
266274
logs: cls,
267275
transactionLogs: ctls,
268276
executionRevertMsg: receipt.executionRevertMsg,

blockchain/blockdao/blockdao.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func (dao *blockDAO) GetReceipts(height uint64) ([]*action.Receipt, error) {
323323
receipts, err = dao.receiptIndexer.Receipts(height)
324324
switch errors.Cause(err) {
325325
case nil:
326-
case ErrIndexOutOfRange:
326+
case ErrIndexOutOfRange, db.ErrNotExist, db.ErrBucketNotExist:
327327
receipts = nil
328328
default:
329329
return nil, err

blockchain/blockdao/receiptindexer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (ri *ReceiptIndexer) Start(ctx context.Context) error {
5858
value, err := ri.kvstore.Get(_receiptMetaNS, _heightKey)
5959
switch errors.Cause(err) {
6060
case nil:
61-
case db.ErrNotExist:
61+
case db.ErrNotExist, db.ErrBucketNotExist:
6262
return nil
6363
default:
6464
return err
@@ -97,7 +97,7 @@ func (ri *ReceiptIndexer) PutBlock(ctx context.Context, blk *block.Block) error
9797
logIndex := uint32(0)
9898
receipts := iotextypes.Receipts{}
9999
for i, receipt := range blk.Receipts {
100-
cr := receipt.FixAndClone()
100+
cr := receipt.CloneFixed()
101101
logIndex = cr.UpdateIndex(uint32(i), logIndex)
102102
receipts.Receipts = append(receipts.Receipts, cr.ConvertToReceiptPb())
103103
}

systemcontractindex/stakingindex/index.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ func (s *Indexer) LoadStakeView(ctx context.Context, sr protocol.StateReader) (s
134134
if !s.common.Started() {
135135
return nil, errors.New("indexer not started")
136136
}
137+
tip, err := sr.Height()
138+
if err != nil {
139+
return nil, errors.Wrap(err, "failed to get tip height from state reader")
140+
}
141+
ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{
142+
BlockHeight: tip + 1,
143+
}))
137144
if protocol.MustGetFeatureCtx(ctx).StoreVoteOfNFTBucketIntoView {
138145
return &stakeView{
139146
cache: s.cache.Clone(),

0 commit comments

Comments
 (0)