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

[Deprecation] Index vs Nonce #243

Closed
7 tasks done
AurevoirXavier opened this issue Nov 8, 2022 · 11 comments
Closed
7 tasks done

[Deprecation] Index vs Nonce #243

AurevoirXavier opened this issue Nov 8, 2022 · 11 comments
Assignees
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. T1-FRAME This PR/Issue is related to core FRAME, the framework. T11-documentation This PR/Issue is related to documentation.

Comments

@AurevoirXavier
Copy link
Contributor

AurevoirXavier commented Nov 8, 2022

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

Why do we need two different names for the same thing?

IMO this adds extra learning effort for developers.

use xxx::Index;
pub use xxx::Index as Nonce;

impl frame_system::Config {
  type Index = Index;
}

substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>;

I think maybe they are two different things.

Index is to describe the transaction index in the block.

Nonce is the account transactions counter.

And they are u32.

But the pub use as makes people confused.


Deprecation steps

@Szegoo
Copy link
Contributor

Szegoo commented Nov 8, 2022

@AurevoirXavier I am probably wrong, but it seems like there aren't any instances of using an alias for Index/Nonce. And if I understand the issue correctly the problem you are mentioning is caused by using type aliases.

@AurevoirXavier
Copy link
Contributor Author

AurevoirXavier commented Nov 9, 2022

@AurevoirXavier I am probably wrong, but it seems like there aren't any instances of using an alias for Index/Nonce. And if I understand the issue correctly the problem you are mentioning is caused by using type aliases.

In some repos, people alias the index to nonce.

As the example shows.

And in the Substrate repo:
We pass the Index to the Nonce field.
https://github.com/paritytech/substrate/blob/a1dee7ecd2a157c490d189f0932b32aa12106857/bin/node/rpc/src/lib.rs#L110

We also pass the Index to the Index field.
https://github.com/paritytech/substrate/blob/a1dee7ecd2a157c490d189f0932b32aa12106857/bin/node/runtime/src/lib.rs#L210

So, I start to think about are these two type the same thing.

Should we unify the name everywhere?

@burdges
Copy link

burdges commented Nov 9, 2022

Aside: Nonce, aka number used only once, typically indicates a security break if you reuse the same number twice. I think nonce advancement cannot stop every possible attacks scenario, like if say two machines sign for a shared account on different forks of the chain, so nonce may warn of some niche scenarios. In principle, you could've stronger by coupling signing to consensus more tightly, but this would create more annoyances too.

@kianenigma
Copy link
Contributor

@juangirini this is another simple deprecation task that we can pilot for a petter process.

Namely, it should be type Nonce in frame_system::Config, not type Index.

You can already see by the usage that this is a bit confusing:

https://github.com/paritytech/substrate/blob/bc3ce835964347166414203d68dccc26b9e9044f/frame/system/src/lib.rs#L1536-L1537

@juangirini juangirini changed the title Index vs Nonce [Deprecation] Index vs Nonce May 24, 2023
@juangirini
Copy link
Contributor

Namely, it should be type Nonce in frame_system::Config, not type Index.

This would break backwards compatibility as existing Config implementations will be still using Index, and we can't set an alias or default value here. A work around would be to create a NewConfig (or whatever we want to call it) with the same types as Config except for the new Nonce instead of the Index type and deprecate Config. But not sure if we want to do this just for one renaming.

@kianenigma do you see an alternative solution?

@kianenigma
Copy link
Contributor

Sadly this cannot be done backwards compatibly.

@juangirini
Copy link
Contributor

I am not sure this renaming is worth the breaking change. If are sure we want to do it we rather do it sooner than later though.

@bkchr @ggwpez @kianenigma @KiChjang any thought on this?

@KiChjang
Copy link
Contributor

KiChjang commented Jun 1, 2023

I'm generally in favor of making sense of things. I think we've already made a bad precedent at times where people have to test every substrate upgrade -- on the list of annoyances, such a naming breaking change would list quite low IMHO, so yes, we should deprecate ASAP.

@xlc
Copy link
Contributor

xlc commented Jun 1, 2023

Rename is not bad compare to other breaking changes... It is just a search & replace and we all are used to this.

@KiChjang
Copy link
Contributor

Fixed in paritytech/substrate#14290.

@juangirini
Copy link
Contributor

This is still open awaiting for the last step of the deprecation todo list to be completed polkadot-developers/substrate-docs#2035

@juangirini juangirini reopened this Aug 25, 2023
@the-right-joyce the-right-joyce added T11-documentation This PR/Issue is related to documentation. C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. T1-FRAME This PR/Issue is related to core FRAME, the framework. and removed I6-documentation labels Aug 25, 2023
@the-right-joyce the-right-joyce added D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. and removed Z1-easy labels Aug 25, 2023
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 8, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 9, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
serban300 pushed a commit to serban300/polkadot-sdk that referenced this issue Apr 10, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
jonathanudd pushed a commit to jonathanudd/polkadot-sdk that referenced this issue Apr 10, 2024
* Bump Substrate to rc5

* Bump async-std to v1.6.2

There was a bug in v.1.6.0 which kept us locked to v1.5 releases.
I think that's fixed now so I'm bumping this.

* Update bridge node runtime

* Update node service

* Update CLI

* Add SystemWeightInfo type to test runtimes

* Add RPC extension builder to service

* Directly return rpc_extensions_builder

* Allow complex types in service

This comes from Substrate, so I'd rather just keep the code as is

* Update benchmarking code for new CLI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. T1-FRAME This PR/Issue is related to core FRAME, the framework. T11-documentation This PR/Issue is related to documentation.
Projects
Status: Done
Development

No branches or pull requests

9 participants