Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
fix nil pointers in lazy tx
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonche committed Oct 4, 2023
1 parent 3903dab commit 2c0460c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion eth/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (h *handler) syncTransactions(p *eth.Peer) {
for _, batch := range h.txpool.Pending(false) {
for _, tx := range batch {
// don't share any transactions marked as private
if !h.txpool.IsPrivateTxHash(tx.Tx.Hash()) {
if !h.txpool.IsPrivateTxHash(tx.Hash) {
hashes = append(hashes, tx.Hash)
}
}
Expand Down
4 changes: 2 additions & 2 deletions miner/algo_greedy.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (b *greedyBuilder) mergeOrdersIntoEnvDiff(
break
}

if tx := order.Tx(); tx != nil {
if tx := order.Tx(); tx != nil && tx.Resolve() != nil {
receipt, skip, err := envDiff.commitTx(tx.Tx, b.chainData)
switch skip {
case shiftTx:
Expand All @@ -65,7 +65,7 @@ func (b *greedyBuilder) mergeOrdersIntoEnvDiff(
}

if err != nil {
log.Trace("could not apply tx", "hash", tx.Tx.Hash(), "err", err)
log.Trace("could not apply tx", "hash", tx.Hash, "err", err)
continue
}
effGapPrice, err := tx.Tx.EffectiveGasTip(envDiff.baseEnvironment.header.BaseFee)
Expand Down
4 changes: 2 additions & 2 deletions miner/algo_greedy_multisnap.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func (b *greedyMultiSnapBuilder) buildBlock(simBundles []types.SimulatedBundle,
return b.inputEnvironment, usedBundles, usedSbundles
}

if tx := order.Tx(); tx != nil {
receipt, skip, err := changes.commitTx(tx.Resolve(), b.chainData)
if tx := order.Tx(); tx != nil && tx.Resolve() != nil {
receipt, skip, err := changes.commitTx(tx.Tx, b.chainData)
switch skip {
case shiftTx:
orders.Shift()
Expand Down
2 changes: 1 addition & 1 deletion miner/ordering.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (t *txWithMinerFee) Price() *big.Int {
}

func (t *txWithMinerFee) Profit(baseFee *big.Int, gasUsed uint64) *big.Int {
if tx := t.Tx(); tx != nil {
if tx := t.Tx(); tx != nil && tx.Resolve() != nil {
profit := new(big.Int).Sub(tx.Tx.GasPrice(), baseFee)
if gasUsed != 0 {
profit.Mul(profit, new(big.Int).SetUint64(gasUsed))
Expand Down
2 changes: 1 addition & 1 deletion miner/stress/clique/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func main() {

// makeGenesis creates a custom Clique genesis block based on some pre-defined
// signer and faucet accounts.
func makeGenesis(faucets []*ecdsa.PrivateKey, sealers []*ecdsa.PrivateKey) *core.Genesis {
func makeGenesis(faucets, sealers []*ecdsa.PrivateKey) *core.Genesis {
// Create a Clique network based off of the Sepolia config
genesis := core.DefaultSepoliaGenesisBlock()
genesis.GasLimit = 25000000
Expand Down
10 changes: 5 additions & 5 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,13 +1041,13 @@ func (w *worker) commitTransactions(env *environment, txs *transactionsByPriceAn
// Check whether the tx is replay protected. If we're not in the EIP155 hf
// phase, start ignoring the sender until we do.
if tx.Tx.Protected() && !w.chainConfig.IsEIP155(env.header.Number) {
log.Trace("Ignoring replay protected transaction", "hash", tx.Tx.Hash(), "eip155", w.chainConfig.EIP155Block)
log.Trace("Ignoring replay protected transaction", "hash", tx.Hash, "eip155", w.chainConfig.EIP155Block)
txs.Pop()
continue
}

// Start executing the transaction
env.state.SetTxContext(tx.Tx.Hash(), env.tcount)
env.state.SetTxContext(tx.Hash, env.tcount)

logs, err := w.commitTransaction(env, tx.Tx)
switch {
Expand All @@ -1065,7 +1065,7 @@ func (w *worker) commitTransactions(env *environment, txs *transactionsByPriceAn
default:
// Transaction is regarded as invalid, drop all consecutive transactions from
// the same sender because of `nonce-too-high` clause.
log.Debug("Transaction failed, account skipped", "hash", tx.Tx.Hash(), "err", err)
log.Debug("Transaction failed, account skipped", "hash", tx.Hash, "err", err)
txs.Pop()
}
}
Expand Down Expand Up @@ -1228,7 +1228,7 @@ func (w *worker) fillTransactions(interrupt *atomic.Int32, env *environment) ([]
mempoolTxHashes := make(map[common.Hash]struct{}, len(pending))
for _, txs := range pending {
for _, tx := range txs {
mempoolTxHashes[tx.Tx.Hash()] = struct{}{}
mempoolTxHashes[tx.Hash] = struct{}{}
}
}

Expand Down Expand Up @@ -1298,7 +1298,7 @@ func (w *worker) fillTransactionsAlgoWorker(interrupt *atomic.Int32, env *enviro
mempoolTxHashes := make(map[common.Hash]struct{}, len(pending))
for _, txs := range pending {
for _, tx := range txs {
mempoolTxHashes[tx.Tx.Hash()] = struct{}{}
mempoolTxHashes[tx.Hash] = struct{}{}
}
}
bundlesToConsider, sbundlesToConsider, err := w.getSimulatedBundles(env)
Expand Down

0 comments on commit 2c0460c

Please sign in to comment.