Skip to content

Commit

Permalink
Potuz's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Dec 10, 2024
1 parent c178784 commit 77abdfd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
24 changes: 14 additions & 10 deletions beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,21 @@ func setExecution(blk interfaces.SignedBeaconBlock, execution interfaces.Executi
// else:
// gas_diff = parent_gas_limit - target_gas_limit
// return parent_gas_limit - min(gas_diff, max_gas_limit_difference)
func expectedGasLimit(parentGasLimit, targetGasLimit uint64) uint64 {
maxGasLimitDiff := parentGasLimit/gasLimitAdjustmentFactor - 1
if targetGasLimit > parentGasLimit {
if targetGasLimit-parentGasLimit > maxGasLimitDiff {
func expectedGasLimit(parentGasLimit, proposerGasLimit uint64) uint64 {
maxGasLimitDiff := uint64(0)
if parentGasLimit > gasLimitAdjustmentFactor {
maxGasLimitDiff = parentGasLimit/gasLimitAdjustmentFactor - 1
}
if proposerGasLimit > parentGasLimit {
if proposerGasLimit-parentGasLimit > maxGasLimitDiff {
return parentGasLimit + maxGasLimitDiff
}
return targetGasLimit
} else {
if parentGasLimit-targetGasLimit > maxGasLimitDiff {
return parentGasLimit - maxGasLimitDiff
}
return targetGasLimit
return proposerGasLimit
}

if parentGasLimit-proposerGasLimit > maxGasLimitDiff {
return parentGasLimit - maxGasLimitDiff
}
return proposerGasLimit

}

Check failure on line 440 in beacon-chain/rpc/prysm/v1alpha1/validator/proposer_bellatrix.go

View workflow job for this annotation

GitHub Actions / Lint

unnecessary trailing newline (whitespace)
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,14 @@ func Test_expectedGasLimit(t *testing.T) {
},
want: 19980470, // maxGasLimitDiff = (20000000 / 1024) - 1
},
{
name: "Parent gas limit under flows",
args: args{
parentGasLimit: 1023,
targetGasLimit: 30000000,
},
want: 1023,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 77abdfd

Please sign in to comment.