Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotstuff integration #1536

Closed
wants to merge 1,597 commits into from
Closed
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
1597 commits
Select commit Hold shift + click to select a range
28d7cbf
Fix `plugin_test` (was missing `action_return_value` dependent feature)
greg7mdp Mar 16, 2024
a9058bd
Remove leftover comment.
greg7mdp Mar 16, 2024
75b5627
GH-2057 Remove unneeded reset_root that takes a variant. Remove unuse…
heifner Mar 16, 2024
d08e321
update ABI definition and types for the new finality_data log
linh2931 Mar 16, 2024
bac10e1
GH-2057 WIP: Transition during replay
heifner Mar 16, 2024
b432deb
GH-2057 Handle startup from snapshot post-if transition without a forkdb
heifner Mar 16, 2024
71ea20c
GH-2057 Revert to v5.0 impl
heifner Mar 16, 2024
4f8a5c4
Renamed if_ibc to svnn_ibc, fixed issues
systemzax Mar 17, 2024
900fa22
Support finality_data in state_history_plugin
linh2931 Mar 17, 2024
0bda766
add new finality_data tests to state_history_plugin test
linh2931 Mar 17, 2024
54797c0
update ship_streamer tests for finality_data
linh2931 Mar 17, 2024
31e4100
rename get_chain_head_finality_data() to head_finality_data()
linh2931 Mar 17, 2024
84c80f9
Merge remote-tracking branch 'origin/hotstuff_integration' into ship_…
linh2931 Mar 18, 2024
3db6e06
cache action_mroot when producing blocks
linh2931 Mar 18, 2024
8635f39
Merge pull request #2318 from AntelopeIO/gh_2162
greg7mdp Mar 18, 2024
8067149
GH-2057 Remove unneeded sets
heifner Mar 18, 2024
66885fe
GH-2057 Correctly handle proposer schedule transition from legacy to …
heifner Mar 18, 2024
91cbeac
Merge remote-tracking branch 'origin/main' into merge-main-03-18-2024
heifner Mar 18, 2024
98c08c3
Fix merge issue
heifner Mar 18, 2024
1e0ca13
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-20…
heifner Mar 18, 2024
23fbe2d
GH-2057 Update asserts for IRREVERSIBLE mode
heifner Mar 18, 2024
55717d1
make head_finality_data() return std::optional<finality_data_t>
linh2931 Mar 18, 2024
03ac11e
Merge pull request #2319 from AntelopeIO/merge-main-03-18-2024
heifner Mar 18, 2024
a3a0a6f
small refactoring in state_history_plugin.cpp
linh2931 Mar 18, 2024
ad09408
GH-2057 Add helper template for extracting header extensions
heifner Mar 18, 2024
fe11657
GH-2057 Cleanup
heifner Mar 18, 2024
ef9d7e3
GH-2057 Stop using legacy forkdb on close when no longer needed
heifner Mar 19, 2024
b73937f
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-20…
heifner Mar 19, 2024
46cefb5
GH-2057 Update deepmind logs
heifner Mar 19, 2024
bc5ba05
GH-2057 Add snapshot support during transition; untested
heifner Mar 19, 2024
5722be9
GH-2057 Fix close logic of forkdb
heifner Mar 19, 2024
b8a772c
GH-2057 Fix race condition on switch_from_legacy. Fix startup in sava…
heifner Mar 19, 2024
f00fd32
GH-2057 Rename result to next_header_state
heifner Mar 19, 2024
beed426
update savanna protocol activation
ericpassmore Mar 19, 2024
0a789b0
GH-2057 Fix indentation
heifner Mar 19, 2024
50fdb40
GH-2057 Set default_safety_information on replay
heifner Mar 19, 2024
3c19387
Merge pull request #2324 from AntelopeIO/update-svna-protocol-activation
ericpassmore Mar 19, 2024
dadd077
Add new Savanna action digest (wip).
greg7mdp Mar 19, 2024
9c70367
merge `origin/hotstuff_integration`
greg7mdp Mar 19, 2024
52eb338
GH-2057 Don't bother including legacy in snapshot if pass transition
heifner Mar 19, 2024
d53d431
Delay on error to give time for node to launch
heifner Mar 19, 2024
0a9f0c1
GH-2057 Simplify code
heifner Mar 19, 2024
84cc1f7
Revert "merge `origin/hotstuff_integration`"
greg7mdp Mar 19, 2024
b624c24
Merge pull request #2325 from AntelopeIO/fix-sync-test
heifner Mar 20, 2024
d19c3f0
Added cleaner log base 2 function + integrity check in bitset constru…
systemzax Mar 20, 2024
5804b24
Added cleaner log base 2 function + integrity check in bitset constru…
systemzax Mar 20, 2024
aada30c
Merge branch 'hotstuff_integration' of https://github.com/antelopeIO/…
systemzax Mar 20, 2024
30a61cc
Merge branch 'hotstuff_integration' into if_ibc_contract
systemzax Mar 20, 2024
3efd4bf
GH-2057 Always return a valid future
heifner Mar 20, 2024
26d82da
GH-2057 Switch away from legacy forkdb in log_irreversible to simplif…
heifner Mar 20, 2024
bbe8735
Introduce get_blocks_request_v1 to support fetch_finality_data parame…
linh2931 Mar 20, 2024
b1b9642
remove leftover debugging statements
linh2931 Mar 20, 2024
35839ed
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-20…
heifner Mar 21, 2024
b4c445d
Support optional computation and storage of two `action_digest` varia…
greg7mdp Mar 21, 2024
528c089
Construct `executed_action_receipt_digests_*` empty by default.
greg7mdp Mar 21, 2024
fbe6455
Merge pull request #2314 from AntelopeIO/if_ibc_contract
systemzax Mar 21, 2024
0c6d290
Add finality_data ABI definition so clients have a standard type defi…
linh2931 Mar 21, 2024
51feb05
GH-2057 Use constexpr instead of overloaded function
heifner Mar 21, 2024
6cfb3fb
Rename functions.
greg7mdp Mar 21, 2024
79142ab
simplify std::visitor uses; cache base_digest; and minor changes for …
linh2931 Mar 21, 2024
2799ca7
Use struct to store two versions of `action_receipt_digests`
greg7mdp Mar 22, 2024
5e895c4
Simplify two namespaces.
greg7mdp Mar 22, 2024
7a22f7e
rename `sad` into `store_which`.
greg7mdp Mar 22, 2024
493b7e1
Merge branch 'hotstuff_integration' of github.com:AntelopeIO/leap int…
greg7mdp Mar 22, 2024
26f72bd
Encapsulate use of `action_digests_t` better.
greg7mdp Mar 22, 2024
1b92f02
Move back `finalize_trace` after the digest computation.
greg7mdp Mar 22, 2024
cc65791
Remove outdated comment.
greg7mdp Mar 22, 2024
78bbc62
GH-2286 Add an irreversible node to test
heifner Mar 22, 2024
b9ac212
GH-2161 Uncomment tests.
heifner Mar 22, 2024
be96431
GH-2161 For LIB to advance need to make bios not a finalizer
heifner Mar 22, 2024
988261e
GH-2161 Add better log statement
heifner Mar 22, 2024
32258f4
GH-2161 Add support for transition to savanna in irreversible mode
heifner Mar 22, 2024
dac12e5
GH-2057 Use any_of instead of find_if
heifner Mar 23, 2024
f576797
GH-2057 Remove todo
heifner Mar 23, 2024
eb2fc59
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-23…
heifner Mar 23, 2024
54e88ed
Fix misspelled function name, and incorrect name `clz_power_2`
greg7mdp Mar 25, 2024
cce8e5c
File reorg to separate `legacy` and `optimized` merkle implementation
greg7mdp Mar 25, 2024
1b0a63b
Merge pull request #2326 from AntelopeIO/gh_2161
greg7mdp Mar 25, 2024
c775d7a
Make `merkle` names consistent and deprecate `canonical`
greg7mdp Mar 25, 2024
f7364c5
Move `merkle` types into their correct headers.
greg7mdp Mar 25, 2024
1b7351d
GH-2286 Add message to assert.
heifner Mar 25, 2024
6f47ddb
GH-2886 Create method to remove duplicate code
heifner Mar 25, 2024
6bb9d36
GH-2334 Change bls_public_key serialization format and optimize
heifner Mar 26, 2024
1056702
GH-2057 minor cleanup
heifner Mar 26, 2024
e421b74
use cached base_digest actually; minor review changes
linh2931 Mar 26, 2024
417615d
Merge branch 'hotstuff_integration' into ship_finality_info_support
linh2931 Mar 26, 2024
86a0b28
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-20…
heifner Mar 26, 2024
3b3fb28
GH-2057 Fix merge conflicts
heifner Mar 26, 2024
1fdd181
Merge remote-tracking branch 'origin/ship_finality_info_support' into…
heifner Mar 26, 2024
35a040d
minor changes responding to review comments
linh2931 Mar 26, 2024
f412147
make cached base_digest as an optional
linh2931 Mar 26, 2024
5c82eec
remove an unnecessary compute_base_digest()
linh2931 Mar 26, 2024
0fd2540
GH-2334 Add bls_aggregate_signature and change serialization of bls_s…
heifner Mar 26, 2024
b280344
GH-2057 update deep mind logs again after merge
heifner Mar 26, 2024
e92e4ad
GH-2286 Misc cleanup
heifner Mar 26, 2024
dc029db
GH-2286 Simplify by adding fork_db_head_or_pending()
heifner Mar 26, 2024
97df979
Merge branch 'GH-2057-transition' into GH-2286-irreversible
heifner Mar 26, 2024
21de5c4
use apply_s for head_finality_data to simplify code
linh2931 Mar 26, 2024
3a65b3f
Merge remote-tracking branch 'origin/ship_finality_info_support' into…
heifner Mar 27, 2024
20520cc
Merge pull request #2316 from AntelopeIO/GH-2057-transition
heifner Mar 27, 2024
4bd9b4d
Merge branch 'hotstuff_integration' into GH-2286-irreversible
heifner Mar 27, 2024
383c6e9
Merge remote-tracking branch 'origin/main' into merge-main-03-27-2024
heifner Mar 27, 2024
f1a1893
Merge branch 'hotstuff_integration' into ship_finality_info_support
linh2931 Mar 27, 2024
39cd75a
Merge pull request #2321 from AntelopeIO/ship_finality_info_support
linh2931 Mar 27, 2024
a2013f7
Merge pull request #2341 from AntelopeIO/merge-main-03-27-2024
heifner Mar 27, 2024
7bab066
Merge branch 'hotstuff_integration' of github.com:AntelopeIO/leap int…
greg7mdp Mar 27, 2024
eb3e2dd
GH-2286 Use const members, clean up construction
heifner Mar 27, 2024
aea1aa1
GH-2286 Remove const as FC_REFLECT does not support const members
heifner Mar 27, 2024
2686c85
GH-2334 Remove duplicate code and update comments
heifner Mar 27, 2024
61afa39
GH-2334 Update comments
heifner Mar 27, 2024
8381b40
GH-2334 Make method public to avoid multiple friend declarations
heifner Mar 27, 2024
86432e9
GH-2310 Use getBlockID so that both block_id and head_id supported de…
heifner Mar 27, 2024
e8d10a3
GH-2313 When a proposed producer schedule will replace an existing on…
heifner Mar 27, 2024
80c3b22
add get_blocks_result_v1 to SHiP
linh2931 Mar 27, 2024
fe71f93
update ship_streamer_test to use get_blocks_result_v1 or get_blocks_r…
linh2931 Mar 28, 2024
81ede3c
set initial active_finalizer_policy_generation in finality_data to 1
linh2931 Mar 28, 2024
e7e9a7c
GH-2334 Serialize as variable length array for easier decoding by ext…
heifner Mar 28, 2024
ba33ba8
GH-2310 Fix error message to say status instead of state
heifner Mar 28, 2024
1cd0b35
Merge pull request #2335 from AntelopeIO/GH-2286-irreversible
heifner Mar 28, 2024
bf04b0a
GH-2313 Fix spelling
heifner Mar 28, 2024
37c3322
simplify send_entryby factoring out result variant processing
linh2931 Mar 28, 2024
57b61b9
use common code to serialize get_blocks_result_v0 and get_blocks_resu…
linh2931 Mar 28, 2024
93905c3
use T&& result for send_update
linh2931 Mar 28, 2024
ae08070
Merge pull request #2343 from AntelopeIO/GH-2310-test
heifner Mar 28, 2024
f0038dc
Merge pull request #2344 from AntelopeIO/GH-2313-proposed_producers_v…
heifner Mar 28, 2024
dd8d988
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-23…
heifner Mar 28, 2024
aaa9284
GH-2334 Simplify sizeof calculation
heifner Mar 28, 2024
86cca8e
GH-2348 Calculate IF Genesis Block finality digest correctly
heifner Mar 28, 2024
f68869a
static_assert the variant index is correct for get_blocks_result_v0 a…
linh2931 Mar 28, 2024
9480cf8
Only use get_blocks_request_v1 and get_blocks_result_v1 for ship_stre…
linh2931 Mar 28, 2024
4a5bc73
Merge branch 'hotstuff_integration' into ship_get_blocks_result_v1
linh2931 Mar 28, 2024
789dfee
remove unnecessary if( fetch_finality_data )
linh2931 Mar 28, 2024
51e9379
Update nodeos_forked_chain_test.py to use get_blocks_result_v1 instea…
linh2931 Mar 28, 2024
acc51cb
GH-2348 Make sure all attributes of block_state are populated in crea…
heifner Mar 28, 2024
9cc6f74
always provide fetch_finality_data field for get_blocks_request_v1
linh2931 Mar 28, 2024
30fd771
Merge pull request #2338 from AntelopeIO/GH-2334-bls-serialization
heifner Mar 28, 2024
f0fcc44
Merge branch 'hotstuff_integration' into GH-2348-genesis-finality-digest
heifner Mar 28, 2024
7bb4e56
Merge pull request #2349 from AntelopeIO/ship_get_blocks_result_v1
linh2931 Mar 28, 2024
fd02885
Initial new merkle tree implementation.
greg7mdp Mar 28, 2024
afd97ca
Add stack depth check.
greg7mdp Mar 28, 2024
bcb2545
Add alternative to `std::popcount` for cdt which does not support C++…
greg7mdp Mar 29, 2024
a09fd7d
Remove destructive version of `calculate_merkle`.
greg7mdp Mar 29, 2024
8ea41a4
Add alternative to `std::bit_floor` for cdt which does not support C+…
greg7mdp Mar 29, 2024
8a7794f
Add extra logging around async write
heifner Mar 29, 2024
809e4ab
Merge branch 'hotstuff_integration' into GH-2348-genesis-finality-digest
heifner Mar 29, 2024
d8e7ee5
Merge branch 'hotstuff_integration' into net-plugin-logging
heifner Mar 29, 2024
e384b43
GH-2057 Ignore proposed producers during transition
heifner Mar 29, 2024
0d809ef
GH-2348 Use correct strong digest
heifner Mar 29, 2024
1eb7bc0
set active_finalizer_policy_generation correctly in finality_data for…
linh2931 Mar 29, 2024
38562ac
Log unknown block
heifner Mar 29, 2024
25b93a9
Merge pull request #2355 from AntelopeIO/net-plugin-logging
heifner Mar 29, 2024
d2f1c92
Add perf tests, fix warning.
greg7mdp Mar 29, 2024
70fb9a9
Merge pull request #2358 from AntelopeIO/correct_finalizer_policy_gen…
linh2931 Mar 29, 2024
1ced859
Verify bls signature of vote while not holding a mutex
heifner Mar 29, 2024
57bf131
Merge pull request #2357 from AntelopeIO/GH-2057-producer-schedule
heifner Mar 29, 2024
12e6a53
Add multithreading to , add test, remove stack size debug code
greg7mdp Mar 29, 2024
da5d431
Merge branch 'hotstuff_integration' of github.com:AntelopeIO/leap int…
greg7mdp Mar 29, 2024
ceec40b
Add has_voted() method
heifner Mar 29, 2024
be4c877
Wait for controller to vote if it should
heifner Mar 29, 2024
2c4cb49
Provide finality_data for Transition blocks
linh2931 Mar 29, 2024
67c4f1d
Verify all have voted
heifner Mar 29, 2024
a241785
Make sure validating node has voted
heifner Mar 29, 2024
209090e
Simplify `canonical` template param from `incremental_merkle_tree_leg…
greg7mdp Mar 29, 2024
46867a9
GH-2348 Fix spelling
heifner Mar 29, 2024
3562c7d
Merge pull request #2359 from AntelopeIO/verify-bls-sig-unlocked
heifner Mar 29, 2024
8ed91d9
Update comments.
greg7mdp Mar 29, 2024
fb6f69e
Merge branch 'hotstuff_integration' of github.com:AntelopeIO/leap int…
greg7mdp Mar 29, 2024
49aca0b
Add test with 20 nodes, seems to be an off by one somewhere that prev…
heifner Mar 29, 2024
5b83d32
Merge pull request #2353 from AntelopeIO/GH-2348-genesis-finality-digest
heifner Mar 29, 2024
264dffe
Merge branch 'hotstuff_integration' of github.com:AntelopeIO/leap int…
greg7mdp Mar 29, 2024
0663a3d
Add `num_digests_appended()` method, not used but pretty cool doc on …
greg7mdp Mar 29, 2024
08c5186
Reduce number of boost test assertions.
greg7mdp Mar 29, 2024
ac2f980
Small cleanup of the test.
greg7mdp Mar 30, 2024
b5f522f
Cleanup messages from performance test.
greg7mdp Mar 30, 2024
c300efe
GH-2364 Verify needed trx processed before continuing
heifner Mar 30, 2024
198e512
Finish removing references to `canonical`.
greg7mdp Mar 30, 2024
89e3d8d
Address PR comments, templatize `calculate_merkle`.
greg7mdp Mar 30, 2024
b86a162
Remove `post_async_task` for the `calculate_merkle` of action/transac…
greg7mdp Mar 30, 2024
f2a3c27
Update `calculate_merkle_pow2` to use 2 threads for sizes from 256 to…
greg7mdp Mar 30, 2024
808d586
Update comment.
greg7mdp Mar 30, 2024
95f06f2
Fix gcc-11 compiler warnings.
greg7mdp Mar 30, 2024
20f5d0e
Merge branch 'hotstuff_integration' into 21-test
heifner Mar 30, 2024
064717e
Fix compilation error with gcc10.
greg7mdp Mar 30, 2024
54e5d70
Fix typo.
greg7mdp Mar 30, 2024
82178a7
Add class comment for `incremental_merkle_tree`.
greg7mdp Mar 30, 2024
f44409b
Merge pull request #2365 from AntelopeIO/GH-2364-retry-test
heifner Apr 2, 2024
d4d052e
Merge branch 'hotstuff_integration' into 21-test
heifner Apr 2, 2024
8c03a62
Merge pull request #2361 from AntelopeIO/gh_2333
greg7mdp Apr 2, 2024
ad64fc7
GH-2102 Use vector of atomic bools to avoid mutex lock for duplicate …
heifner Apr 2, 2024
755da1a
Add get_row_by_id to libtester
linh2931 Apr 2, 2024
f622184
allow more than one BOOST_AUTO_TEST_SUITE() in a file
spoonincode Apr 2, 2024
a19d126
split eosio.system_tests in to two parts
spoonincode Apr 2, 2024
548641d
Merge pull request #2368 from AntelopeIO/get_row_by_id
linh2931 Apr 2, 2024
cf7f527
Merge pull request #2370 from AntelopeIO/split_eosio.system_tests
spoonincode Apr 2, 2024
c40d390
Merge branch 'hotstuff_integration' into 21-test
heifner Apr 2, 2024
3887b2c
GH-2102 Add block to fork db as soon as header is validated so it is …
heifner Apr 2, 2024
753af58
Re-implement getting finality_data for Savanna Transition Blocks
linh2931 Apr 3, 2024
9daa3d2
Merge branch 'hotstuff_integration' into add_finality_data_in_transit…
linh2931 Apr 3, 2024
cc56c51
Merge pull request #2363 from AntelopeIO/21-test
heifner Apr 3, 2024
da5f812
Add a comment explaining why both forkdb root and legacy branch are s…
linh2931 Apr 3, 2024
4b06a17
Merge branch 'hotstuff_integration' into add_finality_data_in_transit…
linh2931 Apr 3, 2024
bd43d61
GH-2102 May already be in forkdb since we are adding as soon as heade…
heifner Apr 3, 2024
c10bcaa
Merge remote-tracking branch 'origin/main' into main_catchup_apr_04
greg7mdp Apr 3, 2024
ccc79c5
Additional changes to support bls12 API change.
greg7mdp Apr 3, 2024
c84bab1
GH-2102 Add logging on app().quit()
heifner Apr 3, 2024
cf50336
GH-2102 Integrate qc and vote when switching forks if first time bloc…
heifner Apr 3, 2024
facbee8
Move merkel benchmarks from `unittest` to `benchmark`.
greg7mdp Apr 3, 2024
5cce3d6
Merge pull request #2374 from AntelopeIO/main_catchup_apr_04
greg7mdp Apr 3, 2024
eb84aa2
Merge branch 'hotstuff_integration' of github.com:AntelopeIO/leap int…
greg7mdp Apr 3, 2024
053fe72
GH-2102 Log irreversible even when head not updated
heifner Apr 3, 2024
68148eb
Cache action_mroot_savanna instead of action_receipt_digests_savanna …
linh2931 Apr 3, 2024
78c6de1
Correct comments
linh2931 Apr 3, 2024
f02fa48
Merge pull request #2375 from AntelopeIO/gh_2371
greg7mdp Apr 3, 2024
a9987a2
Merge branch 'hotstuff_integration' into add_finality_data_in_transit…
linh2931 Apr 4, 2024
773577b
update deep-mind.log
linh2931 Apr 4, 2024
4066109
GH-2102 Check for validated block to avoid extra processing
heifner Apr 4, 2024
486fed3
make it clear action_mroot_savanna constructed as a std::optional
linh2931 Apr 4, 2024
9411c05
GH-2102 Init processed on reflection
heifner Apr 4, 2024
3465884
Make action_receipt_digests_savanna as const& to parameter to block_s…
linh2931 Apr 4, 2024
0c82e7a
GH-2102 Handle corner case of trx locally applied but not in a block yet
heifner Apr 4, 2024
b9deb58
GH-2102 Only report fork switch on actual fork switch. maybe_switch_f…
heifner Apr 4, 2024
8a7b973
GH-2102 Check for terminate_at_block during apply of fork db blocks
heifner Apr 4, 2024
274e44a
GH-2102 If forked out again then could still be in local state
heifner Apr 4, 2024
93163ec
store action_mroot only for the last block in the process of construc…
linh2931 Apr 4, 2024
2e49794
GH-2102 Allow ctrl-c shutdown during sync of a large number of blocks…
heifner Apr 4, 2024
4c3535f
GH-2102 Fix sync issue with receiving a current block while syncing
heifner Apr 4, 2024
08d0c96
Merge pull request #2362 from AntelopeIO/add_finality_data_in_transit…
linh2931 Apr 4, 2024
112bb69
GH-2102 On startup pending_head forkdb blocks are processed. If asked…
heifner Apr 4, 2024
84098e5
switch variant index of new get_blocks_request_v1
spoonincode Apr 4, 2024
66c7c62
Merge pull request #2381 from AntelopeIO/ship_gbrv1_variant
spoonincode Apr 5, 2024
914f218
GH-2102 Fix comparison in waitForBlock
heifner Apr 5, 2024
5e9af0c
GH-2102 Better error reporting and a bit more tolerance for trxs in b…
heifner Apr 5, 2024
2449830
GH-2102 Add additional logging for applied blocks
heifner Apr 5, 2024
e464aee
Revert "GH-2102 Fix comparison in waitForBlock"
heifner Apr 5, 2024
a74450c
GH-2102 Improve logging during sync
heifner Apr 5, 2024
cafd0b6
GH-2102 Add a large_atomic wrapper around mutex
heifner Apr 5, 2024
302b957
GH-2102 Use large_atomic for if_irreversible_block_id
heifner Apr 5, 2024
be77ca6
GH-2102 No need to recalculate finality digest
heifner Apr 5, 2024
23945ff
GH-2102 Move valid_qc into pending_qc and make thread safe
heifner Apr 5, 2024
ba5006e
GH-2102 Improve test conditions
heifner Apr 5, 2024
9de11ff
GH-2102 Move produced/received block logging into controller so it lo…
heifner Apr 6, 2024
8e98c18
GH-2102 Fix log_applied to not be called during replay
heifner Apr 6, 2024
a9058a1
GH-2102 Add a copyable atomic type
heifner Apr 8, 2024
6d64c27
GH-2102 Integrate qc and vote if possible off the main thread.
heifner Apr 8, 2024
6bd8128
Merge remote-tracking branch 'origin/hotstuff_integration' into GH-21…
heifner Apr 8, 2024
c54fe32
Increment `finalizer_policy`'s `generation`.
greg7mdp Apr 8, 2024
232e95b
Merge pull request #2388 from AntelopeIO/gh_2345
greg7mdp Apr 9, 2024
33210c0
GH-2102 Small cleanup from PR review
heifner Apr 9, 2024
5cc1b87
GH-2102 Move Produced block log into controller_impl commit_block
heifner Apr 9, 2024
f9786e1
Merge pull request #2385 from AntelopeIO/GH-2102-vote-processing
heifner Apr 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
663 changes: 663 additions & 0 deletions hostuff-pseudo.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ add_subdirectory( testing )
add_subdirectory( version )
add_subdirectory( state_history )
add_subdirectory( cli11 )
add_subdirectory( hotstuff )

set(USE_EXISTING_SOFTFLOAT ON CACHE BOOL "use pre-exisiting softfloat lib")
set(ENABLE_TOOLS OFF CACHE BOOL "Build tools")
Expand Down
41 changes: 41 additions & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ struct controller_impl {
set_activation_handler<builtin_protocol_feature_t::get_block_num>();
set_activation_handler<builtin_protocol_feature_t::crypto_primitives>();
set_activation_handler<builtin_protocol_feature_t::bls_primitives>();
set_activation_handler<builtin_protocol_feature_t::instant_finality>();

self.irreversible_block.connect([this](const block_state_ptr& bsp) {
wasm_if_collect.current_lib(bsp->block_num);
Expand Down Expand Up @@ -1973,6 +1974,22 @@ struct controller_impl {
pending->push();
}

void commit_hs_proposal_msg(hs_proposal_message_ptr msg){
emit( self.new_hs_proposal_message, msg );
}

void commit_hs_vote_msg(hs_vote_message_ptr msg){
emit( self.new_hs_vote_message, msg );
}

void commit_hs_new_view_msg(hs_new_view_message_ptr msg){
emit( self.new_hs_new_view_message, msg );
}

void commit_hs_new_block_msg(hs_new_block_message_ptr msg){
emit( self.new_hs_new_block_message, msg );
}

/**
* This method is called from other threads. The controller_impl should outlive those threads.
* However, to avoid race conditions, it means that the behavior of this function should not change
Expand Down Expand Up @@ -2966,6 +2983,22 @@ void controller::commit_block() {
my->commit_block(block_status::incomplete);
}

void controller::commit_hs_proposal_msg(hs_proposal_message_ptr msg) {
my->commit_hs_proposal_msg(msg);
}

void controller::commit_hs_vote_msg(hs_vote_message_ptr msg) {
my->commit_hs_vote_msg(msg);
}

void controller::commit_hs_new_view_msg(hs_new_view_message_ptr msg) {
my->commit_hs_new_view_msg(msg);
}

void controller::commit_hs_new_block_msg(hs_new_block_message_ptr msg) {
my->commit_hs_new_block_msg(msg);
}
heifner marked this conversation as resolved.
Show resolved Hide resolved

deque<transaction_metadata_ptr> controller::abort_block() {
return my->abort_block();
}
Expand Down Expand Up @@ -3840,6 +3873,14 @@ void controller_impl::on_activation<builtin_protocol_feature_t::bls_primitives>(
} );
}

template<>
void controller_impl::on_activation<builtin_protocol_feature_t::instant_finality>() {
db.modify( db.get<protocol_state_object>(), [&]( auto& ps ) {
#warning host functions to set proposers, leaders, finalizers/validators
// FIXME/TODO: host functions to set proposers, leaders, finalizers/validators
heifner marked this conversation as resolved.
Show resolved Hide resolved
} );
}

/// End of protocol feature activation handlers

} } /// eosio::chain
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const static auto reversible_blocks_dir_name = "reversible";

const static auto default_state_dir_name = "state";
const static auto forkdb_filename = "fork_db.dat";
const static auto qcdb_filename = "qc_db.dat";
const static auto default_state_size = 1*1024*1024*1024ll;
const static auto default_state_guard_size = 128*1024*1024ll;

Expand Down
19 changes: 19 additions & 0 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ namespace eosio { namespace vm { class wasm_allocator; }}

namespace eosio { namespace chain {

struct hs_proposal_message;
struct hs_vote_message;
struct hs_new_view_message;
struct hs_new_block_message;
using hs_proposal_message_ptr = std::shared_ptr<hs_proposal_message>;
using hs_vote_message_ptr = std::shared_ptr<hs_vote_message>;
using hs_new_view_message_ptr = std::shared_ptr<hs_new_view_message>;
using hs_new_block_message_ptr = std::shared_ptr<hs_new_block_message>;
heifner marked this conversation as resolved.
Show resolved Hide resolved

class authorization_manager;

namespace resource_limits {
Expand Down Expand Up @@ -166,6 +175,12 @@ namespace eosio { namespace chain {
block_state_ptr finalize_block( block_report& br, const signer_callback_type& signer_callback );
void sign_block( const signer_callback_type& signer_callback );
void commit_block();

void commit_hs_proposal_msg(hs_proposal_message_ptr msg);
void commit_hs_vote_msg(hs_vote_message_ptr msg);

void commit_hs_new_view_msg(hs_new_view_message_ptr msg);
void commit_hs_new_block_msg(hs_new_block_message_ptr msg);
heifner marked this conversation as resolved.
Show resolved Hide resolved

// thread-safe
std::future<block_state_ptr> create_block_state_future( const block_id_type& id, const signed_block_ptr& b );
Expand Down Expand Up @@ -337,6 +352,10 @@ namespace eosio { namespace chain {
signal<void(const transaction_metadata_ptr&)> accepted_transaction;
signal<void(std::tuple<const transaction_trace_ptr&, const packed_transaction_ptr&>)> applied_transaction;
signal<void(const int&)> bad_alloc;
signal<void(const hs_proposal_message_ptr&)> new_hs_proposal_message;
signal<void(const hs_vote_message_ptr&)> new_hs_vote_message;
signal<void(const hs_new_view_message_ptr&)> new_hs_new_view_message;
signal<void(const hs_new_block_message_ptr&)> new_hs_new_block_message;
heifner marked this conversation as resolved.
Show resolved Hide resolved

/*
signal<void()> pre_apply_block;
Expand Down
86 changes: 86 additions & 0 deletions libraries/chain/include/eosio/chain/hotstuff.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#pragma once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want this header file in libraries/chain/include/eosio/chain but not in libraries/hotstuff/include?

#include <eosio/chain/block_header.hpp>
#include <fc/bitutil.hpp>
#include <fc/crypto/bls_private_key.hpp>
#include <fc/crypto/bls_public_key.hpp>
#include <fc/crypto/bls_signature.hpp>
#include <fc/crypto/bls_utils.hpp>

namespace eosio::chain {

const block_id_type NULL_BLOCK_ID = block_id_type("00");
const fc::sha256 NULL_PROPOSAL_ID = fc::sha256("00");
heifner marked this conversation as resolved.
Show resolved Hide resolved

inline uint64_t compute_height(uint32_t block_height, uint32_t phase_counter) {
return (uint64_t{block_height} << 32) | phase_counter;
}

struct extended_schedule {
producer_authority_schedule producer_schedule;
std::map<name, fc::crypto::blslib::bls_public_key> bls_pub_keys;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the bls_pub_keys be added in the producer_authority_schedule instead of on the side like here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extended schedule was a placeholder until we reached a decision on the final format of the finalizers set structure. I think we agreed to only keep the bls public key, as well as the threshold for finalizers (as far as the hotstuff algorithm is concerned). The name would be present in the structure as well, but serves only to identify the finalizer on-chain, and is not required by Hotstuff.

};

struct quorum_certificate {
fc::sha256 proposal_id = NULL_PROPOSAL_ID;
fc::unsigned_int active_finalizers = 0; //bitset encoding, following canonical order
fc::crypto::blslib::bls_signature active_agg_sig;
bool quorum_met = false;
};

struct hs_vote_message {
fc::sha256 proposal_id = NULL_PROPOSAL_ID; //vote on proposal
name finalizer;
fc::crypto::blslib::bls_signature sig;
};

struct hs_proposal_message {
fc::sha256 proposal_id = NULL_PROPOSAL_ID; //vote on proposal
block_id_type block_id = NULL_BLOCK_ID;
fc::sha256 parent_id = NULL_PROPOSAL_ID; //new proposal
fc::sha256 final_on_qc = NULL_PROPOSAL_ID;
quorum_certificate justify; //justification
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these = NULL_PROPOSAL_ID are unneeded since the default construction of sha256 already initializes to all zeroes.

uint8_t phase_counter = 0;

uint32_t block_num() const { return block_header::num_from_id(block_id); }
uint64_t get_height() const { return compute_height(block_header::num_from_id(block_id), phase_counter); };
};

struct hs_new_block_message {
block_id_type block_id = NULL_BLOCK_ID; //new proposal
quorum_certificate justify; //justification
};

struct hs_new_view_message {
quorum_certificate high_qc; //justification
};

struct finalizer_state {

bool chained_mode = false;
fc::sha256 b_leaf = NULL_PROPOSAL_ID;
fc::sha256 b_lock = NULL_PROPOSAL_ID;
fc::sha256 b_exec = NULL_PROPOSAL_ID;
fc::sha256 b_finality_violation = NULL_PROPOSAL_ID;
block_id_type block_exec = NULL_BLOCK_ID;
block_id_type pending_proposal_block = NULL_BLOCK_ID;
uint32_t v_height = 0;
eosio::chain::quorum_certificate high_qc;
eosio::chain::quorum_certificate current_qc;
eosio::chain::extended_schedule schedule;
map<fc::sha256, hs_proposal_message> proposals;
heifner marked this conversation as resolved.
Show resolved Hide resolved
};

using hs_proposal_message_ptr = std::shared_ptr<hs_proposal_message>;
using hs_vote_message_ptr = std::shared_ptr<hs_vote_message>;
using hs_new_view_message_ptr = std::shared_ptr<hs_new_view_message>;
using hs_new_block_message_ptr = std::shared_ptr<hs_new_block_message>;

} //eosio::chain

FC_REFLECT(eosio::chain::quorum_certificate, (proposal_id)(active_finalizers)(active_agg_sig));
FC_REFLECT(eosio::chain::extended_schedule, (producer_schedule)(bls_pub_keys));
FC_REFLECT(eosio::chain::hs_vote_message, (proposal_id)(finalizer)(sig));
FC_REFLECT(eosio::chain::hs_proposal_message, (proposal_id)(block_id)(parent_id)(final_on_qc)(justify)(phase_counter));
FC_REFLECT(eosio::chain::hs_new_block_message, (block_id)(justify));
FC_REFLECT(eosio::chain::hs_new_view_message, (high_qc));
FC_REFLECT(eosio::chain::finalizer_state, (chained_mode)(b_leaf)(b_lock)(b_exec)(b_finality_violation)(block_exec)(pending_proposal_block)(v_height)(high_qc)(current_qc)(schedule)(proposals));
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ enum class builtin_protocol_feature_t : uint32_t {
crypto_primitives = 19,
get_block_num = 20,
bls_primitives = 21,
instant_finality = 22,
reserved_private_fork_protocol_features = 500000,
};

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/eosio/chain/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace eosio::chain {
using public_key_type = fc::crypto::public_key;
using private_key_type = fc::crypto::private_key;
using signature_type = fc::crypto::signature;

// configurable boost deque (for boost >= 1.71) performs much better than std::deque in our use cases
using block_1024_option_t = boost::container::deque_options< boost::container::block_size<1024u> >::type;
template<typename T>
Expand Down
9 changes: 9 additions & 0 deletions libraries/chain/protocol_feature_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,15 @@ Enables new `get_block_num` intrinsic which returns the current block number.
Builtin protocol feature: BLS_PRIMITIVES
Adds new cryptographic host functions
- Add, multiply, multi-exponentiation and pairing functions for the bls12-381 elliptic curve.
*/
{}
} )
( builtin_protocol_feature_t::instant_finality, builtin_protocol_feature_spec{
"INSTANT_FINALITY",
fc::variant("bc726a24928ea2d71ba294b70c5c9efc515c1542139bcf9e42f8bc174f2e72ff").as<digest_type>(),
// SHA256 hash of the raw message below within the comment delimiters (do not modify message below).
/*
Builtin protocol feature: INSTANT_FINALITY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some explanation about instant_finality like other protocol features do.

*/
{}
} )
Expand Down
17 changes: 17 additions & 0 deletions libraries/hotstuff/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
file(GLOB HEADERS "include/eosio/hotstuff/*.hpp")

add_library( hotstuff
chain_pacemaker.cpp
qc_chain.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little puzzled by chain being a part of those two file names, and one having chain in the front and the other in the end: chain_pacemake.cpp and qc_chain.cpp. Can the names be changed?

${HEADERS}
)

target_link_libraries( hotstuff
PUBLIC eosio_chain fc
)

target_include_directories( hotstuff
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
)

add_subdirectory( test )
Loading