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

fix: SignedPhase is removed from metadata #803

Merged
merged 7 commits into from
Apr 5, 2024
Merged

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Apr 3, 2024

Because the constant SignedPhase is removed from the metadata we have no good alternative than to hardcode it for now.

The sign phase length is only used to configure the mortality of the submit solution transaction so not super critical if it's slighty off.

In addition I fetched the updated metadata from polkadot master in order to indicate that the signed phase is not exposed in the metadata anymore and updated some polkadot-sdk deps. (this will not break compatibility with older versions)

Because the `SignedPhase` is removed from the metadata we have no good
alternativ than to hardcode this constants for now.
@niklasad1 niklasad1 requested review from gpestana and jsdw April 3, 2024 16:16
Default::default(),
)?;
let params = DefaultExtrinsicParamsBuilder::new().nonce(nonce).build();
let xt = client.chain_api().tx().create_signed(&tx, &*signer, params).await?;
Copy link
Member Author

Choose a reason for hiding this comment

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

changed API in subxt

@@ -209,85 +208,49 @@ async fn run_command(
}

/// Runs until the RPC connection fails or updating the metadata failed.
async fn runtime_upgrade_task(client: Client, tx: oneshot::Sender<Error>, mut spec_version: u32) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this bug has been fixed in subxt and we can rely on that now :)

@@ -9,8 +9,6 @@ pub struct Client {
rpc: RpcClient,
/// Access to chain APIs such as storage, events etc.
chain_api: ChainClient,
/// Raw RPC client.
raw_rpc: RawRpcClient,
Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed anymore

) -> Result<(), Error> {
let tx = epm::signed_solution(RawSolution { solution, score, round })?;

// TODO: https://github.com/paritytech/polkadot-staking-miner/issues/730
//
// The extrinsic mortality length is static and doesn't know when the
// signed phase ends.
let signed_phase_len = client
Copy link

Choose a reason for hiding this comment

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

Just to double check: Instead of fetching the signed phase constant from the chain, we define our own signed phase in the static types.rs. And this is because the constant from the chain wasn't what we'd expect?

Copy link

Choose a reason for hiding this comment

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

from the PR description: its because the SignedPhase is removed from westend in preparation for the merkalized metadata.

Copy link
Member Author

Choose a reason for hiding this comment

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

the SignedPhase is removed from the metadata and it will impact the other chains as well when they update the EPM pallet

Copy link

@lexnv lexnv left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -99,6 +99,9 @@ pub mod westend {
>(16)
);

// SYNC https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/westend/src/lib.rs#L451-#L453.
Copy link

Choose a reason for hiding this comment

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

A crazy idea would be to have a macro which keeps this in sync at compile time or a CI job that fetches that value, but it sounds a bit too complicated since the signed phase depends on multiple constants defined in substrate 🤔

Copy link
Contributor

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

Looks sensible!

@@ -99,6 +99,9 @@ pub mod westend {
>(16)
);

// SYNC https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/westend/src/lib.rs#L451-#L453.
pub const SIGNED_PHASE_LENGTH: u64 = 150;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a temp fix but I wonder if there are any ideas to make sure this value is up to date throughout all chains? or should we just keep a sensible upper bound since this is just used for the tx mortality?

If we leave it as is, I'd suggest us to rename SIGNED_PHASE_LENGTH to SIGNED_PHASE_LENGTH_ESTIMATE or something similar so that the const is now mistakenly used in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

it's removed now and I changed it to use babe::epoch_duration as upper bound/tx mortality ok?

@niklasad1 niklasad1 merged commit 7b0dc3d into main Apr 5, 2024
10 of 11 checks passed
@niklasad1 niklasad1 deleted the fix-borked-polkadot branch April 5, 2024 13:25
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.

4 participants