Skip to content

Commit d6ef6cc

Browse files
committed
all: prague4 fork (#24)
* all: prague4 fork * log fork ID on statrup * update fork timestamp to 1762963200 * fix import cycle
1 parent 95e5259 commit d6ef6cc

File tree

12 files changed

+82
-37
lines changed

12 files changed

+82
-37
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ jobs:
3434
go run build/ci.go check_generate
3535
go run build/ci.go check_baddeps
3636
37-
keeper:
38-
name: Keeper Builds
39-
needs: test
37+
tests:
38+
name: Tests
4039
runs-on: ubuntu-latest
4140
steps:
4241
- uses: actions/checkout@v4
@@ -49,11 +48,12 @@ jobs:
4948
go-version: '1.25'
5049
cache: false
5150

52-
- name: Build
53-
run: go run build/ci.go keeper
51+
- name: Run tests
52+
run: go run build/ci.go test -p 8
5453

55-
tests:
56-
name: Tests
54+
keeper:
55+
name: Keeper Builds
56+
needs: tests
5757
runs-on: ubuntu-latest
5858
steps:
5959
- uses: actions/checkout@v4
@@ -66,5 +66,5 @@ jobs:
6666
go-version: '1.25'
6767
cache: false
6868

69-
- name: Run tests
70-
run: go run build/ci.go test -p 8
69+
- name: Build
70+
run: go run build/ci.go keeper

core/block_validator.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,6 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
174174
return fmt.Errorf("invalid gas used (remote: %d local: %d)", block.GasUsed(), res.GasUsed)
175175
}
176176

177-
// Berachain: If Prague3, check for ERC20 transfers involving blocked addresses.
178-
if v.config.IsPrague3(block.Number(), block.Time()) {
179-
for _, receipt := range res.Receipts {
180-
if err := ValidatePrague3Transaction(&v.config.Berachain.Prague3, receipt); err != nil {
181-
return err
182-
}
183-
}
184-
}
185-
186177
// Validate the received block's bloom with the one derived from the generated receipts.
187178
// For valid blocks this should always validate to true.
188179
//

core/blockchain.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ func NewBlockChain(db ethdb.Database, genesis *Genesis, engine consensus.Engine,
540540
log.Info("Failed to setup size tracker", "err", err)
541541
}
542542
}
543+
543544
return bc, nil
544545
}
545546

core/forkid/forkid.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ func gatherForks(config *params.ChainConfig, genesis uint64) ([]uint64, []uint64
268268
}
269269
}
270270
}
271-
// Berachain-specific: include nested Prague1, Prague2, and Prague3 fork times in the fork id set
272-
// so that clients using it (e.g. reth) compute the same fork checksum.
271+
// Berachain-specific: include nested Prague1, Prague2, Prague3, Prague4 fork times in the fork
272+
// id set so that clients using it (e.g. reth) compute the same fork checksum.
273273
if config != nil && config.Berachain.Prague1.Time != nil {
274274
forksByTime = append(forksByTime, *config.Berachain.Prague1.Time)
275275
}
@@ -279,6 +279,9 @@ func gatherForks(config *params.ChainConfig, genesis uint64) ([]uint64, []uint64
279279
if config != nil && config.Berachain.Prague3.Time != nil {
280280
forksByTime = append(forksByTime, *config.Berachain.Prague3.Time)
281281
}
282+
if config != nil && config.Berachain.Prague4.Time != nil {
283+
forksByTime = append(forksByTime, *config.Berachain.Prague4.Time)
284+
}
282285
slices.Sort(forksByBlock)
283286
slices.Sort(forksByTime)
284287

core/forkid/forkid_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ func TestCreation(t *testing.T) {
162162
{100, 1759247999, ID{Hash: checksumToBytes(0xd2ebecac), Next: 1759248000}}, // Before Prague2
163163
{100, 1759248000, ID{Hash: checksumToBytes(0xcbbf6c9f), Next: 1762164459}}, // Prague2 active
164164
{100, 1762164458, ID{Hash: checksumToBytes(0xcbbf6c9f), Next: 1762164459}}, // Before Prague3
165-
{100, 1762164459, ID{Hash: checksumToBytes(0x6494a176), Next: 0}}, // Prague3 active
166-
{1000, 2000000000, ID{Hash: checksumToBytes(0x6494a176), Next: 0}}, // Far future
165+
{100, 1762164459, ID{Hash: checksumToBytes(0x6494a176), Next: 1768330800}}, // Prague3 active
166+
{100, 1768330799, ID{Hash: checksumToBytes(0x6494a176), Next: 1768330800}}, // Before Prague4
167+
{100, 1768330800, ID{Hash: checksumToBytes(0x0f320857), Next: 0}}, // Prague4 active
168+
{1000, 2000000000, ID{Hash: checksumToBytes(0x0f320857), Next: 0}}, // Far future
167169
},
168170
},
169171
// Bepolia testnet test cases

