After reading more about how transactions are processed by NEAR I came up with this picture of how a few key parts are related.
I am seeking some pointers on how to correct this.
First a few key points I'm currently aware of, only some of which are illustrated below, are:
an
Actionmust be one of 7 supported operations on the networkCreateAccountto make a new account (for a person, company, contract, car, refrigerator, etc)DeployContractto deploy a new contract (with its own account)FunctionCallto invoke a method on a contract (with budget for compute and storage)Transferto transfer tokens from one account to anotherStaketo express interest in becoming a proof-of-stake validator at the next available opportunityAddKeyto add a key to an existing account (eitherFullAccessorFunctionCallaccess)DeleteKeyto delete an existing key from an accountDeleteAccountto delete an account (and transfer balance to a beneficiary account)
a
Transactionis a collection ofActions augmented with critical information about their- origin (ie. cryptographically signed by
signer) - destination or intention (ie. sent or applied to
receiver) - recency (ie.
block_hashdistance from most recent block is within acceptable limits) - uniqueness (ie.
noncemust be unique for a givensigner)
- origin (ie. cryptographically signed by
a
SignedTransactionis aTransactioncryptographically signed by thesigneraccount mentioned aboveReceipts are basically what NEAR callsActions after they pass from outside (untrusted) to inside (trusted) the "boundary of trust" of our network. Having been cryptographically verified as valid, recent and unique, aReceiptis anActionready for processing on the blockchain.since, by design, each
Accountlives on one and only one shard in the system,Receipts are either applied to the shard on which they first appear or are routed across the network to the proper "home shard" for their respectivesenderandreceiveraccounts.DeleteKeyis anActionthat would never need to be routed to more than 1 shard whileTransferwould always be routed to more than 1 shard unless bothsignerandreceiverhappen to have the same "home shard"a "finality gadget" is a collection of rules that balances the urgency of maximizing blockchain "liveness" (ie. responsiveness / performance) with the safety needed to minimize the risk of accepting invalid transactions onto the blockchain. One of these rules includes "waiting for a while" before finalizing (or sometimes reversing) transactions -- this amounts to waiting a few minutes for 120 blocks to be processed before confirming that a transaction has been "finalized".
---.
o--------o | o------------------------o o-------------------o
| Action | | | Transaction | | SignedTransaction |
o--------o | | | | |
| | o--------o | | o-------------o |
o--------o | | | Action | signer | | | Transaction | |
| Action | | --> | o--------o receiver | --> | | | | ---.
o--------o | | | Action | block_hash | | | | | |
| | o--------o nonce | | | | | |
o--------o | | | Action | | | | | | |
| Action | | | o--------o | | o-------------o | |
o--------o | o------------------------o o-------------------o |
---' |
|
sent to network |
.---------------------------------------------------------------------------'
| <----------
|
| ---.
| XXX o--------o o---------o |
| XX | Action | --> | Receipt | |
| o--------------------------------o o--------o o---------o |
| | | |
| | 1. Validation (block_hash) | o--------o o---------o |
'--> | 2. Verification (signer keys) | | Action | --> | Receipt | | --.
| 3. Routing (receiver) | o--------o o---------o | |
| | | |
o--------------------------------o o--------o o---------o | |
transaction arrives XX | Action | --> | Receipt | | |
XXX o--------o o---------o | |
---' |
|
applied locally OR propagated to other shards |
.---------------------------------------------------------------------------'
| <----------
|
|
| --. .-------. .--. .--. .--. o-----------o
| o---------o | | | | | | | | | | |
'--> | Receipt | | Shard | | | | | | | | | |
o---------o | A | | | | | | | | | |
| --' | | | | | | | | | |
| | | | | | | | | | |
| --. | | | | | | | | | Block |
| o---------o | | Block | | | | | o o o | | | (i) |
'--> | Receipt | | | (i) | | | | | | | | finalized |
o---------o | | | | | | | | | | |
| | Shard | | | | | | | | | |
| o---------o | B | | | | | | | | | |
'--> | Receipt | | | | | | | | | | | |
o---------o | | | | | | | | | | |
--' '-------' '--' '--' '--' o-----------o
| |
'------------------------------------------------'
about 3 blocks to finality