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
Action
must be one of 7 supported operations on the networkCreateAccount
to make a new account (for a person, company, contract, car, refrigerator, etc)DeployContract
to deploy a new contract (with its own account)FunctionCall
to invoke a method on a contract (with budget for compute and storage)Transfer
to transfer tokens from one account to anotherStake
to express interest in becoming a proof-of-stake validator at the next available opportunityAddKey
to add a key to an existing account (eitherFullAccess
orFunctionCall
access)DeleteKey
to delete an existing key from an accountDeleteAccount
to delete an account (and transfer balance to a beneficiary account)
a
Transaction
is a collection ofAction
s augmented with critical information about their- origin (ie. cryptographically signed by
signer
) - destination or intention (ie. sent or applied to
receiver
) - recency (ie.
block_hash
distance from most recent block is within acceptable limits) - uniqueness (ie.
nonce
must be unique for a givensigner
)
- origin (ie. cryptographically signed by
a
SignedTransaction
is aTransaction
cryptographically signed by thesigner
account mentioned aboveReceipt
s are basically what NEAR callsAction
s 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, aReceipt
is anAction
ready for processing on the blockchain.since, by design, each
Account
lives on one and only one shard in the system,Receipt
s are either applied to the shard on which they first appear or are routed across the network to the proper "home shard" for their respectivesender
andreceiver
accounts.DeleteKey
is anAction
that would never need to be routed to more than 1 shard whileTransfer
would always be routed to more than 1 shard unless bothsigner
andreceiver
happen 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