Skip to content

Instantly share code, notes, and snippets.

@marklnichols
Created November 6, 2020 15:44
Show Gist options
  • Save marklnichols/65285ba5ce412ca6e05ae64dff732d3c to your computer and use it in GitHub Desktop.
Save marklnichols/65285ba5ce412ca6e05ae64dff732d3c to your computer and use it in GitHub Desktop.
Streamlet-api-notes
----------------------------------------------------------------------------------------------------
Nodes participating in the consensus:
----------------------------------------------------------------------------------------------------
n total nodes, with public keys, etc. known to all nodes
At most n/3 corrupt nodes (static list of corrupt nodes, does not change).
Corrupt nodes can deviate arbitrarily from the protocol, including delaying messages.
Each node maintains its own copy of the blockchain
----------------------------------------------------------------------------------------------------
Timing:
----------------------------------------------------------------------------------------------------
There is an "epoch" timer (assume 1 sec to start). Epocs are numbered.
"Good" network conditions are when honest nodes can exchange messages within a
rount-trip time of 1 epoch
----------------------------------------------------------------------------------------------------
Protocol - All nodes:
----------------------------------------------------------------------------------------------------
Nodes echo each incoming transaction or message to all other nodes
When a node i has seen 2n/3 signed votes for a block, it is "notarized in i's view"
When a node sees a block as notarized in its own view, it writes it to its local blockchain
When a node sees (in its notarized blockchain) three adjacent blocks with consecutive epoc
numbers, it considers all the blocks in the chain except for the last one to be "final"
----------------------------------------------------------------------------------------------------
Protocol - The leader:
----------------------------------------------------------------------------------------------------
A leader is randomly chosen for each epoch
The leader proposes a new block for each epoc, extending from the longest notarized chain it
has seen (ties broken randomly). This proposal contains the leader's signature (i.e. the
leader's 'vote')
----------------------------------------------------------------------------------------------------
Protocol - Voters (all nodes but the leader)
----------------------------------------------------------------------------------------------------
Voters vote for the proposed block, as long as it extends (one of) the longest notarized chains
the voter has seen. Voting means signing the block, and sending the block and its
signature to all the other nodes
Nodes (presumably) validate the block/transactions before voting
----------------------------------------------------------------------------------------------------
Transactions
----------------------------------------------------------------------------------------------------
All nodes can receive transactions from outside the environment
----------------------------------------------------------------------------------------------------
Blocks
----------------------------------------------------------------------------------------------------
a block is a tuple (h, e, txs)
h is the parent hash
e is the epoc number
txs is the set of transactions to be confirmed
----------------------------------------------------------------------------------------------------
Implied 'api'
----------------------------------------------------------------------------------------------------
receive_transactions (* receive external transactions *)
new_txs_to_mempool
receive_epoch_timer_event
get_pending_txs_from_mempool
validate_transactions
broadcast_vote (* send signed block to all *)
get_leader_for_epoc
receive_vote (* either new block from leader or vote from another member *)
add_block_to_local_chain
is_block_notarized
is_block_final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment