From b39a0f7a9549105c2df9dc096a1b8407f2f021d5 Mon Sep 17 00:00:00 2001 From: yperbasis Date: Thu, 16 Jan 2025 17:36:57 +0100 Subject: [PATCH] Deduce SecondsPerSlot --- consensus/misc/eip1559.go | 2 +- erigon-lib/chain/chain_config.go | 12 ++++++++++-- eth/gasprice/feehistory.go | 2 +- params/chainspecs/amoy.json | 1 - params/chainspecs/bor-devnet.json | 1 - params/chainspecs/bor-mainnet.json | 1 - params/chainspecs/chiado.json | 1 - params/chainspecs/gnosis.json | 1 - params/chainspecs/holesky.json | 3 +-- params/chainspecs/mainnet.json | 1 - params/chainspecs/sepolia.json | 1 - turbo/jsonrpc/eth_block.go | 4 +--- turbo/jsonrpc/eth_system.go | 2 +- turbo/stages/stageloop.go | 2 +- 14 files changed, 16 insertions(+), 18 deletions(-) diff --git a/consensus/misc/eip1559.go b/consensus/misc/eip1559.go index a06374666c3..7f5788f8a70 100644 --- a/consensus/misc/eip1559.go +++ b/consensus/misc/eip1559.go @@ -87,7 +87,7 @@ func (f eip1559Calculator) CurrentFees(chainConfig *chain.Config, db kv.Getter) } if currentHeader.ExcessBlobGas != nil { - nextBlockTime := currentHeader.Time + chainConfig.SecondsPerSlot + nextBlockTime := currentHeader.Time + chainConfig.SecondsPerSlot() excessBlobGas := CalcExcessBlobGas(chainConfig, currentHeader, nextBlockTime) b, err := GetBlobGasPrice(chainConfig, excessBlobGas, nextBlockTime) if err != nil { diff --git a/erigon-lib/chain/chain_config.go b/erigon-lib/chain/chain_config.go index 3ed0bf4873a..206f71adee4 100644 --- a/erigon-lib/chain/chain_config.go +++ b/erigon-lib/chain/chain_config.go @@ -90,8 +90,6 @@ type Config struct { // See also EIP-6110: Supply validator deposits on chain DepositContract common.Address `json:"depositContractAddress,omitempty"` - SecondsPerSlot uint64 `json:"secondsPerSlot"` - // Various consensus engines Ethash *EthashConfig `json:"ethash,omitempty"` Clique *CliqueConfig `json:"clique,omitempty"` @@ -318,6 +316,16 @@ func (c *Config) GetMaxBlobsPerBlock(time uint64) uint64 { return c.GetMaxBlobGasPerBlock(time) / fixedgas.BlobGasPerBlob } +func (c *Config) SecondsPerSlot() uint64 { + if c.Bor != nil { + return 2 // Polygon + } + if c.Aura != nil { + return 5 // Gnosis + } + return 12 // Ethereum +} + // CheckCompatible checks whether scheduled fork transitions have been imported // with a mismatching chain configuration. func (c *Config) CheckCompatible(newcfg *Config, height uint64) *ConfigCompatError { diff --git a/eth/gasprice/feehistory.go b/eth/gasprice/feehistory.go index ef44d91f5a0..16f10cf1ee2 100644 --- a/eth/gasprice/feehistory.go +++ b/eth/gasprice/feehistory.go @@ -102,7 +102,7 @@ func (oracle *Oracle) processBlock(bf *blockFees, percentiles []float64) { bf.err = err return } - nextBlockTime := bf.header.Time + chainconfig.SecondsPerSlot + nextBlockTime := bf.header.Time + chainconfig.SecondsPerSlot() nextBlobBaseFee256, err := misc.GetBlobGasPrice(chainconfig, misc.CalcExcessBlobGas(chainconfig, bf.header, nextBlockTime), nextBlockTime) if err != nil { bf.err = err diff --git a/params/chainspecs/amoy.json b/params/chainspecs/amoy.json index a6b0d442f6e..7c15a7cf276 100644 --- a/params/chainspecs/amoy.json +++ b/params/chainspecs/amoy.json @@ -16,7 +16,6 @@ "0": "0x000000000000000000000000000000000000dead", "73100": "0xeCDD77cE6f146cCf5dab707941d318Bd50eeD2C9" }, - "secondsPerSlot": 2, "bor": { "period": { "0": 2 diff --git a/params/chainspecs/bor-devnet.json b/params/chainspecs/bor-devnet.json index 4671609d6e1..3cbdb93a2a0 100644 --- a/params/chainspecs/bor-devnet.json +++ b/params/chainspecs/bor-devnet.json @@ -16,7 +16,6 @@ "22640000": "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38", "41874000": "0x617b94CCCC2511808A3C9478ebb96f455CF167aA" }, - "secondsPerSlot": 2, "bor": { "period": { "0": 2 diff --git a/params/chainspecs/bor-mainnet.json b/params/chainspecs/bor-mainnet.json index 5b67f9c3d8e..792895c4e89 100644 --- a/params/chainspecs/bor-mainnet.json +++ b/params/chainspecs/bor-mainnet.json @@ -16,7 +16,6 @@ "23850000": "0x70bca57f4579f58670ab2d18ef16e02c17553c38", "50523000": "0x7A8ed27F4C30512326878652d20fC85727401854" }, - "secondsPerSlot": 2, "bor": { "period": { "0": 2 diff --git a/params/chainspecs/chiado.json b/params/chainspecs/chiado.json index 01589ee6d40..9d251f72575 100644 --- a/params/chainspecs/chiado.json +++ b/params/chainspecs/chiado.json @@ -23,7 +23,6 @@ "0": "0x1559000000000000000000000000000000000000" }, "depositContractAddress": "0xb97036A26259B7147018913bD58a774cf91acf25", - "secondsPerSlot": 5, "aura": { "stepDuration": 5, "blockReward": 0, diff --git a/params/chainspecs/gnosis.json b/params/chainspecs/gnosis.json index ba9fe92b6a8..f7deadd85b7 100644 --- a/params/chainspecs/gnosis.json +++ b/params/chainspecs/gnosis.json @@ -23,7 +23,6 @@ "19040000": "0x6BBe78ee9e474842Dbd4AB4987b3CeFE88426A92" }, "depositContractAddress": "0x0B98057eA310F4d31F2a452B414647007d1645d9", - "secondsPerSlot": 5, "aura": { "stepDuration": 5, "blockReward": 0, diff --git a/params/chainspecs/holesky.json b/params/chainspecs/holesky.json index 6424e255665..525d4c80e84 100644 --- a/params/chainspecs/holesky.json +++ b/params/chainspecs/holesky.json @@ -16,6 +16,5 @@ "terminalTotalDifficultyPassed": true, "shanghaiTime": 1696000704, "cancunTime": 1707305664, - "depositContractAddress": "0x4242424242424242424242424242424242424242", - "secondsPerSlot": 12 + "depositContractAddress": "0x4242424242424242424242424242424242424242" } diff --git a/params/chainspecs/mainnet.json b/params/chainspecs/mainnet.json index bda7306342a..349c5c8e2a4 100644 --- a/params/chainspecs/mainnet.json +++ b/params/chainspecs/mainnet.json @@ -20,6 +20,5 @@ "shanghaiTime": 1681338455, "cancunTime": 1710338135, "depositContractAddress": "0x00000000219ab540356cBB839Cbe05303d7705Fa", - "secondsPerSlot": 12, "ethash": {} } diff --git a/params/chainspecs/sepolia.json b/params/chainspecs/sepolia.json index 3add649bafa..c584f3c05b7 100644 --- a/params/chainspecs/sepolia.json +++ b/params/chainspecs/sepolia.json @@ -18,6 +18,5 @@ "shanghaiTime": 1677557088, "cancunTime": 1706655072, "depositContractAddress": "0x7f02C3E3c98b133055B8B348B2Ac625669Ed295D", - "secondsPerSlot": 12, "ethash": {} } diff --git a/turbo/jsonrpc/eth_block.go b/turbo/jsonrpc/eth_block.go index 46952cd7dc4..67fb105343d 100644 --- a/turbo/jsonrpc/eth_block.go +++ b/turbo/jsonrpc/eth_block.go @@ -30,9 +30,7 @@ import ( "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon-lib/kv/rawdbv3" "github.com/erigontech/erigon-lib/log/v3" - "github.com/erigontech/erigon-lib/rlp" - "github.com/erigontech/erigon/cl/clparams" "github.com/erigontech/erigon/core" "github.com/erigontech/erigon/core/rawdb" "github.com/erigontech/erigon/core/state" @@ -122,7 +120,7 @@ func (api *APIImpl) CallBundle(ctx context.Context, txHashes []common.Hash, stat blockNumber := stateBlockNumber + 1 - timestamp := parent.Time + clparams.MainnetBeaconConfig.SecondsPerSlot + timestamp := parent.Time + chainConfig.SecondsPerSlot() coinbase := parent.Coinbase header := &types.Header{ diff --git a/turbo/jsonrpc/eth_system.go b/turbo/jsonrpc/eth_system.go index f5cedcbfefc..6bca6d17414 100644 --- a/turbo/jsonrpc/eth_system.go +++ b/turbo/jsonrpc/eth_system.go @@ -215,7 +215,7 @@ func (api *APIImpl) BlobBaseFee(ctx context.Context) (*hexutil.Big, error) { if config == nil { return (*hexutil.Big)(common.Big0), nil } - nextBlockTime := header.Time + config.SecondsPerSlot + nextBlockTime := header.Time + config.SecondsPerSlot() ret256, err := misc.GetBlobGasPrice(config, misc.CalcExcessBlobGas(config, header, nextBlockTime), nextBlockTime) if err != nil { return nil, err diff --git a/turbo/stages/stageloop.go b/turbo/stages/stageloop.go index 661b9dca502..79934ad14f9 100644 --- a/turbo/stages/stageloop.go +++ b/turbo/stages/stageloop.go @@ -483,7 +483,7 @@ func (h *Hook) sendNotifications(tx kv.Tx, finishStageBeforeSync uint64) error { pendingBaseFee := misc.CalcBaseFee(h.chainConfig, currentHeader) pendingBlobFee := h.chainConfig.GetMinBlobGasPrice() if currentHeader.ExcessBlobGas != nil { - nextBlockTime := currentHeader.Time + h.chainConfig.SecondsPerSlot + nextBlockTime := currentHeader.Time + h.chainConfig.SecondsPerSlot() excessBlobGas := misc.CalcExcessBlobGas(h.chainConfig, currentHeader, nextBlockTime) f, err := misc.GetBlobGasPrice(h.chainConfig, excessBlobGas, nextBlockTime) if err != nil {