private void Execute(BlockReceiptsTracer tracer, Transaction tx, Block block) { tracer.StartNewBlockTrace(block); tracer.StartNewTxTrace(tx.Hash); _transactionProcessor.Execute(tx, block.Header, tracer); tracer.EndTxTrace(); }
public Keccak SendTransaction(Transaction transaction, bool doNotEvict = false) { transaction.Hash = Transaction.CalculateHash(transaction); _headBlock.Transactions[_txIndex++] = transaction; _receiptsTracer.StartNewTxTrace(transaction.Hash); _processor.Execute(transaction, Head, _receiptsTracer); _receiptsTracer.EndTxTrace(); return(Transaction.CalculateHash(transaction)); }
public Keccak SendTransaction(Transaction tx, TxHandlingOptions txHandlingOptions) { tx.Hash = tx.CalculateHash(); _headBlock.Transactions[_txIndex++] = tx; _receiptsTracer.StartNewTxTrace(tx.Hash); _processor.Execute(tx, Head, _receiptsTracer); _receiptsTracer.EndTxTrace(); return(tx.CalculateHash()); }
public ValueTask <Keccak> SendTransaction(Transaction tx, TxHandlingOptions txHandlingOptions) { tx.Nonce = GetNonce(tx.SenderAddress); tx.Hash = tx.CalculateHash(); _headBlock.Transactions[_txIndex++] = tx; _receiptsTracer.StartNewTxTrace(tx.Hash); _processor.Execute(tx, Head?.Header, _receiptsTracer); _receiptsTracer.EndTxTrace(); return(new ValueTask <Keccak>(tx.CalculateHash())); }
public void Sets_state_root_if_provided_on_failure() { Block block = Build.A.Block.WithTransactions(MuirGlacier.Instance, Build.A.Transaction.TestObject).TestObject; BlockReceiptsTracer tracer = new BlockReceiptsTracer(); tracer.SetOtherTracer(NullBlockTracer.Instance); tracer.StartNewBlockTrace(block); tracer.StartNewTxTrace(block.Transactions[0].Hash); tracer.MarkAsFailed(TestItem.AddressA, 100, new byte[0], "error", TestItem.KeccakF); Assert.AreEqual(TestItem.KeccakF, tracer.TxReceipts[0].PostTransactionState); }
public void Sets_state_root_if_provided_on_success() { Block block = Build.A.Block.WithTransactions(Build.A.Transaction.TestObject).TestObject; BlockReceiptsTracer tracer = new BlockReceiptsTracer(); tracer.SetOtherTracer(NullBlockTracer.Instance); tracer.StartNewBlockTrace(block); tracer.StartNewTxTrace(block.Transactions[0].Hash); tracer.MarkAsSuccess(TestItem.AddressA, 100, new byte[0], new LogEntry[0], TestItem.KeccakF); Assert.AreEqual(TestItem.KeccakF, tracer.TxReceipts[0].PostTransactionState); }
public void Invokes_other_tracer_mark_as_failed_if_other_block_tracer_is_tx_tracer_too() { Block block = Build.A.Block.WithTransactions(MuirGlacier.Instance, Build.A.Transaction.TestObject).TestObject; IBlockTracer otherTracer = Substitute.For <IBlockTracer, ITxTracer>(); BlockReceiptsTracer tracer = new BlockReceiptsTracer(); tracer.SetOtherTracer(otherTracer); tracer.StartNewBlockTrace(block); tracer.StartNewTxTrace(block.Transactions[0].Hash); tracer.MarkAsFailed(TestItem.AddressA, 100, Array.Empty <byte>(), "error", TestItem.KeccakF); (otherTracer as ITxTracer).Received().MarkAsFailed(TestItem.AddressA, 100, Array.Empty <byte>(), "error", TestItem.KeccakF); }
public void Invokes_other_tracer_mark_as_success_if_other_block_tracer_is_tx_tracer_too() { Block block = Build.A.Block.WithTransactions(Build.A.Transaction.TestObject).TestObject; IBlockTracer otherTracer = Substitute.For <IBlockTracer, ITxTracer>(); BlockReceiptsTracer tracer = new BlockReceiptsTracer(); tracer.SetOtherTracer(otherTracer); tracer.StartNewBlockTrace(block); tracer.StartNewTxTrace(block.Transactions[0].Hash); var logEntries = new LogEntry[0]; tracer.MarkAsSuccess(TestItem.AddressA, 100, Array.Empty <byte>(), logEntries, TestItem.KeccakF); (otherTracer as ITxTracer).Received().MarkAsSuccess(TestItem.AddressA, 100, Array.Empty <byte>(), logEntries, TestItem.KeccakF); }
public static void ProcessTransaction(this ITransactionProcessorAdapter transactionProcessor, Block block, Transaction currentTx, BlockReceiptsTracer receiptsTracer, ProcessingOptions processingOptions, IStateProvider stateProvider) { if (processingOptions.ContainsFlag(ProcessingOptions.DoNotVerifyNonce)) { currentTx.Nonce = stateProvider.GetNonce(currentTx.SenderAddress); } receiptsTracer.StartNewTxTrace(currentTx); transactionProcessor.Execute(currentTx, block.Header, receiptsTracer); receiptsTracer.EndTxTrace(); }
private TxReceipt[] ProcessTransactions(Block block, ProcessingOptions processingOptions, IBlockTracer blockTracer) { _receiptsTracer.SetOtherTracer(blockTracer); _receiptsTracer.StartNewBlockTrace(block); for (int i = 0; i < block.Transactions.Length; i++) { Transaction currentTx = block.Transactions[i]; if ((processingOptions & ProcessingOptions.DoNotVerifyNonce) != 0) { currentTx.Nonce = _stateProvider.GetNonce(currentTx.SenderAddress); } _receiptsTracer.StartNewTxTrace(currentTx.Hash); _transactionProcessor.Execute(currentTx, block.Header, _receiptsTracer); _receiptsTracer.EndTxTrace(); TransactionProcessed?.Invoke(this, new TxProcessedEventArgs(i, currentTx, _receiptsTracer.TxReceipts[i])); } return(_receiptsTracer.TxReceipts); }
private TransactionReceipt[] ProcessTransactions(Block block, ProcessingOptions processingOptions, IBlockTracer blockTracer) { _receiptsTracer.SetOtherTracer(blockTracer); _receiptsTracer.StartNewBlockTrace(block); for (int i = 0; i < block.Transactions.Length; i++) { if (_logger.IsTrace) { _logger.Trace($"Processing transaction {i}"); } Transaction currentTx = block.Transactions[i]; _receiptsTracer.StartNewTxTrace(currentTx.Hash); _transactionProcessor.Execute(currentTx, block.Header, _receiptsTracer); _receiptsTracer.EndTxTrace(); if ((processingOptions & ProcessingOptions.ReadOnlyChain) == 0) { TransactionProcessed?.Invoke(this, new TransactionProcessedEventArgs(_receiptsTracer.TransactionReceipts[i])); } } return(_receiptsTracer.TransactionReceipts); }