Skip to content

Commit

Permalink
Fix DKG Events (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekohex authored Jul 18, 2023
1 parent 8da0018 commit 45d82d2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 41 additions & 6 deletions pallets/dkg-metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ use dkg_runtime_primitives::{
traits::{GetDKGPublicKey, OnAuthoritySetChangeHandler},
utils::{ecdsa, to_slice_33, verify_signer_from_set_ecdsa},
AggregatedMisbehaviourReports, AggregatedPublicKeys, AuthorityIndex, AuthoritySet,
ConsensusLog, MisbehaviourType, ProposalHandlerTrait, RefreshProposal, DKG_ENGINE_ID,
ConsensusLog, MisbehaviourType, ProposalHandlerTrait, ProposalNonce, RefreshProposal,
DKG_ENGINE_ID,
};
use frame_support::{
dispatch::DispatchResultWithPostInfo,
Expand Down Expand Up @@ -706,11 +707,37 @@ pub mod pallet {
/// Next public key submitted
NextPublicKeySubmitted { compressed_pub_key: Vec<u8> },
/// Next public key signature submitted
NextPublicKeySignatureSubmitted { signature: Vec<u8>, refresh_proposal: RefreshProposal },
NextPublicKeySignatureSubmitted {
/// The merkle root of the voters (validators)
voter_merkle_root: [u8; 32],
/// The session length in milliseconds
session_length: u64,
/// The number of voters
voter_count: u32,
/// The refresh nonce for the rotation
nonce: ProposalNonce,
/// The public key of the governor
pub_key: Vec<u8>,
/// The Signature of the data above, concatenated.
signature: Vec<u8>,
},
/// Current Public Key Changed.
PublicKeyChanged { compressed_pub_key: Vec<u8> },
/// Current Public Key Signature Changed.
PublicKeySignatureChanged { signature: Vec<u8>, refresh_proposal: RefreshProposal },
PublicKeySignatureChanged {
/// The merkle root of the voters (validators)
voter_merkle_root: [u8; 32],
/// The session length in milliseconds
session_length: u64,
/// The number of voters
voter_count: u32,
/// The refresh nonce for the rotation
nonce: ProposalNonce,
/// The public key of the governor
pub_key: Vec<u8>,
/// The Signature of the data above, concatenated.
signature: Vec<u8>,
},
/// Misbehaviour reports submitted
MisbehaviourReportsSubmitted {
misbehaviour_type: MisbehaviourType,
Expand Down Expand Up @@ -1846,10 +1873,14 @@ impl<T: Config> Pallet<T> {
});

// At this point the refresh proposal should ALWAYS exist
if let Some(curr_prop) = CurrentRefreshProposal::<T>::get() {
if let Some(curr) = CurrentRefreshProposal::<T>::get() {
Self::deposit_event(Event::PublicKeySignatureChanged {
voter_merkle_root: curr.voter_merkle_root,
session_length: curr.session_length,
voter_count: curr.voter_count,
nonce: curr.nonce,
pub_key: curr.pub_key,
signature: next_pub_key_signature.into(),
refresh_proposal: curr_prop,
});

CurrentRefreshProposal::<T>::kill();
Expand Down Expand Up @@ -2426,8 +2457,12 @@ impl<T: Config> OnSignedProposal<T::MaxProposalLength> for Pallet<T> {

// Emit the event
Self::deposit_event(Event::NextPublicKeySignatureSubmitted {
refresh_proposal: curr,
signature: proposal.signature().unwrap_or_default(),
voter_merkle_root: curr.voter_merkle_root,
session_length: curr.session_length,
voter_count: curr.voter_count,
nonce: curr.nonce,
pub_key: curr.pub_key,
});
};

Expand Down
12 changes: 6 additions & 6 deletions scripts/run-local-testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ cd "$PROJECT_ROOT"
echo "*** Start Webb DKG Node ***"
# Alice
./target/release/dkg-standalone-node --tmp --chain local --validator -lerror --alice --output-path=./tmp/alice/output.log \
--rpc-cors all --ws-external --rpc-methods=unsafe \
--rpc-cors all --rpc-external --rpc-methods=unsafe \
--port ${ports[0]} \
--ws-port 9944 --node-key 0000000000000000000000000000000000000000000000000000000000000001 &
--rpc-port 9944 --node-key 0000000000000000000000000000000000000000000000000000000000000001 &
# Bob
./target/release/dkg-standalone-node --tmp --chain local --validator -lerror --bob --output-path=./tmp/bob/output.log \
--rpc-cors all --ws-external --rpc-methods=unsafe \
--rpc-cors all --rpc-external --rpc-methods=unsafe \
--port ${ports[1]} \
--ws-port 9945 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp &
--rpc-port 9945 --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp &
# Charlie
./target/release/dkg-standalone-node --tmp --chain local --validator -linfo --charlie --output-path=./tmp/charlie/output.log \
--rpc-cors all --ws-external \
--ws-port 9948 \
--rpc-cors all --rpc-external \
--rpc-port 9948 \
--port ${ports[2]} \
-ldkg=debug \
-ldkg_gadget::worker=debug \
Expand Down

0 comments on commit 45d82d2

Please sign in to comment.