Skip to content

Comments

Support time based forks for BFT chains#9785

Open
matthew1001 wants to merge 10 commits intohyperledger:mainfrom
matthew1001:bft-time-based-forks
Open

Support time based forks for BFT chains#9785
matthew1001 wants to merge 10 commits intohyperledger:mainfrom
matthew1001:bft-time-based-forks

Conversation

@matthew1001
Copy link
Contributor

@matthew1001 matthew1001 commented Feb 11, 2026

PR description

This PR adds fork-type to Fork so that wherever a fork is retrieved from a ForkSchedule the correct one is retrieved based on:

  • The "block" of the fork (which may be a timestamp)
  • The protocol schedule, which denotes the type of fork at a given point, i.e. block (e.g. if londonBlock applies at the time of the fork) or time (e.g. if shanghaiTime applies at the time of the fork)

Getting a fork from ForkSchedule now requires the caller to pass in both the relevant block number and timestamp. In some calling contexts these will be the same, but when they are different the ForkSchedule needs to know which to use to determine the correct fork to apply.

Currently the ForkSchedule is created, then passed to the BFT protocol schedule creation. So there's a slight chicken-and-egg situation where protocol schedule is needed to apply fork types to the fork schedule - but the fork schedule is needed to create the protocol schedule.

I've decided to take the approach of leaving that ordering, but updating the fork schedule with types once we have a protocol schedule.

These changes should be isolated from almost all non-PoA code.

Fixed Issue(s)

Fixes #9681

Example of manual tests run:

genesis.json:

