0

I am trying to learn more about txpool and at what state transactions in it are in the overall lifecycle of an Ethereum transaction.

If I have a transaction that is going to call a smart contract, the transaction will have data that will be passed to the contract. This may alter the final state of a SC transaction, like slippage on a swap for example.

I'm trying to understand at what point that final swap value is fixed. Is it when the transaction reaches the txpool, or when the smart contract byte code is executed.

Does this relate to pending and queued transactions in the txpool?

1 Answer 1

1

Basically the state changes are being calculated when your transaction is selected to be picked in a block. Let's say you calculate the state changes at block X and the best way to meet your calculations is your transaction to be 1st in the X + 1 block. You can achive this manipulation by twitching the gas price.

For the difference between ququed and pending check this answer: What is the difference between a pending transaction and a queued transaction?

What is the difference between a pending transaction and a queued

transaction? Pending transactions are transactions that are ready to be processed and included in the block.

Queued transactions are transactions where the transaction nonce is not in sequence. The transaction nonce is an incrementing number for each transaction with the same From address.

For example:

Transaction from account 0xaaaa...aaaa with nonce 0 has been included in the blockchain. Transaction from account 0xaaaa...aaaa with nonce 1 has been included in the blockchain. 10 transactions from account 0xaaaa...aaaa with nonces 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 as sent to an Ethereum node. These are placed in the transaction queue as the transaction from account 0xaaaa...aaaa with nonce 2 has not been seen by the Ethereum node. Once the transaction from account 0xaaaa...aaaa with nonce 2 is added to the transaction pool, the 10 transactions with nonces 3, 4, 5, 6, 7, 8, 9, 10, 11 and 12 will be moved from the queue to the pending transaction pool and all 11 transactions are ready to be processed and inserted into into the blockchain (provided there is enough gas).

2
  • So a pending transaction that is in the txpool, which may be calling functions of a smart contract, which will result in a value being set i.e. swap rate for a token. In the txpool this smart contract function has not yet run?
    – elgringo
    Mar 20, 2022 at 16:19
  • yes, it will run and affect the Ethereum state once it is included in block Mar 21, 2022 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.