diff --git a/gossip/c_block_callbacks.go b/gossip/c_block_callbacks.go index cf026f043..d4fe3fea2 100644 --- a/gossip/c_block_callbacks.go +++ b/gossip/c_block_callbacks.go @@ -319,6 +319,7 @@ func consensusCallbackBeginBlockFn( for _, e := range blockEvents { txs = append(txs, e.Txs()...) } + _ = evmProcessor.Execute(txs) evmBlock, skippedTxs, allReceipts := evmProcessor.Finalize() @@ -343,16 +344,18 @@ func consensusCallbackBeginBlockFn( } } } + // memorize block position of each tx + for i, tx := range evmBlock.Transactions { + // not skipped txs only + position := txPositions[tx.Hash()] + position.Block = blockCtx.Idx + position.BlockOffset = uint32(i) + txPositions[tx.Hash()] = position + } + // call OnNewReceipt for i, r := range allReceipts { - // memorize block position for not skipped txs only - position := txPositions[r.TxHash] - position.Block = blockCtx.Idx - position.BlockOffset = uint32(r.TransactionIndex) - txPositions[r.TxHash] = position - // call OnNewReceipt - creator := position.EventCreator - // TODO: is it check necessary? + creator := txPositions[r.TxHash].EventCreator if creator != 0 && es.Validators.Get(creator) == 0 { creator = 0 } diff --git a/gossip/txposition_test.go b/gossip/txposition_test.go index 8651d2ae3..683e36d76 100644 --- a/gossip/txposition_test.go +++ b/gossip/txposition_test.go @@ -95,7 +95,7 @@ func TestTxIndexing(t *testing.T) { t.Fatal("skipped tx's receipt found") case tx4ok.Hash(): require.Equal(types.ReceiptStatusSuccessful, r.Status, i) - require.Equal(txPos.BlockOffset, uint32(3)) // THAT shows the effect of the fix #524 + require.Equal(txPos.BlockOffset, uint32(2)) // skipped txs aren't counted } for j, l := range r.Logs {