(where the time at the start of the test was 1771577257 so initially the london EVM was applicable.

{
  "config" : {
    "chainId" : 1337,
    "londonBlock" : 0,
    "shanghaiTime" : 1771577357,
    "zeroBaseFee": true,
    "qbft" : {
      "blockperiodseconds" : 2,
      "epochlength" : 30000,
      "requesttimeoutseconds" : 30
    },
    "transitions": {
      "qbft": [
        {
          "block": 10,
          "blockperiodseconds": 3
        },
        {
          "block": 20,
          "blockperiodseconds": 4
        },
        {
          "block": 1771577457,
          "blockperiodseconds": 5
        }
      ]
    },
...
2026-02-20 08:47:32.339+0000 | main | INFO  | DefaultP2PNetwork | Node address 0x5c9437de876531c73c9618d13872f7508869f253
2026-02-20 08:47:32.344+0000 | main | INFO  | NetworkRunner | Supported capabilities: [eth/68, eth/69], [istanbul/100], [snap/1]
2026-02-20 08:47:32.344+0000 | main | INFO  | DefaultSynchronizer | Starting synchronizer.
2026-02-20 08:47:32.346+0000 | main | INFO  | TransactionPoolFactory | Enabling transaction handling following initial sync
2026-02-20 08:47:32.346+0000 | main | INFO  | BftMiningCoordinator | Starting BFT mining coordinator following initial sync
2026-02-20 08:47:32.354+0000 | main | INFO  | FullSyncDownloader | Starting full sync.
2026-02-20 08:47:32.354+0000 | main | INFO  | FullSyncTargetManager | Unable to find sync target. Waiting for 1 peers minimum. Currently checking 0 peers for usefulness
2026-02-20 08:47:32.358+0000 | main | INFO  | Runner | Ethereum main loop is up.
2026-02-20 08:47:32.401+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #1 / 0 tx / 0 pending / 0 (0.0%) gas / (0x81eaf31bf15dfb5a1e0ef4cbc753f2aec19224c5875db4c8532390722d2a0103)
2026-02-20 08:47:34.014+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #2 / 0 tx / 0 pending / 0 (0.0%) gas / (0xca2df33196fe94e7c7f3dbc8a567791e47adddc23e7453e4da61034e37a72855)

...

2026-02-20 08:47:51.028+0000 | BftProcessorExecutor-QBFT-0 | INFO  | NodeRecordManager | Writing node record to disk. NodeRecord{seq=2, publicKey=0x02beea7aa3a6e1f862870a456239dbf9a232d9a69e58edfeda92193f679bdbf396, udpAddress=Optional[/127.0.0.1:50303], tcpAddress=Optional[/127.0.0.1:50303], quicAddress=Optional.empty, udp6Address=Optional.empty, tcp6Address=Optional.empty, quic6Address=Optional.empty, asBase64=-Ju4QIsA0AikhfYevJ15Ax6ifPyVFS_A2fFmSRc7LOHGzVWfYLUNmj6W2rU0_r7fEKIXl44byFOkWJqguCMu4VyM_b0Cg2V0aMvKhPXcYjyEaZggDYJpZIJ2NIJpcIR_AAABiXNlY3AyNTZrMaECvup6o6bh-GKHCkViOdv5ojLZpp5Y7f7akhk_Z5vb85aDdGNwgsR_g3VkcILEfw, nodeId=0x22ca428d119ff48f9ca3c2ee5c9437de876531c73c9618d13872f7508869f253, customFields={tcp=50303, udp=50303, eth=[[0xf5dc623c, 0x6998200d]], id=V4, ip=0x7f000001, secp256k1=0x02beea7aa3a6e1f862870a456239dbf9a232d9a69e58edfeda92193f679bdbf396}}
2026-02-20 08:47:51.030+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #10 / 0 tx / 0 pending / 0 (0.0%) gas / (0x0d8facdbc330521941854dc448eabf6cfaf874293a67d7e46f1ea29e045def91)
2026-02-20 08:47:54.022+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #11 / 0 tx / 0 pending / 0 (0.0%) gas / (0x923ef84639ae7ad99cdcd58cd760f4d7057951001ca82eebde259a31fa3de410)
2026-02-20 08:47:57.010+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #12 / 0 tx / 0 pending / 0 (0.0%) gas / (0x670e253749b46d3de679a9e144f24758d4e396daaecdbf4128696a9599191e9a)

...

2026-02-20 08:48:22.009+0000 | BftProcessorExecutor-QBFT-0 | INFO  | NodeRecordManager | Writing node record to disk. NodeRecord{seq=3, publicKey=0x02beea7aa3a6e1f862870a456239dbf9a232d9a69e58edfeda92193f679bdbf396, udpAddress=Optional[/127.0.0.1:50303], tcpAddress=Optional[/127.0.0.1:50303], quicAddress=Optional.empty, udp6Address=Optional.empty, tcp6Address=Optional.empty, quic6Address=Optional.empty, asBase64=-Ju4QJlD5KIJMSw8PiraGVhr521s3rGEKtdQ5U4YAtbWMyCwM47SNWYncKeYJ9CBzvuzbvG0n5jzzcDAyjVZwwUWXOkDg2V0aMvKhPXcYjyEaZggDYJpZIJ2NIJpcIR_AAABiXNlY3AyNTZrMaECvup6o6bh-GKHCkViOdv5ojLZpp5Y7f7akhk_Z5vb85aDdGNwgsR_g3VkcILEfw, nodeId=0x22ca428d119ff48f9ca3c2ee5c9437de876531c73c9618d13872f7508869f253, customFields={tcp=50303, udp=50303, eth=[[0xf5dc623c, 0x6998200d]], id=V4, ip=0x7f000001, secp256k1=0x02beea7aa3a6e1f862870a456239dbf9a232d9a69e58edfeda92193f679bdbf396}}
2026-02-20 08:48:22.010+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #20 / 0 tx / 0 pending / 0 (0.0%) gas / (0x24b5e7f28e09115d39ae928bbfaea9e7452bb3f04984e462d4383e6495cc303b)
2026-02-20 08:48:26.004+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #21 / 0 tx / 0 pending / 0 (0.0%) gas / (0xe9e903cf1835432a24e34505faa1703b78ccea0ad49269d82712077c5715377f)
2026-02-20 08:48:30.056+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #22 / 0 tx / 0 pending / 0 (0.0%) gas / (0x935645fda4c1dc72a93538ffba311e1e30a2a976540ec78ecf5a3f40f768a8c2)
2026-02-20 08:48:34.018+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #23 / 0 tx / 0 pending / 0 (0.0%) gas / (0x7eb508c3359ffadb4f4ab5004b0d7e6d5b806c7c2ac16b9ee005d7c0d6e35b09)

...

2026-02-20 08:51:59.010+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #71 / 0 tx / 0 pending / 0 (0.0%) gas / (0x05300aebda4b48770dc4a26b236c967f13e25cdd0b73926c8e78c167f21510b1)
2026-02-20 08:52:04.015+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #72 / 0 tx / 0 pending / 0 (0.0%) gas / (0x94393b04a90fb65ffbe89a2d8b571076787e5f52d1f148512eb8c0aefec138ca)
2026-02-20 08:52:09.008+0000 | BftProcessorExecutor-QBFT-0 | INFO  | QbftBesuControllerBuilder | Produced empty block #73 / 0 tx / 0 pending / 0 (0.0%) gas / (0xc40f3562db64deb2e1fceb0b9178c9cde853ea0eae44670df3939c31387a9e3b)

@matthew1001 matthew1001 force-pushed the bft-time-based-forks branch 3 times, most recently from 045ec55 to bf86e32 Compare February 11, 2026 16:04
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
@matthew1001 matthew1001 changed the title WIP - time based forks for BFT Support time based forks for BFT chains Feb 20, 2026
@matthew1001 matthew1001 marked this pull request as ready for review February 20, 2026 09:27
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Signed-off-by: Matthew Whitehead <matthew.whitehead@kaleido.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QBFT doesn't support time-based block transitions for blockperiodseconds

1 participant