-
Notifications
You must be signed in to change notification settings - Fork 561
fix(rpc): align nextBaseFee and invalid check for fee history #1720
Conversation
fceb6ac
to
7d2b87b
Compare
go func(index int32) { | ||
defer wg.Done() | ||
// fetch block | ||
// tendermint block | ||
blockNum := rpctypes.BlockNumber(blockStart + int64(index)) | ||
tendermintblock, err := b.TendermintBlockByNumber(blockNum) | ||
if tendermintblock == nil { | ||
chanErr <- err | ||
return | ||
} | ||
|
||
// fetch block | ||
for blockID := blockStart; blockID <= blockEnd; blockID++ { | ||
index := int32(blockID - blockStart) | ||
// tendermint block | ||
tendermintblock, err := b.TendermintBlockByNumber(rpctypes.BlockNumber(blockID)) | ||
if tendermintblock == nil { | ||
return nil, err | ||
} | ||
|
||
// eth block | ||
ethBlock, err := b.GetBlockByNumber(rpctypes.BlockNumber(blockID), true) | ||
if ethBlock == nil { | ||
return nil, err | ||
} | ||
// eth block | ||
ethBlock, err := b.GetBlockByNumber(blockNum, true) | ||
if ethBlock == nil { | ||
chanErr <- err | ||
return | ||
} | ||
|
||
// tendermint block result | ||
tendermintBlockResult, err := b.TendermintBlockResultByNumber(&tendermintblock.Block.Height) | ||
if tendermintBlockResult == nil { | ||
b.logger.Debug("block result not found", "height", tendermintblock.Block.Height, "error", err.Error()) | ||
return nil, err | ||
} | ||
// tendermint block result | ||
tendermintBlockResult, err := b.TendermintBlockResultByNumber(&tendermintblock.Block.Height) | ||
if tendermintBlockResult == nil { | ||
b.logger.Debug("block result not found", "height", tendermintblock.Block.Height, "error", err.Error()) | ||
chanErr <- err | ||
return | ||
} | ||
|
||
oneFeeHistory := rpctypes.OneFeeHistory{} | ||
err = b.processBlock(tendermintblock, ðBlock, rewardPercentiles, tendermintBlockResult, &oneFeeHistory) | ||
if err != nil { | ||
return nil, err | ||
} | ||
oneFeeHistory := rpctypes.OneFeeHistory{} | ||
err = b.processBlock(tendermintblock, ðBlock, rewardPercentiles, tendermintBlockResult, &oneFeeHistory) | ||
if err != nil { | ||
chanErr <- err | ||
return | ||
} | ||
|
||
// copy | ||
thisBaseFee[index] = (*hexutil.Big)(oneFeeHistory.BaseFee) | ||
thisBaseFee[index+1] = (*hexutil.Big)(oneFeeHistory.NextBaseFee) | ||
thisGasUsedRatio[index] = oneFeeHistory.GasUsedRatio | ||
if calculateRewards { | ||
for j := 0; j < rewardCount; j++ { | ||
reward[index][j] = (*hexutil.Big)(oneFeeHistory.Reward[j]) | ||
if reward[index][j] == nil { | ||
reward[index][j] = (*hexutil.Big)(big.NewInt(0)) | ||
// copy | ||
thisBaseFee[index] = (*hexutil.Big)(oneFeeHistory.BaseFee) | ||
thisBaseFee[index+1] = (*hexutil.Big)(oneFeeHistory.NextBaseFee) | ||
thisGasUsedRatio[index] = oneFeeHistory.GasUsedRatio | ||
if calculateRewards { | ||
for j := 0; j < rewardCount; j++ { | ||
reward[index][j] = (*hexutil.Big)(oneFeeHistory.Reward[j]) | ||
if reward[index][j] == nil { | ||
reward[index][j] = (*hexutil.Big)(big.NewInt(0)) | ||
} | ||
} | ||
} | ||
} | ||
}(int32(blockID - blockStart + int64(i))) |
Check notice
Code scanning / CodeQL
Spawning a Go routine
go func() { | ||
wg.Wait() | ||
close(wgDone) | ||
}() |
Check notice
Code scanning / CodeQL
Spawning a Go routine
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1720 +/- ##
==========================================
- Coverage 68.89% 67.92% -0.98%
==========================================
Files 117 112 -5
Lines 10681 10280 -401
==========================================
- Hits 7359 6983 -376
+ Misses 2900 2884 -16
+ Partials 422 413 -9
|
* fix blk number for next base fee * add test * add change doc * cross check next fee * calc base fee based on params elasticity_multiplier & base_fee_change_denominator * concurrent call with maxBlockFetchers * test with get feemarket params * Update CHANGELOG.md --------- Signed-off-by: yihuang <huang@crypto.com> Co-authored-by: yihuang <huang@crypto.com>
elasticity_multiplier & base_fee_change_denominator
blockEnd = int64(blockNumber) | ||
} else if int64(blockNumber) < blockEnd { | ||
return nil, fmt.Errorf("%w: requested %d, head %d", errRequestBeyondHead, blockEnd, int64(blockNumber)) |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
blockEnd = int64(blockNumber) | ||
} else if int64(blockNumber) < blockEnd { |
Check failure
Code scanning / gosec
Potential integer overflow by integer type conversion
… (#241) * align request beyond head block * align invalid reward percentile
* fix blk number for next base fee * add test * add change doc * cross check next fee * calc base fee based on params elasticity_multiplier & base_fee_change_denominator * concurrent call with maxBlockFetchers * test with get feemarket params * Update CHANGELOG.md --------- Signed-off-by: yihuang <huang@crypto.com> Co-authored-by: yihuang <huang@crypto.com>
… (#241) * align request beyond head block * align invalid reward percentile
* fix(rpc): nextBaseFee for fee history (backport: evmos#1720) (#234) * fix blk number for next base fee * add test * add change doc * cross check next fee * calc base fee based on params elasticity_multiplier & base_fee_change_denominator * concurrent call with maxBlockFetchers * test with get feemarket params * Update CHANGELOG.md --------- Signed-off-by: yihuang <huang@crypto.com> Co-authored-by: yihuang <huang@crypto.com> * fix(rpc): add more invalid check for fee history (backport: evmos#1720) (#241) * align request beyond head block * align invalid reward percentile --------- Signed-off-by: yihuang <huang@crypto.com> Co-authored-by: yihuang <huang@crypto.com>
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs. |
For contributor use:
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerFor admin use:
WIP
,R4R
,docs
, etc)