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 TDX test network chainspec #1204

Merged
merged 6 commits into from
Dec 11, 2024
Merged

Add TDX test network chainspec #1204

merged 6 commits into from
Dec 11, 2024

Conversation

ameba23
Copy link
Contributor

@ameba23 ameba23 commented Dec 6, 2024

This add a chainspec type for the setup i am currently using for a simple test network with the TSS servers running in TDX virtual machines.

It is just the development chainspec with a custom TSS endpoint (we need TSS nodes to have their public IP address), custom PCK certificates (we can't use the mock ones), and a custom accepted MRTD value from the entropy-tss VM image i am currently using.

I don't want to hardcode the IP address as i think it will probably change (hopefully we find something cheaper!), so it is read from an environment variable.

Currently the PCK is hard-coded. Ideally i would like to read it in from a certificate file, using the same code that the staking extension pallet uses to extract and verify PCKs from certificates. But this would mean having the staking pallet be a direct dependency of the node CLI, which is kinda weird. Maybe that code should be extracted to a separate crate. Since this code may change anyway if we switch to using dcap-qvl, i am going to kick this decision down the road.

For details of how the TSS nodes are deployed see entropyxyz/tdx-build-system#5

@ameba23 ameba23 marked this pull request as draft December 6, 2024 10:17
@ameba23 ameba23 self-assigned this Dec 6, 2024
@ameba23 ameba23 added this to the v0.4.0 milestone Dec 6, 2024
@ameba23 ameba23 marked this pull request as ready for review December 9, 2024 10:04
@@ -283,10 +288,10 @@ pub fn development_genesis_config(
max_instructions_per_programs: INITIAL_MAX_INSTRUCTIONS_PER_PROGRAM,
total_signers: TOTAL_SIGNERS,
threshold: SIGNER_THRESHOLD,
accepted_mrtd_values: vec![
accepted_mrtd_values: accepted_mrtd_values.unwrap_or(vec![
Copy link
Contributor Author

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.

@@ -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>>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator

Choose a reason for hiding this comment

The 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

Copy link
Collaborator

@HCastano HCastano left a comment

Choose a reason for hiding this comment

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

Couple comments, but looks good

Comment on lines +40 to +41
let tss_ip = std::env::var("ENTROPY_TESTNET_TSS_IP")
.expect("ENTROPY_TESTNET_TSS_IP environment variable to be set");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why panic here instead of having a fallback to a default IP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what default IP we can fallback to. localhost wont work because these are the IPs which the TSS nodes use to communicate with each other, and from the CVM point of view localhost is not the same as localhost on the host. I don't really want to hardcode the public IP of our current box.

Comment on lines 80 to 81
.with_name("Development")
.with_id("dev")
Copy link
Collaborator

Choose a reason for hiding this comment

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

These should be updated to be "TDX-something"

Comment on lines 74 to 78
/// The configuration used for development.
///
/// 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 development_config() -> ChainSpec {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

139, 37, 56, 135, 49, 24, 183,
];

lazy_static::lazy_static! {
Copy link
Collaborator

Choose a reason for hiding this comment

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

A comment explaining how to generate this would be helpful

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@@ -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>>>;
Copy link
Collaborator

Choose a reason for hiding this comment

The 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

@ameba23 ameba23 merged commit 44f80c2 into master Dec 11, 2024
8 checks passed
@ameba23 ameba23 deleted the peg/tdx-testnet-chainspec branch December 11, 2024 10:11
ameba23 added a commit that referenced this pull request Dec 13, 2024
* master:
  Add TDX test network chainspec (#1204)
  Test CLI command to retrieve quote and change endpoint / TSS account in one command (#1198)
  Bump the patch-dependencies group with 2 updates (#1212)
  Bump thiserror from 2.0.4 to 2.0.6 in the patch-dependencies group (#1206)
  Downgrade parity-scale-codec as version we currently use has been yanked (#1205)
  Bump clap from 4.5.22 to 4.5.23 in the patch-dependencies group (#1202)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants