@@ -1165,6 +1165,115 @@ func TestChangingSlotterSize(t *testing.T) {
11651165 }
11661166}
11671167
1168+ // TestBillyMigration tests the billy migration from the default slotter to
1169+ // the PeerDAS slotter. This tests both the migration of the slotter
1170+ // as well as increasing the slotter size of the new slotter.
1171+ func TestBillyMigration (t * testing.T ) {
1172+ //log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
1173+
1174+ // Create a temporary folder for the persistent backend
1175+ storage := t .TempDir ()
1176+
1177+ os .MkdirAll (filepath .Join (storage , pendingTransactionStore ), 0700 )
1178+ os .MkdirAll (filepath .Join (storage , limboedTransactionStore ), 0700 )
1179+ // Create the billy with the old slotter
1180+ oldSlotter := newSlotterEIP7594 (6 )
1181+ store , _ := billy .Open (billy.Options {Path : filepath .Join (storage , pendingTransactionStore )}, oldSlotter , nil )
1182+
1183+ // Create transactions from a few accounts.
1184+ var (
1185+ key1 , _ = crypto .GenerateKey ()
1186+ key2 , _ = crypto .GenerateKey ()
1187+ key3 , _ = crypto .GenerateKey ()
1188+
1189+ addr1 = crypto .PubkeyToAddress (key1 .PublicKey )
1190+ addr2 = crypto .PubkeyToAddress (key2 .PublicKey )
1191+ addr3 = crypto .PubkeyToAddress (key3 .PublicKey )
1192+
1193+ tx1 = makeMultiBlobTx (0 , 1 , 1000 , 100 , 6 , 0 , key1 , types .BlobSidecarVersion0 )
1194+ tx2 = makeMultiBlobTx (0 , 1 , 800 , 70 , 6 , 0 , key2 , types .BlobSidecarVersion0 )
1195+ tx3 = makeMultiBlobTx (0 , 1 , 800 , 110 , 24 , 0 , key3 , types .BlobSidecarVersion0 )
1196+
1197+ blob1 , _ = rlp .EncodeToBytes (tx1 )
1198+ blob2 , _ = rlp .EncodeToBytes (tx2 )
1199+ )
1200+
1201+ // Write the two safely sized txs to store. note: although the store is
1202+ // configured for a blob count of 6, it can also support around ~1mb of call
1203+ // data - all this to say that we aren't using the the absolute largest shelf
1204+ // available.
1205+ store .Put (blob1 )
1206+ store .Put (blob2 )
1207+ store .Close ()
1208+
1209+ // Mimic a blobpool with max blob count of 6 upgrading to a max blob count of 24.
1210+ for _ , maxBlobs := range []int {6 , 24 } {
1211+ statedb , _ := state .New (types .EmptyRootHash , state .NewDatabaseForTesting ())
1212+ statedb .AddBalance (addr1 , uint256 .NewInt (1_000_000_000 ), tracing .BalanceChangeUnspecified )
1213+ statedb .AddBalance (addr2 , uint256 .NewInt (1_000_000_000 ), tracing .BalanceChangeUnspecified )
1214+ statedb .AddBalance (addr3 , uint256 .NewInt (1_000_000_000 ), tracing .BalanceChangeUnspecified )
1215+ statedb .Commit (0 , true , false )
1216+
1217+ // Make custom chain config where the max blob count changes based on the loop variable.
1218+ zero := uint64 (0 )
1219+ config := & params.ChainConfig {
1220+ ChainID : big .NewInt (1 ),
1221+ LondonBlock : big .NewInt (0 ),
1222+ BerlinBlock : big .NewInt (0 ),
1223+ CancunTime : & zero ,
1224+ OsakaTime : & zero ,
1225+ BlobScheduleConfig : & params.BlobScheduleConfig {
1226+ Cancun : & params.BlobConfig {
1227+ Target : maxBlobs / 2 ,
1228+ Max : maxBlobs ,
1229+ UpdateFraction : params .DefaultCancunBlobConfig .UpdateFraction ,
1230+ },
1231+ Osaka : & params.BlobConfig {
1232+ Target : maxBlobs / 2 ,
1233+ Max : maxBlobs ,
1234+ UpdateFraction : params .DefaultCancunBlobConfig .UpdateFraction ,
1235+ },
1236+ },
1237+ }
1238+ chain := & testBlockChain {
1239+ config : config ,
1240+ basefee : uint256 .NewInt (1050 ),
1241+ blobfee : uint256 .NewInt (105 ),
1242+ statedb : statedb ,
1243+ }
1244+ pool := New (Config {Datadir : storage }, chain , nil )
1245+ if err := pool .Init (1 , chain .CurrentBlock (), newReserver ()); err != nil {
1246+ t .Fatalf ("failed to create blob pool: %v" , err )
1247+ }
1248+
1249+ // Try to add the big blob tx. In the initial iteration it should overflow
1250+ // the pool. On the subsequent iteration it should be accepted.
1251+ errs := pool .Add ([]* types.Transaction {tx3 }, true )
1252+ if _ , ok := pool .index [addr3 ]; ok && maxBlobs == 6 {
1253+ t .Errorf ("expected insert of oversized blob tx to fail: blobs=24, maxBlobs=%d, err=%v" , maxBlobs , errs [0 ])
1254+ } else if ! ok && maxBlobs == 10 {
1255+ t .Errorf ("expected insert of oversized blob tx to succeed: blobs=24, maxBlobs=%d, err=%v" , maxBlobs , errs [0 ])
1256+ }
1257+
1258+ // Verify the regular two txs are always available.
1259+ if got := pool .Get (tx1 .Hash ()); got == nil {
1260+ t .Errorf ("expected tx %s from %s in pool" , tx1 .Hash (), addr1 )
1261+ }
1262+ if got := pool .Get (tx2 .Hash ()); got == nil {
1263+ t .Errorf ("expected tx %s from %s in pool" , tx2 .Hash (), addr2 )
1264+ }
1265+
1266+ // Verify all the calculated pool internals. Interestingly, this is **not**
1267+ // a duplication of the above checks, this actually validates the verifier
1268+ // using the above already hard coded checks.
1269+ //
1270+ // Do not remove this, nor alter the above to be generic.
1271+ verifyPoolInternals (t , pool )
1272+
1273+ pool .Close ()
1274+ }
1275+ }
1276+
11681277// TestBlobCountLimit tests the blobpool enforced limits on the max blob count.
11691278func TestBlobCountLimit (t * testing.T ) {
11701279 var (
0 commit comments