@@ -999,8 +999,14 @@ u256 Block::enact( VerifiedBlockRef const& _block, BlockChain const& _bc ) {
999999 throw ;
10001000 }
10011001
1002- // EIP-2718: use typed receipt encoding for non-Legacy transactions.
1003- if ( EIP1559TransactionsPatch::isEnabledInWorkingBlock () &&
1002+ // The EIP-1559
1003+ // transaction format is accepted before Berlin, but the typed-receipt
1004+ // encoding must only change at the coordinated Berlin fork so blocks
1005+ // produced before it keep their original receiptsRoot.
1006+ // The parent block timestamp is used (not the global committed-block
1007+ // timestamp) so the encoding is deterministic per block, including when
1008+ // a block is re-enacted out of order.
1009+ if ( BerlinForkPatch::isEnabledWhen ( previousInfo ().timestamp () ) &&
10041010 m_receipts.back ().txType () > 0 ) {
10051011 receipts.push_back ( m_receipts.back ().typedRlp () );
10061012 } else {
@@ -1420,10 +1426,15 @@ void Block::commitToSeal(
14201426 RLPStream k;
14211427 k << i;
14221428
1423- // Since EIP-1559 API is enabled before Berlin fork,
1424- // this part of EIP-2718 logic is activated depending on EIP1559TransactionsPatch
1429+ // EIP-2718 typed-receipt encoding is gated on BerlinForkPatch:
1430+ // the EIP-1559 transaction format is accepted
1431+ // before Berlin, but the receipt encoding must only change at the
1432+ // coordinated Berlin fork so pre-Berlin blocks keep their receiptsRoot.
1433+ // The parent block timestamp is used (not the global committed-block
1434+ // timestamp) so the encoding is deterministic per block and matches enact().
14251435 bytes receiptBytes;
1426- if ( EIP1559TransactionsPatch::isEnabledInWorkingBlock () && receipt ( i ).txType () > 0 ) {
1436+ if ( BerlinForkPatch::isEnabledWhen ( previousInfo ().timestamp () ) &&
1437+ receipt ( i ).txType () > 0 ) {
14271438 receiptBytes = receipt ( i ).typedRlp ();
14281439 } else {
14291440 RLPStream receiptrlp;
@@ -1433,9 +1444,11 @@ void Block::commitToSeal(
14331444 receiptsMap.insert ( std::make_pair ( k.out (), receiptBytes ) );
14341445
14351446 dev::bytes txOutput = m_transactions[i].toBytes ();
1436- // Same as receiptBytes creation:
1437- // this part of EIP-2718 logic is activated depending on EIP1559TransactionsPatch
1438- if ( EIP1559TransactionsPatch::isEnabledInWorkingBlock () &&
1447+ // EIP-2718: typed transactions go into the transactions trie wrapped as an
1448+ // RLP byte string. Unlike the receipt encoding above, this is gated on
1449+ // EIP1559TransactionsPatch because typed transactions are accepted
1450+ // before Berlin.
1451+ if ( EIP1559TransactionsPatch::isEnabledWhen ( previousInfo ().timestamp () ) &&
14391452 m_transactions[i].txType () != dev::eth::TransactionType::Legacy ) {
14401453 RLPStream s;
14411454 s.append ( txOutput );
0 commit comments