Skip to content

Commit fbce2fb

Browse files
merge fixes
1 parent d8c4b0e commit fbce2fb

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

core/state/intra_block_state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ func (sdb *IntraBlockState) createObject(addr libcommon.Address, previous *state
641641
sdb.journal.append(resetObjectChange{account: &addr, prev: previous})
642642
}
643643

644-
if sdb.logger != nil && sdb.logger.OnNewAccount != nil {
645-
sdb.logger.OnNewAccount(addr, previous != nil)
644+
if sdb.tracingHooks != nil && sdb.tracingHooks.OnNewAccount != nil {
645+
sdb.tracingHooks.OnNewAccount(addr, previous != nil)
646646
}
647647

648648
newobj.newlyCreated = true

eth/tracers/internal/tracetest/firehose/blockchain_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/erigontech/erigon-lib/common"
8+
"github.com/erigontech/erigon-lib/common/datadir"
89
"github.com/erigontech/erigon-lib/log/v3"
910
"github.com/erigontech/erigon/core"
1011
"github.com/erigontech/erigon/core/state"
@@ -34,10 +35,10 @@ func runPrestateBlock(t *testing.T, prestatePath string, hooks *tracing.Hooks) {
3435
dbTx, err := m.DB.BeginRw(m.Ctx)
3536
require.NoError(t, err)
3637
defer dbTx.Rollback()
37-
stateDB, _ := tests.MakePreState(rules, dbTx, prestate.Genesis.Alloc, uint64(context.BlockNumber), m.HistoryV3)
38+
stateDB, _ := tests.MakePreState(rules, dbTx, prestate.Genesis.Alloc, context.BlockNumber)
3839

3940
var logger = log.New("test")
40-
genesisBlock, _, err := core.GenesisToBlock(prestate.Genesis, "", logger, nil)
41+
genesisBlock, _, err := core.GenesisToBlock(prestate.Genesis, datadir.New(""), logger)
4142
require.NoError(t, err)
4243

4344
block := types.NewBlock(&types.Header{
@@ -49,10 +50,10 @@ func runPrestateBlock(t *testing.T, prestatePath string, hooks *tracing.Hooks) {
4950
GasLimit: context.GasLimit,
5051
BaseFee: context.BaseFee.ToBig(),
5152
ParentBeaconBlockRoot: ptr(common.Hash{}),
52-
}, []types.Transaction{tx}, nil, nil, nil, nil)
53+
}, []types.Transaction{tx}, nil, nil, nil)
5354

54-
stateDB.SetLogger(hooks)
55-
stateDB.SetTxContext(tx.Hash(), block.Hash(), 0)
55+
stateDB.SetHooks(hooks)
56+
stateDB.SetTxContext(0)
5657

5758
hooks.OnBlockchainInit(prestate.Genesis.Config)
5859
hooks.OnBlockStart(tracing.BlockEvent{

eth/tracers/internal/tracetest/firehose/prestate_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
"testing"
88

99
"github.com/erigontech/erigon-lib/common"
10+
"github.com/erigontech/erigon-lib/common/datadir"
11+
"github.com/erigontech/erigon-lib/common/math"
1012
"github.com/erigontech/erigon-lib/log/v3"
11-
"github.com/erigontech/erigon/common/math"
1213
"github.com/erigontech/erigon/consensus"
1314
"github.com/erigontech/erigon/consensus/ethash"
1415
"github.com/erigontech/erigon/core"
@@ -66,7 +67,7 @@ func (p *prestateData) GetHeader(hash common.Hash, number uint64) (*types.Header
6667
}
6768

6869
if p.genesisBlock == nil {
69-
p.genesisBlock, _, err = core.GenesisToBlock(p.Genesis, "", logger, nil)
70+
p.genesisBlock, _, err = core.GenesisToBlock(p.Genesis, datadir.New(""), logger)
7071
if err != nil {
7172
return nil, err
7273
}

eth/tracers/live/firehose.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ import (
2222

2323
"github.com/erigontech/erigon-lib/chain"
2424
libcommon "github.com/erigontech/erigon-lib/common"
25+
"github.com/erigontech/erigon-lib/common/math"
26+
"github.com/erigontech/erigon-lib/crypto"
2527
"github.com/erigontech/erigon-lib/log/v3"
26-
types2 "github.com/erigontech/erigon-lib/types"
27-
2828
"github.com/erigontech/erigon/common"
29-
"github.com/erigontech/erigon/common/math"
3029
"github.com/erigontech/erigon/core/tracing"
3130
"github.com/erigontech/erigon/core/types"
3231
"github.com/erigontech/erigon/core/vm"
33-
"github.com/erigontech/erigon/crypto"
3432
"github.com/erigontech/erigon/eth/tracers"
3533
"github.com/erigontech/erigon/params"
3634
pbeth "github.com/erigontech/erigon/pb/sf/ethereum/type/v2"
@@ -1435,7 +1433,7 @@ func (f *Firehose) panicInvalidState(msg string, callerSkip int) string {
14351433
}
14361434

14371435
if f.transaction != nil {
1438-
msg += fmt.Sprintf(" in transaction %s", hex.EncodeToString(f.transaction.Hash))
1436+
msg += " in transaction " + hex.EncodeToString(f.transaction.Hash)
14391437
}
14401438

14411439
panic(fmt.Errorf("%s (caller=%s, init=%t, inBlock=%t, inTransaction=%t, inCall=%t)", msg, caller, f.chainConfig != nil, f.block != nil, f.transaction != nil, f.callStack.HasActiveCall()))
@@ -1681,7 +1679,7 @@ func newTxReceiptFromChain(receipt *types.Receipt, txType pbeth.TransactionTrace
16811679
return out
16821680
}
16831681

1684-
func newAccessListFromChain(accessList types2.AccessList) (out []*pbeth.AccessTuple) {
1682+
func newAccessListFromChain(accessList types.AccessList) (out []*pbeth.AccessTuple) {
16851683
if len(accessList) == 0 {
16861684
return nil
16871685
}
@@ -1927,7 +1925,7 @@ func (s *CallStack) NextIndex() uint32 {
19271925

19281926
func (s *CallStack) Pop() (out *pbeth.Call) {
19291927
if len(s.stack) == 0 {
1930-
panic(fmt.Errorf("pop from empty call stack"))
1928+
panic(errors.New("pop from empty call stack"))
19311929
}
19321930

19331931
out = s.stack[len(s.stack)-1]
@@ -2180,7 +2178,7 @@ func validateFirehoseKnownTransactionType(txType byte, isKnownFirehoseTxType boo
21802178
if err != nil {
21812179
if err == types.ErrTxTypeNotSupported {
21822180
if isKnownFirehoseTxType {
2183-
return fmt.Errorf("firehose known type but encoding RLP of receipt led to 'types.ErrTxTypeNotSupported'")
2181+
return errors.New("firehose known type but encoding RLP of receipt led to 'types.ErrTxTypeNotSupported'")
21842182
}
21852183

21862184
// It's not a known type and encoding reported the same, so validation is OK
@@ -2197,7 +2195,7 @@ func validateFirehoseKnownTransactionType(txType byte, isKnownFirehoseTxType boo
21972195
if err != nil {
21982196
if err == types.ErrTxTypeNotSupported {
21992197
if isKnownFirehoseTxType {
2200-
return fmt.Errorf("firehose known type but decoding of RLP of receipt led to 'types.ErrTxTypeNotSupported'")
2198+
return errors.New("firehose known type but decoding of RLP of receipt led to 'types.ErrTxTypeNotSupported'")
22012199
}
22022200

22032201
// It's not a known type and decoding reported the same, so validation is OK
@@ -2235,7 +2233,7 @@ func validateAddressField(into *validationResult, field string, a, b libcommon.A
22352233
}
22362234

22372235
func validateBigIntField(into *validationResult, field string, a, b *big.Int) {
2238-
equal := false
2236+
var equal bool
22392237
if a == nil && b == nil {
22402238
equal = true
22412239
} else if a == nil || b == nil {

eth/tracers/live/firehose_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func blockEvent(height uint64) tracing.BlockEvent {
448448
return tracing.BlockEvent{
449449
Block: types.NewBlock(&types.Header{
450450
Number: b(int64(height)),
451-
}, nil, nil, nil, nil, nil),
451+
}, nil, nil, nil, nil),
452452
TD: b(1),
453453
}
454454
}

0 commit comments

Comments
 (0)