From 2acb91dc9acec7b758aa003c78ffe9f2dca0892c Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Wed, 21 Aug 2024 10:03:17 +0400 Subject: [PATCH] feat(consensus): sequence transaction from foreign LocalPrepare/Accept --- Cargo.lock | 17 + .../src/transaction_executor.rs | 10 - .../tari_indexer/src/json_rpc/handlers.rs | 4 +- applications/tari_swarm_daemon/Cargo.toml | 1 + applications/tari_swarm_daemon/src/cli.rs | 2 + applications/tari_swarm_daemon/src/config.rs | 7 +- applications/tari_swarm_daemon/src/main.rs | 6 +- .../src/process_manager/instances/manager.rs | 8 +- .../src/process_manager/manager.rs | 42 ++- .../src/webserver/rpc/validator_nodes.rs | 2 + .../webui/src/routes/Main.tsx | 39 ++- .../webui/src/utils/json_rpc.tsx | 4 +- .../tari_validator_node/src/bootstrap.rs | 3 +- .../consensus/block_transaction_executor.rs | 27 -- .../src/json_rpc/handlers.rs | 6 +- .../src/p2p/services/mempool/gossip.rs | 6 +- .../src/p2p/services/mempool/service.rs | 11 +- .../src/p2p/services/messaging/outbound.rs | 2 +- dan_layer/common_types/src/committee.rs | 10 +- dan_layer/consensus/src/hotstuff/common.rs | 26 +- dan_layer/consensus/src/hotstuff/error.rs | 5 + .../src/hotstuff/on_message_validate.rs | 148 +++++++-- .../consensus/src/hotstuff/on_propose.rs | 95 ++++-- .../on_ready_to_vote_on_local_block.rs | 298 +++++++++--------- .../hotstuff/on_receive_foreign_proposal.rs | 222 ++++++++----- .../src/hotstuff/on_receive_local_proposal.rs | 43 +-- .../hotstuff/on_receive_new_transaction.rs | 4 +- .../src/hotstuff/substate_store/error.rs | 6 +- .../hotstuff/substate_store/pending_store.rs | 35 +- .../hotstuff/transaction_manager/manager.rs | 55 ++-- .../hotstuff/transaction_manager/prepared.rs | 6 +- dan_layer/consensus/src/hotstuff/worker.rs | 79 +++-- dan_layer/consensus/src/messages/proposal.rs | 18 +- dan_layer/consensus_tests/src/consensus.rs | 40 ++- .../consensus_tests/src/substate_store.rs | 4 +- .../src/support/epoch_manager.rs | 14 +- .../src/support/executions_store.rs | 10 +- .../consensus_tests/src/support/harness.rs | 39 ++- .../src/support/transaction.rs | 63 ++-- dan_layer/engine_types/src/substate.rs | 16 + .../base_layer/base_layer_epoch_manager.rs | 3 +- .../epoch_manager/src/base_layer/handle.rs | 3 +- .../epoch_manager/src/base_layer/types.rs | 3 +- dan_layer/epoch_manager/src/traits.rs | 3 +- dan_layer/rpc_state_sync/src/manager.rs | 174 +++++----- .../up.sql | 47 ++- dan_layer/state_store_sqlite/src/reader.rs | 1 + dan_layer/state_store_sqlite/src/schema.rs | 24 ++ .../src/sql_models/foreign_parked_block.rs | 34 ++ .../state_store_sqlite/src/sql_models/mod.rs | 2 + .../src/sql_models/transaction_pool.rs | 12 +- dan_layer/state_store_sqlite/src/writer.rs | 232 ++++++++++---- .../storage/src/consensus_models/block.rs | 22 +- .../src/consensus_models/block_pledges.rs | 10 +- .../storage/src/consensus_models/command.rs | 236 ++------------ .../storage/src/consensus_models/evidence.rs | 253 +++++++++++++++ .../foreign_parked_proposal.rs | 77 +++++ dan_layer/storage/src/consensus_models/mod.rs | 4 + .../storage/src/consensus_models/substate.rs | 2 +- .../src/consensus_models/transaction.rs | 20 +- .../src/consensus_models/transaction_pool.rs | 77 +++-- .../transaction_pool_status_update.rs | 4 + .../storage/src/global/backend_adapter.rs | 3 +- .../storage/src/global/validator_node_db.rs | 4 +- dan_layer/storage/src/state_store/mod.rs | 22 +- .../src/global/backend_adapter.rs | 79 ++--- .../src/global/models/committee.rs | 18 +- .../storage_sqlite/src/global/models/mod.rs | 4 + dan_layer/storage_sqlite/tests/global_db.rs | 4 +- dan_layer/transaction/src/transaction.rs | 17 +- dan_layer/transaction/src/transaction_id.rs | 7 + 71 files changed, 1802 insertions(+), 1032 deletions(-) create mode 100644 dan_layer/state_store_sqlite/src/sql_models/foreign_parked_block.rs create mode 100644 dan_layer/storage/src/consensus_models/evidence.rs create mode 100644 dan_layer/storage/src/consensus_models/foreign_parked_proposal.rs diff --git a/Cargo.lock b/Cargo.lock index 590bb748ce..9efa12da88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2328,6 +2328,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7" +[[package]] +name = "deunicode" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" + [[package]] name = "dialoguer" version = "0.10.4" @@ -8197,6 +8203,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slug" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882a80f72ee45de3cc9a5afeb2da0331d58df69e4e7d8eeb5d3c7784ae67e724" +dependencies = [ + "deunicode", + "wasm-bindgen", +] + [[package]] name = "sluice" version = "0.5.5" @@ -9849,6 +9865,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "slug", "tari_common", "tari_common_types", "tari_core", diff --git a/applications/tari_dan_app_utilities/src/transaction_executor.rs b/applications/tari_dan_app_utilities/src/transaction_executor.rs index e8793f97b2..2ee288b18d 100644 --- a/applications/tari_dan_app_utilities/src/transaction_executor.rs +++ b/applications/tari_dan_app_utilities/src/transaction_executor.rs @@ -130,16 +130,6 @@ where TTemplateProvider: TemplateProvider