Skip to content

Conversation

@joyqvq
Copy link
Collaborator

@joyqvq joyqvq commented Oct 25, 2025

Description

Test plan

make the config file: crates/key-server/key-server-config.example

network: Testnet
server_mode: !Committee
  member_address: '0x0636157e9d013585ff473b3b378499ac2f1d207ed07d70e2cd815711725bca9d'
  key_server_obj_id: '0x5b4b868b22f4e1e87d3938f29aefc71a1e1ddf7352e214088c9eaf37e31efd31'
  target_key_server_version: 1

run with

CONFIG_PATH=crates/key-server/key-server-config.example MASTER_SHARE_V1=0x03899294f5e6551631fcbaea5583367fb565471adeccb220b769879c55e66ed9 cargo run --bin key-server

output:

2025-11-14T21:39:20.085704Z  INFO key_server::key_server_options: Validating KeyServerOptions:
network: Testnet
server_mode: !Committee
  member_address: 0x0636157e9d013585ff473b3b378499ac2f1d207ed07d70e2cd815711725bca9d
  key_server_obj_id: 0x5b4b868b22f4e1e87d3938f29aefc71a1e1ddf7352e214088c9eaf37e31efd31
  target_key_server_version: 1
2025-11-14T21:39:20.281357Z  INFO key_server: Server started with network: Testnet
2025-11-14T21:39:20.364939Z  INFO key_server::master_keys: Loading keys from env variables
2025-11-14T21:39:20.391359Z  INFO key_server: Committee mode: KeyServer 0x5b4b868b22f4e1e87d3938f29aefc71a1e1ddf7352e214088c9eaf37e31efd31 with party_id=1
2025-11-14T21:39:20.479348Z  INFO key_server: Initial current version: 1, config target version: 1
2025-11-14T21:39:20.479409Z  INFO key_server: Active mode: current version 1 matches target. Do not start version monitor.

