Skip to content

Commit

Permalink
fix fee history
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed Jul 29, 2022
1 parent 703fb5a commit 313c65a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions arbitrum/apibackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ func (a *APIBackend) FeeHistory(
}
basefees[block-oldestBlock] = header.BaseFee

if block > int(newestBlock) {
break
}

if header.Time > prevTimestamp {
timeSinceLastTimeChange = header.Time - prevTimestamp
currentTimestampGasUsed = 0
Expand All @@ -231,16 +235,17 @@ func (a *APIBackend) FeeHistory(

prevTimestamp = header.Time

// In vanilla geth, this RPC returns the gasUsed ratio so a client can infer how the basefee will change
// To emulate this, we translate the compute rate into something like that, centered at an analogous 0.5
// In vanilla geth, this RPC returns the gasUsed ratio so a client can know how the basefee will change
// To emulate this, we translate the compute rate into something similar, centered at an analogous 0.5
var fullnessAnalogue float64
if timeSinceLastTimeChange > 0 {
fullnessAnalogue = float64(currentTimestampGasUsed) / float64(speedLimit) / float64(timeSinceLastTimeChange) / 2.0
if fullnessAnalogue > 1.0 {
fullnessAnalogue = 1.0
}
} else {
// We haven't looked far enough back to know the last timestamp change, so treat this block as full.
// We haven't looked far enough back to know the last timestamp change,
// so treat this block as full.
fullnessAnalogue = 1.0
}
gasUsed[block-oldestBlock] = fullnessAnalogue
Expand Down

0 comments on commit 313c65a

Please sign in to comment.