@@ -2036,3 +2036,91 @@ func benchmarkPoolPending(b *testing.B, datacap uint64) {
20362036 }
20372037 }
20382038}
2039+
2040+ // TestOsakaMaxBlobsPerTx verifies that the maxBlobsPerTx parameter is dynamic
2041+ // and changes according to the Osaka hardfork activation.
2042+ func TestOsakaMaxBlobsPerTx (t * testing.T ) {
2043+ var (
2044+ key , _ = crypto .GenerateKey ()
2045+ addr = crypto .PubkeyToAddress (key .PublicKey )
2046+ )
2047+
2048+ statedb , _ := state .New (types .EmptyRootHash , state .NewDatabaseForTesting ())
2049+ statedb .AddBalance (addr , uint256 .NewInt (1_000_000_000 ), tracing .BalanceChangeUnspecified )
2050+ statedb .Commit (0 , true , false )
2051+
2052+ osakaTime := uint64 (1 )
2053+ pragueTime := uint64 (0 )
2054+ cancunTime := uint64 (0 )
2055+ config := & params.ChainConfig {
2056+ ChainID : big .NewInt (1 ),
2057+ LondonBlock : big .NewInt (0 ),
2058+ BerlinBlock : big .NewInt (0 ),
2059+ CancunTime : & cancunTime ,
2060+ PragueTime : & pragueTime ,
2061+ OsakaTime : & osakaTime ,
2062+ BlobScheduleConfig : & params.BlobScheduleConfig {
2063+ Cancun : params .DefaultCancunBlobConfig ,
2064+ Prague : params .DefaultPragueBlobConfig ,
2065+ Osaka : params .DefaultOsakaBlobConfig ,
2066+ },
2067+ }
2068+
2069+ chain := & testBlockChain {
2070+ config : config ,
2071+ basefee : uint256 .NewInt (params .InitialBaseFee ),
2072+ blobfee : uint256 .NewInt (params .BlobTxMinBlobGasprice ),
2073+ statedb : statedb ,
2074+ }
2075+
2076+ tests := []struct {
2077+ name string
2078+ header * types.Header
2079+ numBlobs int
2080+ sidecarVer uint8
2081+ expectErr error
2082+ }{
2083+ {
2084+ name : "before Osaka, maxBlobsPerTx blobs" ,
2085+ header : & types.Header {Number : big .NewInt (0 ), Time : 0 , Difficulty : common .Big0 , GasLimit : 30_000_000 , BaseFee : big .NewInt (int64 (params .InitialBaseFee ))},
2086+ numBlobs : maxBlobsPerTx ,
2087+ sidecarVer : types .BlobSidecarVersion0 ,
2088+ expectErr : nil ,
2089+ },
2090+ {
2091+ name : "after Osaka, maxBlobsPerTx blobs" ,
2092+ header : & types.Header {Number : big .NewInt (1 ), Time : 1 , Difficulty : common .Big0 , GasLimit : 30_000_000 , BaseFee : big .NewInt (int64 (params .InitialBaseFee ))},
2093+ numBlobs : maxBlobsPerTx ,
2094+ sidecarVer : types .BlobSidecarVersion1 ,
2095+ expectErr : txpool .ErrTxBlobLimitExceeded ,
2096+ },
2097+ {
2098+ name : "after Osaka, BlobTxMaxBlobs blobs" ,
2099+ header : & types.Header {Number : big .NewInt (1 ), Time : 1 , Difficulty : common .Big0 , GasLimit : 30_000_000 , BaseFee : big .NewInt (int64 (params .InitialBaseFee ))},
2100+ numBlobs : params .BlobTxMaxBlobs ,
2101+ sidecarVer : types .BlobSidecarVersion1 ,
2102+ expectErr : nil ,
2103+ },
2104+ }
2105+
2106+ for _ , tt := range tests {
2107+ t .Run (tt .name , func (t * testing.T ) {
2108+ pool := New (Config {Datadir : t .TempDir ()}, chain , nil )
2109+ if err := pool .Init (1 , tt .header , newReserver ()); err != nil {
2110+ t .Fatalf ("failed to create blob pool: %v" , err )
2111+ }
2112+ tx := makeMultiBlobTx (0 , 1 , 1 , 1 , tt .numBlobs , 0 , key , tt .sidecarVer )
2113+ err := pool .add (tx )
2114+ if tt .expectErr != nil {
2115+ if ! errors .Is (err , tt .expectErr ) {
2116+ t .Errorf ("expected error %v, got: %v" , tt .expectErr , err )
2117+ }
2118+ } else {
2119+ if err != nil {
2120+ t .Errorf ("expected success, got: %v" , err )
2121+ }
2122+ }
2123+ pool .Close ()
2124+ })
2125+ }
2126+ }
0 commit comments