|
17 | 17 | package miner
|
18 | 18 |
|
19 | 19 | import (
|
20 |
| - "context" |
21 |
| - "errors" |
22 | 20 | "math"
|
23 | 21 | "math/big"
|
24 | 22 | "math/rand"
|
@@ -1200,82 +1198,82 @@ func TestPrioritizeOverflowTx(t *testing.T) {
|
1200 | 1198 | }
|
1201 | 1199 | }
|
1202 | 1200 |
|
1203 |
| -type mockL1Client struct { |
1204 |
| - failList []bool |
1205 |
| -} |
1206 |
| - |
1207 |
| -func (c *mockL1Client) StoragesAt(ctx context.Context, account common.Address, keys []common.Hash, blockNumber *big.Int) ([]byte, error) { |
1208 |
| - if len(c.failList) == 0 { |
1209 |
| - return common.Hash{}.Bytes(), nil |
1210 |
| - } |
1211 |
| - failed := c.failList[0] |
1212 |
| - c.failList = c.failList[1:] |
1213 |
| - if failed { |
1214 |
| - return nil, errors.New("error") |
1215 |
| - } else { |
1216 |
| - return common.Hash{}.Bytes(), nil |
1217 |
| - } |
1218 |
| -} |
1219 |
| - |
1220 |
| -func TestL1SloadFailedTxReexecuted(t *testing.T) { |
1221 |
| - assert := assert.New(t) |
1222 |
| - |
1223 |
| - var ( |
1224 |
| - chainConfig = params.AllCliqueProtocolChanges |
1225 |
| - db = rawdb.NewMemoryDatabase() |
1226 |
| - engine = clique.New(chainConfig.Clique, db) |
1227 |
| - ) |
1228 |
| - |
1229 |
| - chainConfig.Clique = ¶ms.CliqueConfig{Period: 1, Epoch: 30000} |
1230 |
| - chainConfig.LondonBlock = big.NewInt(0) |
1231 |
| - chainConfig.DescartesBlock = big.NewInt(0) |
1232 |
| - |
1233 |
| - w, b := newTestWorker(t, chainConfig, engine, db, 0) |
1234 |
| - // GetStoragesAt will shouldn't fail 2 times on block tracing and should fail then on tx executing |
1235 |
| - w.chain.GetVMConfig().L1Client = &mockL1Client{failList: []bool{false, false, true, true, true}} |
1236 |
| - defer w.close() |
1237 |
| - |
1238 |
| - // This test chain imports the mined blocks. |
1239 |
| - db2 := rawdb.NewMemoryDatabase() |
1240 |
| - b.genesis.MustCommit(db2) |
1241 |
| - chain, _ := core.NewBlockChain(db2, nil, b.chain.Config(), engine, vm.Config{ |
1242 |
| - Debug: true, |
1243 |
| - Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil) |
1244 |
| - defer chain.Stop() |
1245 |
| - chain.GetVMConfig().L1Client = &mockL1Client{} |
1246 |
| - |
1247 |
| - // Ignore empty commit here for less noise. |
1248 |
| - w.skipSealHook = func(task *task) bool { |
1249 |
| - return len(task.receipts) == 0 |
1250 |
| - } |
1251 |
| - |
1252 |
| - // Wait for mined blocks. |
1253 |
| - sub := w.mux.Subscribe(core.NewMinedBlockEvent{}) |
1254 |
| - defer sub.Unsubscribe() |
1255 |
| - |
1256 |
| - // Define tx that calls L1Sload |
1257 |
| - l1SlaodAddress := common.BytesToAddress([]byte{1, 1}) |
1258 |
| - input := make([]byte, 52) |
1259 |
| - tx, _ := types.SignTx(types.NewTransaction(b.txPool.Nonce(testBankAddress), l1SlaodAddress, big.NewInt(0), 25208, big.NewInt(10*params.InitialBaseFee), input), types.HomesteadSigner{}, testBankKey) |
1260 |
| - |
1261 |
| - // Process 2 transactions with gas order: tx0 > tx1, tx1 will overflow. |
1262 |
| - b.txPool.AddRemote(tx) |
1263 |
| - // b.txPool.AddLocal(b.newRandomTx(false)) |
1264 |
| - w.start() |
1265 |
| - |
1266 |
| - select { |
1267 |
| - case ev := <-sub.Chan(): |
1268 |
| - w.stop() |
1269 |
| - block := ev.Data.(core.NewMinedBlockEvent).Block |
1270 |
| - assert.Equal(1, len(block.Transactions())) |
1271 |
| - assert.Equal(tx.Hash(), block.Transactions()[0].Hash()) |
1272 |
| - if _, err := chain.InsertChain([]*types.Block{block}); err != nil { |
1273 |
| - t.Fatalf("failed to insert new mined block %d: %v", block.NumberU64(), err) |
1274 |
| - } |
1275 |
| - case <-time.After(3 * time.Second): // Worker needs 1s to include new changes. |
1276 |
| - t.Fatalf("timeout") |
1277 |
| - } |
1278 |
| -} |
| 1201 | +// type mockL1Client struct { |
| 1202 | +// failList []bool |
| 1203 | +// } |
| 1204 | + |
| 1205 | +// func (c *mockL1Client) StoragesAt(ctx context.Context, account common.Address, keys []common.Hash, blockNumber *big.Int) ([]byte, error) { |
| 1206 | +// if len(c.failList) == 0 { |
| 1207 | +// return common.Hash{}.Bytes(), nil |
| 1208 | +// } |
| 1209 | +// failed := c.failList[0] |
| 1210 | +// c.failList = c.failList[1:] |
| 1211 | +// if failed { |
| 1212 | +// return nil, errors.New("error") |
| 1213 | +// } else { |
| 1214 | +// return common.Hash{}.Bytes(), nil |
| 1215 | +// } |
| 1216 | +// } |
| 1217 | + |
| 1218 | +// func TestL1SloadFailedTxReexecuted(t *testing.T) { |
| 1219 | +// assert := assert.New(t) |
| 1220 | + |
| 1221 | +// var ( |
| 1222 | +// chainConfig = params.AllCliqueProtocolChanges |
| 1223 | +// db = rawdb.NewMemoryDatabase() |
| 1224 | +// engine = clique.New(chainConfig.Clique, db) |
| 1225 | +// ) |
| 1226 | + |
| 1227 | +// chainConfig.Clique = ¶ms.CliqueConfig{Period: 1, Epoch: 30000} |
| 1228 | +// chainConfig.LondonBlock = big.NewInt(0) |
| 1229 | +// chainConfig.DescartesBlock = big.NewInt(0) |
| 1230 | + |
| 1231 | +// w, b := newTestWorker(t, chainConfig, engine, db, 0) |
| 1232 | +// // GetStoragesAt will shouldn't fail 2 times on block tracing and should fail then on tx executing |
| 1233 | +// w.chain.GetVMConfig().L1Client = &mockL1Client{failList: []bool{false, false, true, true, true}} |
| 1234 | +// defer w.close() |
| 1235 | + |
| 1236 | +// // This test chain imports the mined blocks. |
| 1237 | +// db2 := rawdb.NewMemoryDatabase() |
| 1238 | +// b.genesis.MustCommit(db2) |
| 1239 | +// chain, _ := core.NewBlockChain(db2, nil, b.chain.Config(), engine, vm.Config{ |
| 1240 | +// Debug: true, |
| 1241 | +// Tracer: vm.NewStructLogger(&vm.LogConfig{EnableMemory: true, EnableReturnData: true})}, nil, nil) |
| 1242 | +// defer chain.Stop() |
| 1243 | +// chain.GetVMConfig().L1Client = &mockL1Client{} |
| 1244 | + |
| 1245 | +// // Ignore empty commit here for less noise. |
| 1246 | +// w.skipSealHook = func(task *task) bool { |
| 1247 | +// return len(task.receipts) == 0 |
| 1248 | +// } |
| 1249 | + |
| 1250 | +// // Wait for mined blocks. |
| 1251 | +// sub := w.mux.Subscribe(core.NewMinedBlockEvent{}) |
| 1252 | +// defer sub.Unsubscribe() |
| 1253 | + |
| 1254 | +// // Define tx that calls L1Sload |
| 1255 | +// l1SlaodAddress := common.BytesToAddress([]byte{1, 1}) |
| 1256 | +// input := make([]byte, 52) |
| 1257 | +// tx, _ := types.SignTx(types.NewTransaction(b.txPool.Nonce(testBankAddress), l1SlaodAddress, big.NewInt(0), 25208, big.NewInt(10*params.InitialBaseFee), input), types.HomesteadSigner{}, testBankKey) |
| 1258 | + |
| 1259 | +// // Process 2 transactions with gas order: tx0 > tx1, tx1 will overflow. |
| 1260 | +// b.txPool.AddRemote(tx) |
| 1261 | +// // b.txPool.AddLocal(b.newRandomTx(false)) |
| 1262 | +// w.start() |
| 1263 | + |
| 1264 | +// select { |
| 1265 | +// case ev := <-sub.Chan(): |
| 1266 | +// w.stop() |
| 1267 | +// block := ev.Data.(core.NewMinedBlockEvent).Block |
| 1268 | +// assert.Equal(1, len(block.Transactions())) |
| 1269 | +// assert.Equal(tx.Hash(), block.Transactions()[0].Hash()) |
| 1270 | +// if _, err := chain.InsertChain([]*types.Block{block}); err != nil { |
| 1271 | +// t.Fatalf("failed to insert new mined block %d: %v", block.NumberU64(), err) |
| 1272 | +// } |
| 1273 | +// case <-time.After(3 * time.Second): // Worker needs 1s to include new changes. |
| 1274 | +// t.Fatalf("timeout") |
| 1275 | +// } |
| 1276 | +// } |
1279 | 1277 |
|
1280 | 1278 | func TestSkippedTransactionDatabaseEntries(t *testing.T) {
|
1281 | 1279 | assert := assert.New(t)
|
|
0 commit comments