Skip to content

Commit 8838ccf

Browse files
Revert "eth/tracers: fix standardTraceBlockToFile (ethereum#31763)"
This reverts commit 7705d13.
1 parent 7d7a246 commit 8838ccf

File tree

2 files changed

+0
-144
lines changed

2 files changed

+0
-144
lines changed

eth/tracers/api.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,12 +1104,10 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
11041104
if !canon {
11051105
prefix = fmt.Sprintf("%valt-", prefix)
11061106
}
1107-
11081107
dump, err = os.CreateTemp(os.TempDir(), prefix)
11091108
if err != nil {
11101109
return nil, err
11111110
}
1112-
11131111
dumps = append(dumps, dump.Name())
11141112

11151113
// Swap out the noop logger to the standard tracer
@@ -1118,33 +1116,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
11181116
Tracer: logger.NewJSONLogger(&logConfig, writer),
11191117
EnablePreimageRecording: true,
11201118
}
1121-
1122-
// Finalize the state so any modifications are written to the trie
1123-
// Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect
1124-
statedb.Finalise(evm.ChainConfig().IsEIP158(block.Number()))
1125-
continue
1126-
}
1127-
// The transaction should be traced.
1128-
// Generate a unique temporary file to dump it into.
1129-
prefix := fmt.Sprintf("block_%#x-%d-%#x-", block.Hash().Bytes()[:4], i, tx.Hash().Bytes()[:4])
1130-
if !canon {
1131-
prefix = fmt.Sprintf("%valt-", prefix)
11321119
}
1133-
1134-
dump, err = os.CreateTemp(os.TempDir(), prefix)
1135-
if err != nil {
1136-
return nil, err
1137-
}
1138-
dumps = append(dumps, dump.Name())
1139-
// Set up the tracer and EVM for the transaction.
1140-
var (
1141-
writer = bufio.NewWriter(dump)
1142-
tracer = logger.NewJSONLogger(&logConfig, writer)
1143-
evm = vm.NewEVM(vmctx, statedb, chainConfig, vm.Config{
1144-
Tracer: tracer,
1145-
NoBaseFee: true,
1146-
})
1147-
)
11481120
// Execute the transaction and flush any traces to disk
11491121
//nolint: nestif
11501122
if stateSyncPresent && i == len(txs)-1 {

eth/tracers/api_test.go

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"errors"
2424
"fmt"
2525
"math/big"
26-
"os"
2726
"reflect"
2827
"slices"
2928
"sync/atomic"
@@ -1376,118 +1375,3 @@ func TestTraceBlockWithBasefee(t *testing.T) {
13761375
}
13771376
}
13781377
}
1379-
1380-
func TestStandardTraceBlockToFile(t *testing.T) {
1381-
var (
1382-
// A sender who makes transactions, has some funds
1383-
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
1384-
address = crypto.PubkeyToAddress(key.PublicKey)
1385-
funds = big.NewInt(1000000000000000)
1386-
1387-
// first contract the sender transacts with
1388-
aa = common.HexToAddress("0x7217d81b76bdd8707601e959454e3d776aee5f43")
1389-
aaCode = []byte{byte(vm.PUSH1), 0x00, byte(vm.POP)}
1390-
1391-
// second contract the sender transacts with
1392-
bb = common.HexToAddress("0x7217d81b76bdd8707601e959454e3d776aee5f44")
1393-
bbCode = []byte{byte(vm.PUSH2), 0x00, 0x01, byte(vm.POP)}
1394-
)
1395-
1396-
genesis := &core.Genesis{
1397-
Config: params.TestChainConfig,
1398-
Alloc: types.GenesisAlloc{
1399-
address: {Balance: funds},
1400-
aa: {
1401-
Code: aaCode,
1402-
Nonce: 1,
1403-
Balance: big.NewInt(0),
1404-
},
1405-
bb: {
1406-
Code: bbCode,
1407-
Nonce: 1,
1408-
Balance: big.NewInt(0),
1409-
},
1410-
},
1411-
}
1412-
txHashs := make([]common.Hash, 0, 2)
1413-
backend := newTestBackend(t, 1, genesis, func(i int, b *core.BlockGen) {
1414-
b.SetCoinbase(common.Address{1})
1415-
// first tx to aa
1416-
tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{
1417-
Nonce: 0,
1418-
To: &aa,
1419-
Value: big.NewInt(0),
1420-
Gas: 50000,
1421-
GasPrice: b.BaseFee(),
1422-
Data: nil,
1423-
}), types.HomesteadSigner{}, key)
1424-
b.AddTx(tx)
1425-
txHashs = append(txHashs, tx.Hash())
1426-
// second tx to bb
1427-
tx, _ = types.SignTx(types.NewTx(&types.LegacyTx{
1428-
Nonce: 1,
1429-
To: &bb,
1430-
Value: big.NewInt(1),
1431-
Gas: 100000,
1432-
GasPrice: b.BaseFee(),
1433-
Data: nil,
1434-
}), types.HomesteadSigner{}, key)
1435-
b.AddTx(tx)
1436-
txHashs = append(txHashs, tx.Hash())
1437-
})
1438-
defer backend.chain.Stop()
1439-
1440-
var testSuite = []struct {
1441-
blockNumber rpc.BlockNumber
1442-
config *StdTraceConfig
1443-
want []string
1444-
}{
1445-
{
1446-
// test that all traces in the block were outputted if no trace config is specified
1447-
blockNumber: rpc.LatestBlockNumber,
1448-
config: nil,
1449-
want: []string{
1450-
`{"pc":0,"op":96,"gas":"0x7148","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH1"}
1451-
{"pc":2,"op":80,"gas":"0x7145","gasCost":"0x2","memSize":0,"stack":["0x0"],"depth":1,"refund":0,"opName":"POP"}
1452-
{"pc":3,"op":0,"gas":"0x7143","gasCost":"0x0","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"STOP"}
1453-
{"output":"","gasUsed":"0x5"}
1454-
`,
1455-
`{"pc":0,"op":97,"gas":"0x13498","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH2"}
1456-
{"pc":3,"op":80,"gas":"0x13495","gasCost":"0x2","memSize":0,"stack":["0x1"],"depth":1,"refund":0,"opName":"POP"}
1457-
{"pc":4,"op":0,"gas":"0x13493","gasCost":"0x0","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"STOP"}
1458-
{"output":"","gasUsed":"0x5"}
1459-
`,
1460-
},
1461-
},
1462-
{
1463-
// test that only a specific tx is traced if specified
1464-
blockNumber: rpc.LatestBlockNumber,
1465-
config: &StdTraceConfig{TxHash: txHashs[1]},
1466-
want: []string{
1467-
`{"pc":0,"op":97,"gas":"0x13498","gasCost":"0x3","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"PUSH2"}
1468-
{"pc":3,"op":80,"gas":"0x13495","gasCost":"0x2","memSize":0,"stack":["0x1"],"depth":1,"refund":0,"opName":"POP"}
1469-
{"pc":4,"op":0,"gas":"0x13493","gasCost":"0x0","memSize":0,"stack":[],"depth":1,"refund":0,"opName":"STOP"}
1470-
{"output":"","gasUsed":"0x5"}
1471-
`,
1472-
},
1473-
},
1474-
}
1475-
1476-
api := NewAPI(backend)
1477-
for i, tc := range testSuite {
1478-
block, _ := api.blockByNumber(context.Background(), tc.blockNumber)
1479-
txTraces, err := api.StandardTraceBlockToFile(context.Background(), block.Hash(), tc.config)
1480-
if err != nil {
1481-
t.Fatalf("test index %d received error %v", i, err)
1482-
}
1483-
for j, traceFileName := range txTraces {
1484-
traceReceived, err := os.ReadFile(traceFileName)
1485-
if err != nil {
1486-
t.Fatalf("could not read trace file: %v", err)
1487-
}
1488-
if tc.want[j] != string(traceReceived) {
1489-
t.Fatalf("unexpected trace result. expected\n'%s'\n\nreceived\n'%s'\n", tc.want[j], string(traceReceived))
1490-
}
1491-
}
1492-
}
1493-
}

0 commit comments

Comments
 (0)