Blockchain Transaction Manager Study Guide
Glossary of Key Terms
A blockchain is a growing list of records (called blocks) that are linked and secured using cryptography. Each block typically contains a cryptographic hash of the previous block, a timestamp, and transaction data. Blockchains are designed to be fundamentally resistant to modification of transaction data. To be used as a distributed ledger, a blockchain is typically managed by a peer-to-peer network that collectively adheres to a protocol for validating new blocks. Once recorded, the data in any given block cannot be altered retroactively without altering all subsequent blocks, which requires collusion by a majority of the network. Smart contracts provide computer protocols for general computations that occur on a blockchain or distributed ledger. Smart contract transactions may be simple or implement complex logic. The resulting transactions are typically transparent, traceable, and irreversible to the ledger participants. Various distributed ledger technology platforms, such as Ethereum, have implemented types of smart contracts. In Ethereum, smart contracts are high-level programming abstractions that are compiled into bytecode and deployed to the Ethereum blockchain for execution. Node.js® A free, open-source server environment for executing JavaScript code outside of a browser. Node.js® is an asynchronous programming platform built on top of the Chrome browser JavaScript runtime. Ether The internal cryptocurrency of the Ethereum blockchain platform. One use of this currency is to compensate miners for work they do on behalf of the network. Miner An entity that evaluates blockchain transactions and performs computations that collectively maintain the integrity of the blockchain data within its network. Submitter A blockchain network identity associated with a transaction, whose identity credentials are used to digitally sign the transaction, and whose cryptocurrency account is debited for fees. Sent/Sent The initial communication (or attempt) of a transaction to a neighboring node in the blockchain network. Rejected The transaction was rejected during initial communication with a neighboring node in the blockchain network due to an error. Pending The transaction was accepted during initial communication, has been placed in a list of pending transactions and is being broadcast to other blockchain network nodes, but is not yet known to have been mined. Mined The transaction has been evaluated, included in a block, and attached to the blockchain (at least from the perspective of a given node). A transaction may have succeeded or failed. Receipt A piece of data from a neighboring node in the blockchain network indicating that a transaction is known to have been mined, including information about success or failure. ("Receipt" is a term used by the popular web3 software library used with Ethereum nodes.) A successfully mined transaction was fully executed without error when mined. A failed mined transaction was mined with an error, was not fully executed, and has no effect other than logging the failure details to a block and deducting a fee for the attempt from the submitter's cryptocurrency account. Failure can occur for a number of reasons, some of which are described in this document. Completed A transaction whose block is extremely unlikely to be replaced in the blockchain because another part of the blockchain network was found to have made more progress in confirming the transaction. There is no formal specification for determining this, but it is usually based on the number of blocks subsequently appended. Simple transactions contain no blockchain transactions for new smart contracts. Contract transactions contain blockchain transactions for new smart contracts. Gas is a standardized number of proxy units used to estimate the sum of the computational and storage costs that an Ethereum-like blockchain network would incur if a given transaction were processed, which becomes the basis for charging transaction submitters. "Gas" is both a proxy unit and a term for such an estimated total. Startgas transactions senders indicate the maximum number of proxy units of computation and storage they are willing to pay for a proposed transaction. (This is web3 library terminology; the Ethereum Yellow Paper calls it the "gas limit.") Gasprice The amount the transaction submitter is willing to pay for the account to mine the transaction, expressed in cryptocurrency fees per unit of gas consumed during the processing of that transaction. Intrinsicgas The gas that a transaction will use before any smart contract code executes. It includes the base transaction gas fee plus the gas fees for any data provided as transaction parameters. (The latter is calculated because the input parameters are recorded to the blockchain even if the transaction fails.) Nonce All discussion of nonces in this article relates to the sequential numbers required for submitters' transactions on Ethereum and similar blockchain platforms. They are assigned by the submitter, but in practice submitters typically delegate this to supporting code libraries associated with the blockchain network. Ethereum-like networks will attempt to process transactions in nonce number order, which may cause transaction delays or failures for a variety of reasons. Transactions with values lower or much higher than those already processed will simply fail. Missing values in the sequence will cause transactions with subsequent nonces to be ignored until the gap in the sequence is filled. Block gas limit When miners on the network select pending transactions to mine into a single block, this is the maximum value that the sum of startgas for all selected transactions is allowed to be. Each Ethereum network, or network based on a platform with a similar miner compensation mechanism, has its own limit, which increases or decreases by a small amount after each new block is appended. Nonce window The highest nonce value a transaction may have and still be accepted by a node, expressed as a delta above the nonce of the last transaction that the node sent to the blockchain network for a given submitter identity. The nonce window works by limiting the number of transactions that a node per identity can broadcast. The nonce window can be configured for each node in a blockchain network. Neighboring nodes The nodes in a blockchain network that a user or application communicates with most directly in order to interact with the blockchain network as a whole.
Short answer questions
What challenges does the blockchain transaction pipeline face? The blockchain transaction pipeline faces many challenges, such as the delay between transaction submission and its acceptance into the shared ledger, and rejections that occur due to the transaction "nonce" numbering problem in Ethereum.
How do blockchain transaction managers solve the problem of synchronously waiting for transactions to be mined or finalized? The blockchain transaction manager solves this problem by using a robust pipeline of queued transactions and then polling the network to track transaction success or failure. This allows user applications to submit transactions without waiting for final confirmation.
What is a "nonce" and why is it important in blockchain transaction management? A "nonce" is a sequence number associated with Ethereum transactions. It prevents double spending and ensures that transactions are processed in order.
How does the blockchain transaction manager handle the "nonce gap"? The blockchain transaction manager minimizes nonce-related challenges by methodically and automatically assigning nonces. If a transaction is rejected, it immediately writes its nonce to a list in a memory cache for the next transaction to use.
How does the blockchain transaction manager determine the gas price for a transaction? The blockchain transaction manager calculates the gas price based on the gas prices of transactions that have recently been accepted in the network.
Describe the retry approach that the blockchain transaction manager takes to handle transaction preparation and sending. The blockchain transaction manager divides transactions into two phases in the process of sending transactions to the blockchain network: transaction preparation and sending. If problems are encountered in either phase, the system simply retries the process, up to a configurable number of times each.
How does the blockchain transaction manager handle transactions that are rejected by blockchain nodes? For rejected transactions, the blockchain transaction manager first resolves the nonce issue by adding the transaction's nonce to the pool of available nonces, and then attempts to resolve the cause of the rejection by adjusting properties such as the gas limit.
Explain the two status polling methods employed by the blockchain transaction manager. The blockchain transaction manager uses two separate status polling methods: one is intensive polling, which is used to frequently check the status of a transaction during the initial period after it is sent to a node; the other is a slower scheduler-based method that is used to track transactions over a long period of time.
How does the blockchain transaction manager handle database failures if they occur at different stages of the transaction lifecycle? The blockchain transaction manager handles database failures in different ways, depending on where in the transaction lifecycle the failure occurs. In most cases, this involves writing the transaction to an error table or temporarily writing the information elsewhere until the database is available.
How does the blockchain transaction manager support batched transaction processing? The ability to process and monitor transactions asynchronously enables the blockchain transaction manager to support batched submission of transactions by client applications.