-
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
Rotate parent network key takes 2 steps #1018
Conversation
…te-parent-network-key-2-steps
// TODO: should this be a two step process? see # https://github.com/entropyxyz/entropy-core/issues/968 | ||
if app_state.kv_store.kv().exists(&network_parent_key).await? { | ||
app_state.kv_store.kv().delete(&network_parent_key).await? | ||
let next_network_parent_key = hex::encode(NEXT_NETWORK_PARENT_KEY); |
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.
Why does this need to be encoded as hex?
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.
the type that the kv takes needs it, but tbh should probably make the const that
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.
👍
serialize(&aux_info_after_rotate).unwrap() | ||
); | ||
|
||
// calling twice doesn't do anything |
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.
👍
Will take a look at this on Monday |
Co-authored-by: peg <[email protected]>
…te-parent-network-key-2-steps
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.
So I don't necessarily think that a two phase approach is bad, but I'm also not sure if we should be adding an extra OCW flow just yet.
I'd either want to see us explore other approaches (e.g maybe just having the TSS subscribe to an on-chain event post-confirmation before deleting), or see where this actually ends up failing in practice with the current implementation.
let latest_block_number = rpc | ||
.chain_get_header(None) | ||
.await? | ||
.ok_or_else(|| ValidatorErr::OptionUnwrapError("Failed to get block number".to_string()))? | ||
.number; |
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.
Here it makes sense to check using the finalized header
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.
no , I think that would fail as this needs to match when the OCW is fired and that isn't on finalized but on block creation
/// Key Rotate Message passed to validators | ||
/// parameters. [BlockNumberFor<T>] |
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.
/// Key Rotate Message passed to validators | |
/// parameters. [BlockNumberFor<T>] | |
/// Key Rotate Message passed to validators parameters. [SOMETHING_MORE_DESCRIPTIVE] |
let network_parent_key_heading = hex::encode(NETWORK_PARENT_KEY); | ||
let next_network_parent_key_heading = hex::encode(NEXT_NETWORK_PARENT_KEY); | ||
|
||
let new_parent_key = app_state.kv_store.kv().get(&next_network_parent_key_heading).await?; | ||
|
||
if app_state.kv_store.kv().exists(&network_parent_key_heading).await? { | ||
app_state.kv_store.kv().delete(&network_parent_key_heading).await?; | ||
}; | ||
|
||
app_state.kv_store.kv().delete(&next_network_parent_key_heading).await?; | ||
|
||
let reservation = app_state.kv_store.kv().reserve_key(network_parent_key_heading).await?; | ||
app_state.kv_store.kv().put(reservation, new_parent_key).await?; |
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.
Does this mean we should get rid of the is_signer_or_delete_parent_key
step in the other flow? We want to wait for this to be called before deleting the parent key
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.
mmm yes that is a good point, that should be moved to the second step
personally Im more in favour of pushing then pulling from the TSS, plus I mean that would break convention here, and it is like we right now always have a flow that the chain pushes to the TSS but randomly we set up one long running listener, I know the ocw code is a little more verbose but I feel pretty strongly about keeping only push methods |
…te-parent-network-key-2-steps
Co-authored-by: Hernando Castano <[email protected]>
Closes #968