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

Add option to start in a pre-jumpstarted state to genesis config #1162

Merged
merged 29 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6327119
Add pre-jumpstart option to chainspec and helper fn, update tests
ameba23 Nov 12, 2024
406a305
Dont include JumpStartDetails in staking pallet config, only ids of t…
ameba23 Nov 13, 2024
a4dcf5e
Update mock config for propagation and registry pallets
ameba23 Nov 13, 2024
1d4eb58
Comments, tidy
ameba23 Nov 13, 2024
ebe7280
Add new field to attestation pallet mock
ameba23 Nov 14, 2024
3489e4a
Update client tests
ameba23 Nov 14, 2024
5052741
Fix issue with test helper fn
ameba23 Nov 14, 2024
ff676d2
Add pre-generated keyshares directly to the kvdb, rather than using t…
ameba23 Nov 14, 2024
082fac3
Update integratiion test chain spec
ameba23 Nov 14, 2024
8ead21b
Fixes for pre-jumpstarted state in tests - mocking jump start no long…
ameba23 Nov 15, 2024
e94c4e3
Update reshare test
ameba23 Nov 15, 2024
02147a8
Update client tests
ameba23 Nov 15, 2024
c80a8f0
Typo
ameba23 Nov 15, 2024
17d4b02
Tidy test
ameba23 Nov 22, 2024
0204c83
Tidy test
ameba23 Nov 22, 2024
4381c76
Fix for deadline issue
ameba23 Nov 25, 2024
874a206
Rm unused variable
ameba23 Nov 25, 2024
202b0df
Fix local storage for rotate network key endpoint
ameba23 Nov 25, 2024
dd7f797
Update test
ameba23 Nov 25, 2024
a1f4bca
Clippy
ameba23 Nov 25, 2024
170b5cc
Clippy
ameba23 Nov 25, 2024
04b8309
Fix remaining tests
ameba23 Nov 25, 2024
94f13f7
Fix tests, tidy
ameba23 Nov 26, 2024
895a118
Update generated keyshares
ameba23 Nov 26, 2024
d9f2d9a
Update script to generate keyshares
ameba23 Nov 26, 2024
476e327
Update script to generate keyshares readme
ameba23 Nov 26, 2024
6b66e65
Tidy
ameba23 Nov 26, 2024
6aeb958
Merge peg/dont-mock-propagation, lower test reshare block number
ameba23 Nov 26, 2024
6f91f3f
Undo testnet reshare fix
ameba23 Nov 26, 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
21 changes: 6 additions & 15 deletions crates/client/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ use crate::{
};
use entropy_testing_utils::{
constants::{TEST_PROGRAM_WASM_BYTECODE, TSS_ACCOUNTS},
helpers::{derive_mock_pck_verifying_key, encode_verifying_key},
jump_start_network, spawn_testing_validators,
helpers::{
derive_mock_pck_verifying_key, encode_verifying_key, spawn_tss_nodes_and_start_chain,
},
substrate_context::test_context_stationary,
test_node_process_testing_state, ChainSpecType,
ChainSpecType,
};
use serial_test::serial;
use sp_core::{sr25519, Pair, H256};
Expand Down Expand Up @@ -134,18 +135,8 @@ async fn test_store_and_remove_program() {
async fn test_remove_program_reference_counter() {
let program_owner = AccountKeyring::Ferdie.pair();

let (_validator_ips, _validator_ids) =
spawn_testing_validators(ChainSpecType::Integration).await;

let force_authoring = true;
let substrate_context = &test_node_process_testing_state(force_authoring).await[0];
let api = get_api(&substrate_context.ws_url).await.unwrap();
let rpc = get_rpc(&substrate_context.ws_url).await.unwrap();

// Jumpstart the network
let alice = AccountKeyring::Alice;
let signer = PairSigner::<EntropyConfig, sr25519::Pair>::new(alice.clone().into());
jump_start_network(&api, &rpc, &signer).await;
let (_ctx, api, rpc, _validator_ips, _validator_ids) =
spawn_tss_nodes_and_start_chain(ChainSpecType::IntegrationJumpStarted).await;

// Store a program
let program_pointer = store_program(
Expand Down
6 changes: 5 additions & 1 deletion crates/protocol/src/execute_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ pub async fn execute_reshare(
(ThresholdKeyShare<KeyParams, PartyId>, AuxInfo<KeyParams, PartyId>),
ProtocolExecutionErr,
> {
tracing::debug!("Executing proactive refresh");
tracing::info!("Executing reshare");
tracing::debug!("Signing with {:?}", &threshold_pair.public());

let pair = PairWrapper(threshold_pair.clone());
Expand All @@ -394,9 +394,13 @@ pub async fn execute_reshare(
.map_err(ProtocolExecutionErr::SessionCreation)?;

let (new_key_share, chans) = execute_protocol_generic(chans, session, session_id_hash).await?;

tracing::info!("Completed reshare protocol");

let aux_info = if let Some(aux_info) = aux_info_option {
aux_info
} else {
tracing::info!("Executing aux gen session as part of reshare");
// Now run an aux gen session
let session_id_hash_aux_data = session_id.blake2(Some(Subsession::AuxGen))?;
let session = make_aux_gen_session(
Expand Down
2 changes: 1 addition & 1 deletion crates/shared/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub const MAX_SIGNERS: u8 = 15;
pub const SIGNER_THRESHOLD: u8 = 2;

/// For testing to line up chain mock data and reshare_test
pub const TEST_RESHARE_BLOCK_NUMBER: u32 = 22;
pub const TEST_RESHARE_BLOCK_NUMBER: u32 = 10;

/// Program version number, must be incremented if version number changes
pub const PROGRAM_VERSION_NUMBER: u8 = 0;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
43 changes: 20 additions & 23 deletions crates/testing-utils/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use crate::{
chain_api::{get_api, get_rpc, EntropyConfig},
spawn_testing_validators,
substrate_context::{test_context_stationary, test_node_process_testing_state},
ChainSpecType,
substrate_context::test_node_process_testing_state,
ChainSpecType, TestNodeProcess,
};
use entropy_protocol::PartyId;
use rand::{rngs::StdRng, SeedableRng};
Expand All @@ -26,31 +26,28 @@ pub use tdx_quote::encode_verifying_key;

/// A helper for setting up tests which starts both a set of TS servers and a chain node and returns
/// the chain API as well as IP addresses and PartyId of the started validators
///
/// Note that since this function does not reside in entropy-tss, cfg(test) will be false when the
/// TSS nodes are set up, meaning the unsafe API will not be enabled
pub async fn spawn_tss_nodes_and_start_chain(
chain_spec_type: ChainSpecType,
) -> (OnlineClient<EntropyConfig>, LegacyRpcMethods<EntropyConfig>, Vec<String>, Vec<PartyId>) {
) -> (
Vec<TestNodeProcess<EntropyConfig>>,
OnlineClient<EntropyConfig>,
LegacyRpcMethods<EntropyConfig>,
Vec<String>,
Vec<PartyId>,
) {
let (validator_ips, validator_ids) = spawn_testing_validators(chain_spec_type).await;

let (api, rpc) = match chain_spec_type {
ChainSpecType::Development => {
let substrate_context = test_context_stationary().await;
(
get_api(&substrate_context.node_proc.ws_url).await.unwrap(),
get_rpc(&substrate_context.node_proc.ws_url).await.unwrap(),
)
},
ChainSpecType::Integration => {
// Here we need to use `--chain=integration-tests` and force authoring otherwise we won't be
// able to get our chain in the right state to be jump started.
let force_authoring = true;
let substrate_context = &&test_node_process_testing_state(force_authoring).await[0];
(
get_api(&substrate_context.ws_url).await.unwrap(),
get_rpc(&substrate_context.ws_url).await.unwrap(),
)
},
};
(api, rpc, validator_ips, validator_ids)
// Here we need to force authoring otherwise we won't be able to get our chain in the right
// state to be jump started.
let force_authoring = true;
let substrate_context = test_node_process_testing_state(chain_spec_type, force_authoring).await;
let api = get_api(&substrate_context[0].ws_url).await.unwrap();
let rpc = get_rpc(&substrate_context[0].ws_url).await.unwrap();

(substrate_context, api, rpc, validator_ips, validator_ids)
}

/// Get the mock PCK that will be used for a given TSS account ID
Expand Down
4 changes: 1 addition & 3 deletions crates/testing-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ pub mod create_test_keyshares;
pub mod helpers;
mod node_proc;
pub mod substrate_context;
pub use entropy_tss::helpers::tests::{
jump_start_network_with_signer as jump_start_network, spawn_testing_validators, ChainSpecType,
};
pub use entropy_tss::helpers::tests::{spawn_testing_validators, ChainSpecType};
pub use node_proc::TestNodeProcess;
pub use substrate_context::*;
10 changes: 6 additions & 4 deletions crates/testing-utils/src/substrate_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use entropy_tss::helpers::tests::ChainSpecType;
use sp_keyring::AccountKeyring;
use subxt::{config::substrate::SubstrateExtrinsicParams, OnlineClient};

Expand Down Expand Up @@ -110,6 +111,7 @@ pub async fn test_node_process_stationary() -> TestNodeProcess<EntropyConfig> {
///
/// Allowing `force_authoring` will produce blocks.
pub async fn test_node_process_testing_state(
chain_spec_type: ChainSpecType,
force_authoring: bool,
) -> Vec<TestNodeProcess<EntropyConfig>> {
let alice_bootnode = Some(
Expand All @@ -118,30 +120,30 @@ pub async fn test_node_process_testing_state(
);
let result = test_node(
AccountKeyring::Alice,
"--chain=integration-tests".to_string(),
format!("--chain={}", chain_spec_type),
force_authoring,
None,
)
.await;
let result_bob = test_node_process_with(
AccountKeyring::Bob,
"--chain=integration-tests".to_string(),
format!("--chain={}", chain_spec_type),
force_authoring,
alice_bootnode.clone(),
Some("http://127.0.0.1:3002".into()),
)
.await;
let result_charlie = test_node_process_with(
AccountKeyring::Charlie,
"--chain=integration-tests".to_string(),
format!("--chain={}", chain_spec_type),
force_authoring,
alice_bootnode.clone(),
Some("http://127.0.0.1:3003".into()),
)
.await;
let result_dave = test_node_process_with(
AccountKeyring::Dave,
"--chain=integration-tests".to_string(),
format!("--chain={}", chain_spec_type),
force_authoring,
alice_bootnode.clone(),
Some("http://127.0.0.1:3004".into()),
Expand Down
Loading
Loading