Skip to content

Commit

Permalink
WriteFailedReceipt removed (#1403)
Browse files Browse the repository at this point in the history
* WriteFailedReceipt removed
Co-authored-by: Stefan Negovanović <93934272+Stefan-Ethernal@users.noreply.github.com>
  • Loading branch information
Nemanja0x committed Apr 24, 2023
1 parent 989978d commit 6427e8c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 48 deletions.
10 changes: 0 additions & 10 deletions consensus/ibft/consensus_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ type txExeResult struct {

type transitionInterface interface {
Write(txn *types.Transaction) error
WriteFailedReceipt(txn *types.Transaction) error
}

func (i *backendIBFT) writeTransactions(
Expand Down Expand Up @@ -382,15 +381,6 @@ func (i *backendIBFT) writeTransaction(
if tx.ExceedsBlockGasLimit(gasLimit) {
i.txpool.Drop(tx)

if err := transition.WriteFailedReceipt(tx); err != nil {
i.logger.Error(
fmt.Sprintf(
"unable to write failed receipt for transaction %s",
tx.Hash,
),
)
}

// continue processing
return &txExeResult{tx, fail}, true
}
Expand Down
5 changes: 2 additions & 3 deletions consensus/polybft/block_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ func (b *BlockBuilder) Build(handler func(h *types.Header)) (*types.FullBlock, e
// WriteTx applies given transaction to the state. If transaction apply fails, it reverts the saved snapshot.
func (b *BlockBuilder) WriteTx(tx *types.Transaction) error {
if tx.ExceedsBlockGasLimit(b.params.GasLimit) {
if err := b.state.WriteFailedReceipt(tx); err != nil {
return err
}
b.params.Logger.Info("Transaction gas limit exceedes block gas limit", "hash", tx.Hash,
"tx gas limit", tx.Gas, "block gas limt", b.params.GasLimit)

return txpool.ErrBlockLimitExceeded
}
Expand Down
35 changes: 0 additions & 35 deletions state/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ func (e *Executor) ProcessBlock(

for _, t := range block.Transactions {
if t.ExceedsBlockGasLimit(block.Header.GasLimit) {
if err := txn.WriteFailedReceipt(t); err != nil {
return nil, err
}

continue
}

Expand Down Expand Up @@ -309,37 +305,6 @@ func (t *Transition) Receipts() []*types.Receipt {

var emptyFrom = types.Address{}

func (t *Transition) WriteFailedReceipt(txn *types.Transaction) error {
signer := crypto.NewSigner(t.config, uint64(t.ctx.ChainID))

if txn.From == emptyFrom && txn.Type == types.LegacyTx {
// Decrypt the from address
from, err := signer.Sender(txn)
if err != nil {
return NewTransitionApplicationError(err, false)
}

txn.From = from
}

receipt := &types.Receipt{
CumulativeGasUsed: t.totalGas,
TransactionType: txn.Type,
TxHash: txn.Hash,
Logs: t.state.Logs(),
}

receipt.LogsBloom = types.CreateBloom([]*types.Receipt{receipt})
receipt.SetStatus(types.ReceiptFailed)
t.receipts = append(t.receipts, receipt)

if txn.To == nil {
receipt.ContractAddress = crypto.CreateAddress(txn.From, txn.Nonce).Ptr()
}

return nil
}

// Write writes another transaction to the executor
func (t *Transition) Write(txn *types.Transaction) error {
var err error
Expand Down

0 comments on commit 6427e8c

Please sign in to comment.