core/state_processor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ func ApplyTransactionWithEVM(msg *Message, gp *GasPool, statedb *state.StateDB,
171171
blockGasUsed := *usedGas + result.UsedGas
172172
receipt = MakeReceipt(evm, result, statedb, blockNumber, blockHash, blockTime, tx, blockGasUsed, nil)
173173

174-
// Berachain: If Prague3, check for ERC20 transfers involving blocked addresses.
175-
if evm.ChainConfig().IsPrague3(blockNumber, blockTime) {
174+
// Berachain: If only in Prague3 (not Prague4 onwards), check for ERC20 transfers involving blocked addresses.
175+
if !evm.ChainConfig().IsPrague4(blockNumber, blockTime) && evm.ChainConfig().IsPrague3(blockNumber, blockTime) {
176176
if err := ValidatePrague3Transaction(&evm.ChainConfig().Berachain.Prague3, receipt); err != nil {
177177
return nil, err
178178
}

eth/backend.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/ethereum/go-ethereum/consensus"
3535
"github.com/ethereum/go-ethereum/core"
3636
"github.com/ethereum/go-ethereum/core/filtermaps"
37+
"github.com/ethereum/go-ethereum/core/forkid"
3738
"github.com/ethereum/go-ethereum/core/rawdb"
3839
"github.com/ethereum/go-ethereum/core/state/pruner"
3940
"github.com/ethereum/go-ethereum/core/txpool"
@@ -277,6 +278,11 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
277278
return nil, err
278279
}
279280

281+
// Berachain: log the forkID for debugging convenience.
282+
currentHeader := eth.blockchain.CurrentHeader()
283+
forkID := forkid.NewID(eth.blockchain.Config(), eth.blockchain.Genesis(), currentHeader.Number.Uint64(), currentHeader.Time)
284+
log.Info("Fork Information", "forkID", forkID)
285+
280286
// Initialize filtermaps log index.
281287
fmConfig := filtermaps.Config{
282288
History: config.LogHistory,

eth/catalyst/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedV3P11(update engine.ForkchoiceStateV1,
240240
return engine.STATUS_INVALID, attributesErr("missing beacon root")
241241
case params.ProposerPubkey == nil:
242242
return engine.STATUS_INVALID, attributesErr("missing proposer pubkey")
243-
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
243+
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Prague4, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
244244
return engine.STATUS_INVALID, unsupportedForkErr("fcuV3P11 must only be called for prague1 onwards payloads")
245245
}
246246
}
@@ -720,7 +720,7 @@ func (api *ConsensusAPI) NewPayloadV4P11(params engine.ExecutableData, versioned
720720
return invalidStatus, paramsErr("nil executionRequests post-prague")
721721
case proposerPubkey == nil:
722722
return invalidStatus, paramsErr("nil proposerPubkey post-prague1")
723-
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
723+
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Prague4, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
724724
return invalidStatus, unsupportedForkErr("newPayloadV4P11 must only be called for prague1 onwards payloads")
725725
}
726726
requests := convertRequests(executionRequests)

eth/catalyst/simulated_beacon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type SimulatedBeacon struct {
100100

101101
func payloadVersion(config *params.ChainConfig, time uint64) engine.PayloadVersion {
102102
switch config.LatestFork(time) {
103-
case forks.BPO5, forks.BPO4, forks.BPO3, forks.BPO2, forks.BPO1, forks.Osaka, forks.Prague3, forks.Prague2, forks.Prague1:
103+
case forks.BPO5, forks.BPO4, forks.BPO3, forks.BPO2, forks.BPO1, forks.Osaka, forks.Prague4, forks.Prague3, forks.Prague2, forks.Prague1:
104104
return engine.PayloadV3P11
105105
case forks.Prague, forks.Cancun:
106106
return engine.PayloadV3

eth/catalyst/witness.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedWithWitnessV3P11(update engine.Forkcho
101101
return engine.STATUS_INVALID, attributesErr("missing beacon root")
102102
case params.ProposerPubkey == nil:
103103
return engine.STATUS_INVALID, attributesErr("missing proposer pubkey")
104-
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
104+
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Prague4, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
105105
return engine.STATUS_INVALID, unsupportedForkErr("fcuV3P11 must only be called for prague1 onwards payloads")
106106
}
107107
}
@@ -207,7 +207,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV4P11(params engine.ExecutableData
207207
return invalidStatus, paramsErr("nil executionRequests post-prague")
208208
case proposerPubkey == nil:
209209
return invalidStatus, paramsErr("nil proposerPubkey post-prague1")
210-
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
210+
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Prague4, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
211211
return invalidStatus, unsupportedForkErr("newPayloadV4P11 must only be called for prague1 payloads")
212212
}
213213
requests := convertRequests(executionRequests)
@@ -312,7 +312,7 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV4P11(params engine.ExecutableDa
312312
return engine.StatelessPayloadStatusV1{Status: engine.INVALID}, paramsErr("nil executionRequests post-prague")
313313
case proposerPubkey == nil:
314314
return engine.StatelessPayloadStatusV1{Status: engine.INVALID}, paramsErr("nil proposerPubkey post-prague1")
315-
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
315+
case !api.checkFork(params.Timestamp, forks.Prague1, forks.Prague2, forks.Prague3, forks.Prague4, forks.Osaka, forks.BPO1, forks.BPO2, forks.BPO3, forks.BPO4, forks.BPO5):
316316
return engine.StatelessPayloadStatusV1{Status: engine.INVALID}, unsupportedForkErr("executeStatelessPayloadV4P11 must only be called for prague1 payloads")
317317
}
318318
requests := convertRequests(executionRequests)

0 commit comments

Comments
 (0)