Skip to content

Commit

Permalink
rm unused pre-1559 gas limit update calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec committed Jan 19, 2025
1 parent 5b74335 commit dadf757
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 60 deletions.
4 changes: 2 additions & 2 deletions fluffy/database/content_db.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Fluffy
# Copyright (c) 2021-2024 Status Research & Development GmbH
# Copyright (c) 2021-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
Expand Down Expand Up @@ -411,7 +411,7 @@ proc putAndPrune*(db: ContentDB, key: ContentId, value: openArray[byte]): PutRes
else:
# Note:
# An approach of a deleting a full fraction is chosen here, in an attempt
# to not continiously require radius updates, which could have a negative
# to not continuously require radius updates, which could have a negative
# impact on the network. However this should be further investigated, as
# doing a large fraction deletion could cause a temporary node performance
# degradation. The `contentDeletionFraction` might need further tuning or
Expand Down
4 changes: 2 additions & 2 deletions fluffy/network/beacon/beacon_db.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fluffy
# Copyright (c) 2022-2024 Status Research & Development GmbH
# Copyright (c) 2022-2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
Expand Down Expand Up @@ -534,7 +534,7 @@ proc createStoreHandler*(db: BeaconDb): DbStoreHandler =
return

# Lot of assumptions here:
# - that updates are continious i.e there is no period gaps
# - that updates are continuous i.e. there is no period gaps
# - that updates start from startPeriod of content key
var period = contentKey.lightClientUpdateKey.startPeriod
for update in updates.asSeq():
Expand Down
4 changes: 2 additions & 2 deletions fluffy/network/wire/portal_protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ proc getContentKeys(o: OfferRequest): ContentKeysList =

func getMaxOfferedContentKeys*(protocolIdLen: uint32, maxKeySize: uint32): int =
## Calculates how many ContentKeys will fit in one offer message which
## will be small enouch to fit into discv5 limit.
## This is neccesarry as contentKeysLimit (64) is sometimes to big, and even
## will be small enough to fit into discv5 limit.
## This is necessary as contentKeysLimit (64) is sometimes too big, and even
## half of this can be too much to fit into discv5 limits.

let maxTalkReqPayload = maxDiscv5PacketSize - getTalkReqOverhead(int(protocolIdLen))
Expand Down
3 changes: 1 addition & 2 deletions hive_integration/nodocker/consensus/consensus_sim.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2021-2024 Status Research & Development GmbH
# Copyright (c) 2021-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
Expand All @@ -9,7 +9,6 @@

import
std/[os, json, strutils, times],
stew/byteutils,
results,
chronicles,
../../../nimbus/core/chain,
Expand Down
52 changes: 4 additions & 48 deletions nimbus/core/pow/header.nim
Original file line number Diff line number Diff line change
@@ -1,57 +1,13 @@
# Nimbus
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

{.push raises: [].}

import
std/[strformat],
./difficulty

export Header

proc hasUncles*(header: Header): bool = header.ommersHash != EMPTY_UNCLE_HASH

proc `$`*(header: Header): string =
result = &"Header(timestamp: {header.timestamp} difficulty: {header.difficulty} blockNumber: {header.number} gasLimit: {header.gasLimit})"

# CalcGasLimit computes the gas limit of the next block after parent. It aims
# to keep the baseline gas above the provided floor, and increase it towards the
# ceil if the blocks are full. If the ceil is exceeded, it will always decrease
# the gas allowance.
func computeGasLimit*(parentGasUsed, parentGasLimit, gasFloor, gasCeil: GasInt): GasInt =
# contrib = (parentGasUsed * 3 / 2) / 1024
let contrib = (parentGasUsed + parentGasUsed div 2) div GAS_LIMIT_ADJUSTMENT_FACTOR

# decay = parentGasLimit / 1024 -1
let decay = parentGasLimit div GAS_LIMIT_ADJUSTMENT_FACTOR - 1

#[
strategy: gasLimit of block-to-mine is set based on parent's
gasUsed value. if parentGasUsed > parentGasLimit * (2/3) then we
increase it, otherwise lower it (or leave it unchanged if it's right
at that usage) the amount increased/decreased depends on how far away
from parentGasLimit * (2/3) parentGasUsed is.
]#

var limit = parentGasLimit - decay + contrib
if limit < GAS_LIMIT_MINIMUM:
limit = GAS_LIMIT_MINIMUM

# If we're outside our allowed gas range, we try to hone towards them
if limit < gasFloor:
limit = parentGasLimit + decay
if limit > gasFloor:
limit = gasFloor

elif limit > gasCeil:
limit = parentGasLimit - decay
if limit < gasCeil:
limit = gasCeil

return limit
from ./difficulty import GAS_LIMIT_ADJUSTMENT_FACTOR, GAS_LIMIT_MINIMUM, GasInt

# CalcGasLimit1559 calculates the next block gas limit under 1559 rules.
func calcGasLimit1559*(parentGasLimit, desiredLimit: GasInt): GasInt =
Expand All @@ -74,4 +30,4 @@ func calcGasLimit1559*(parentGasLimit, desiredLimit: GasInt): GasInt =
if limit < desiredLimit:
limit = desiredLimit

return limit
limit
8 changes: 4 additions & 4 deletions nimbus/core/validate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import
../transaction,
../utils/utils,
"."/[dao, eip4844, eip7702, eip7691, gaslimit, withdrawals],
./pow/[difficulty, header],
./pow/difficulty,
stew/objects,
results

Expand Down Expand Up @@ -168,7 +168,7 @@ proc validateUncles(com: CommonRef; header: Header;
# Public function, extracted from executor
# ------------------------------------------------------------------------------

proc validateLegacySignatureForm(tx: Transaction, fork: EVMFork): bool =
func validateLegacySignatureForm(tx: Transaction, fork: EVMFork): bool =
var
vMin = 27'u64
vMax = 28'u64
Expand All @@ -190,7 +190,7 @@ proc validateLegacySignatureForm(tx: Transaction, fork: EVMFork): bool =

isValid

proc validateEip2930SignatureForm(tx: Transaction): bool =
func validateEip2930SignatureForm(tx: Transaction): bool =
var isValid = tx.V == 0'u64 or tx.V == 1'u64
isValid = isValid and tx.S >= UInt256.one
isValid = isValid and tx.S < SECPK1_N
Expand All @@ -205,7 +205,7 @@ func gasCost*(tx: Transaction): UInt256 =
else:
tx.gasLimit.u256 * tx.gasPrice.u256

proc validateTxBasic*(
func validateTxBasic*(
com: CommonRef,
tx: Transaction; ## tx to validate
fork: EVMFork,
Expand Down

0 comments on commit dadf757

Please sign in to comment.