-
Notifications
You must be signed in to change notification settings - Fork 2
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 TDX test network chainspec #1204
Changes from all commits
33f2e2f
8a7d5f6
4c44a70
0c95702
8cad165
b31180e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
|
||
pub mod dev; | ||
pub mod integration_tests; | ||
pub mod tdx_testnet; | ||
pub mod testnet; | ||
|
||
pub use entropy_runtime::{AccountId, RuntimeGenesisConfig, Signature}; | ||
|
@@ -47,7 +48,10 @@ use serde_json::json; | |
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; | ||
use sp_consensus_babe::AuthorityId as BabeId; | ||
use sp_core::{sr25519, Pair, Public}; | ||
use sp_runtime::traits::{IdentifyAccount, Verify}; | ||
use sp_runtime::{ | ||
traits::{ConstU32, IdentifyAccount, Verify}, | ||
BoundedVec, | ||
}; | ||
|
||
type AccountPublic = <Signature as Verify>::Signer; | ||
|
||
|
@@ -215,3 +219,6 @@ pub fn authority_keys_from_seed( | |
get_from_seed::<AuthorityDiscoveryId>(seed), | ||
) | ||
} | ||
|
||
/// Accepted build time measurement values for TDX attestation | ||
pub type MrtdValues = Vec<BoundedVec<u8, ConstU32<48>>>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type alias is already present in the parameters pallet, so possibly we could avoid duplicating it by having that as a dependency, or putting it in entropy-shared. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say it's fine for now, if we use it more then we can move it somewhere better |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright (C) 2023 Entropy Cryptography Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// 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 crate::chain_spec::{dev::development_genesis_config, get_account_id_from_seed, ChainSpec}; | ||
|
||
use entropy_runtime::wasm_binary_unwrap; | ||
use entropy_shared::{BoundedVecEncodedVerifyingKey, X25519PublicKey as TssX25519PublicKey}; | ||
use sc_service::ChainType; | ||
use sp_core::sr25519; | ||
use sp_runtime::BoundedVec; | ||
|
||
/// The build time measurement value from the current entropy-tss VM images | ||
const ACCEPTED_MRTD: [u8; 48] = [ | ||
145, 235, 43, 68, 209, 65, 212, 236, 224, 159, 12, 117, 194, 197, 61, 36, 122, 60, 104, 237, | ||
215, 250, 254, 138, 53, 32, 201, 66, 166, 4, 164, 7, 222, 3, 174, 109, 197, 248, 127, 39, 66, | ||
139, 37, 56, 135, 49, 24, 183, | ||
]; | ||
|
||
lazy_static::lazy_static! { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A comment explaining how to generate this would be helpful There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is specific to our current box so probably this also should be read in from an environment variable or file no i think about it - but for now i will just put a comment explaining what it is. |
||
/// This is the PCK from the certificates of the current TDX machine we are using for testing | ||
pub static ref PCK: BoundedVecEncodedVerifyingKey = vec![ | ||
2, 166, 103, 136, 58, 157, 155, 124, 186, 75, 81, 133, 87, 255, 233, 182, 192, 125, 235, 230, | ||
121, 173, 147, 108, 47, 190, 240, 181, 75, 181, 31, 148, 128, | ||
].try_into().unwrap(); | ||
} | ||
|
||
fn tdx_devnet_four_node_initial_tss_servers( | ||
) -> Vec<(sp_runtime::AccountId32, TssX25519PublicKey, String, BoundedVecEncodedVerifyingKey)> { | ||
let tss_ip = std::env::var("ENTROPY_TESTNET_TSS_IP") | ||
.expect("ENTROPY_TESTNET_TSS_IP environment variable to be set"); | ||
Comment on lines
+41
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why panic here instead of having a fallback to a default IP? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what default IP we can fallback to. |
||
|
||
let alice = ( | ||
crate::chain_spec::tss_account_id::ALICE.clone(), | ||
crate::chain_spec::tss_x25519_public_key::ALICE, | ||
format!("{tss_ip}:3001"), | ||
PCK.clone(), | ||
); | ||
|
||
let bob = ( | ||
crate::chain_spec::tss_account_id::BOB.clone(), | ||
crate::chain_spec::tss_x25519_public_key::BOB, | ||
format!("{tss_ip}:3002"), | ||
PCK.clone(), | ||
); | ||
|
||
let charlie = ( | ||
crate::chain_spec::tss_account_id::CHARLIE.clone(), | ||
crate::chain_spec::tss_x25519_public_key::CHARLIE, | ||
format!("{tss_ip}:3003"), | ||
PCK.clone(), | ||
); | ||
|
||
let dave = ( | ||
crate::chain_spec::tss_account_id::DAVE.clone(), | ||
crate::chain_spec::tss_x25519_public_key::DAVE, | ||
format!("{tss_ip}:3004"), | ||
PCK.clone(), | ||
); | ||
|
||
vec![alice, bob, charlie, dave] | ||
} | ||
|
||
/// The configuration used for the TDX testnet. | ||
/// | ||
/// Since Entropy requires at two-of-three threshold setup, and requires an additional relayer node, | ||
/// we spin up four validators: Alice, Bob, Charlie and Dave. | ||
pub fn tdx_testnet_config() -> ChainSpec { | ||
ChainSpec::builder(wasm_binary_unwrap(), Default::default()) | ||
.with_name("TDX-testnet") | ||
.with_id("tdx") | ||
.with_chain_type(ChainType::Development) | ||
.with_properties(crate::chain_spec::entropy_properties()) | ||
.with_genesis_config_patch(development_genesis_config( | ||
vec![ | ||
crate::chain_spec::authority_keys_from_seed("Alice"), | ||
crate::chain_spec::authority_keys_from_seed("Bob"), | ||
crate::chain_spec::authority_keys_from_seed("Charlie"), | ||
crate::chain_spec::authority_keys_from_seed("Dave"), | ||
], | ||
vec![], | ||
get_account_id_from_seed::<sr25519::Public>("Alice"), | ||
tdx_devnet_four_node_initial_tss_servers(), | ||
Some(vec![BoundedVec::try_from(ACCEPTED_MRTD.to_vec()).unwrap()]), | ||
)) | ||
.build() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since in most cases we use the mock values, i've made this an option which if not given will use the mock values.