@joyqvq joyqvq changed the base branch from main to joy/dkg-init-cli October 25, 2025 02:49
@joyqvq joyqvq force-pushed the joy/dkg-init-cli branch 2 times, most recently from 246025c to d9174d5 Compare October 30, 2025 17:52
@joyqvq joyqvq changed the base branch from joy/dkg-init-cli to joy/seal-committee-only October 30, 2025 17:56
Base automatically changed from joy/seal-committee-only to main October 31, 2025 16:12
@joyqvq joyqvq force-pushed the joy/server-mode branch 3 times, most recently from 9752b01 to 05a3799 Compare October 31, 2025 23:54
@joyqvq joyqvq changed the title Joy/server mode [key-server] handle committee mode Oct 31, 2025
@joyqvq joyqvq marked this pull request as ready for review October 31, 2025 23:56
@joyqvq joyqvq force-pushed the joy/server-mode branch 2 times, most recently from adee3a1 to 4b433e7 Compare November 5, 2025 01:24
#[derive(Clone)]
pub(crate) enum CommitteeKeyState {
Active {
master_key: IbeMasterKey,
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can move master_share to Committee enum

Copy link
Collaborator Author

@joyqvq joyqvq Nov 12, 2025

Choose a reason for hiding this comment

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

you mean collapse it into pub enum ServerMode?

i was considering this, KeyServerOptions that has ServerMode also has a bunch of "configurations", is it a good idea to move key materials there? (perhaps thats why it was set up separately before?)

@joyqvq joyqvq force-pushed the joy/server-mode branch 2 times, most recently from 9c53815 to 0cf46e3 Compare November 12, 2025 21:58
@joyqvq
Copy link
Collaborator Author

joyqvq commented Nov 12, 2025

cc @benr-ml i revised it to use the key server obj instead of committee. im still working on adding more tests, but see pr description and lmk if they make sense high level?

@joyqvq joyqvq force-pushed the joy/server-mode branch 3 times, most recently from 4c7d38a to e32447f Compare November 12, 2025 23:09
@benr-ml
Copy link
Collaborator

benr-ml commented Nov 13, 2025

cc @benr-ml i revised it to use the key server obj instead of committee. im still working on adding more tests, but see pr description and lmk if they make sense high level?

yes, the high level makes sense. perhaps we can use env variable MASTER_SHARE_X for version X to make it slightly more explicit

@joyqvq joyqvq force-pushed the joy/server-mode branch 6 times, most recently from 08fc13b to 5496c63 Compare November 14, 2025 21:56
@joyqvq joyqvq requested a review from benr-ml November 14, 2025 21:57
@joyqvq joyqvq force-pushed the joy/server-mode branch 2 times, most recently from 3f4620c to e4303e1 Compare November 17, 2025 18:41
# - "0x3333333333333333333333333333333333333333333333333333333333333333"

# #### COMMITTEE MODE ####
# See step 7 in the member runbook for fresh DKG and key rotation in details.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# See step 7 in the member runbook for fresh DKG and key rotation in details.
# See the runbook for fresh DKG and key rotation in details.

# #### COMMITTEE MODE ####
# See step 7 in the member runbook for fresh DKG and key rotation in details.
#
# Environment variables use versioned naming: MASTER_SHARE_VX
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Environment variables use versioned naming: MASTER_SHARE_VX
# Environment variables use versioned naming: MASTER_SHARE_VX where X is a version of the committee (e.g. 1)

# Environment variables use versioned naming: MASTER_SHARE_VX
#
# - For active mode (onchain version = target version = X):
# Must provide MASTER_SHARE_VX where X matches both onchain and target versions.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Must provide MASTER_SHARE_VX where X matches both onchain and target versions.
# Must set the env variable MASTER_SHARE_VX where X matches the onchain version.

# Example: For version 0, set MASTER_SHARE_V0, other versioned shares will be ignored.
#
# - For rotation mode (onchain version = X, target version = X+1):
# Must provide MASTER_SHARE_VX and MASTER_SHARE_VX+1.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Must provide MASTER_SHARE_VX and MASTER_SHARE_VX+1.
# Must set the env variables MASTER_SHARE_VX and MASTER_SHARE_VY where Y = X+1

# Must provide MASTER_SHARE_VX and MASTER_SHARE_VX+1.
# The server uses MASTER_SHARE_VX and automatically switches to MASTER_SHARE_VX+1
# when the onchain version updates to X+1.
# Example: For rotation from v1 to v2, set both MASTER_SHARE_V1 and MASTER_SHARE_V2.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Example: For rotation from v1 to v2, set both MASTER_SHARE_V1 and MASTER_SHARE_V2.
# Example: For rotation from version 1 to 2, set both MASTER_SHARE_V1 and MASTER_SHARE_V2.

# server_mode: !Committee
# member_address: '<MY_ADDRESS>'
# key_server_obj_id: '<KEY_SERVER_OBJ_ID>'
# target_key_server_version: 2
Copy link
Collaborator

@benr-ml benr-ml Nov 19, 2025

Choose a reason for hiding this comment

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

abusing target_key_server_version for both cases confused me a bit, maybe we could make it more explicit - instead of target_key_server_version , use committee_state: enum { Active, Rotation(target_version) } - if Active, determine the version from the ks obj; if Rotation, determine both versions from target_version?

let master_keys = MasterKeys::load(&options).unwrap_or_else(|e| {

// Fetch current version onchain.
let current_version = match &options.server_mode {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let current_version = match &options.server_mode {
let committee_version = match &options.server_mode {

// Derive KeyServerV2 dynamic field ID on KeyServer object.
// This is a regular dynamic_field, not dynamic_object_field.
// Key type: u64, Key value: EXPECTED_KEY_SERVER_VERSION
let v2_field_name_bcs = bcs::to_bytes(&EXPECTED_KEY_SERVER_VERSION)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let v2_field_name_bcs = bcs::to_bytes(&EXPECTED_KEY_SERVER_VERSION)?;
let v2_field_name_bcs = bcs::to_bytes(&EXPECTED_KEY_SERVER_VERSION).unwrap();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants