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

with_genesis_config not support u128 type #4853

Closed
AurevoirXavier opened this issue Jun 21, 2024 · 8 comments
Closed

with_genesis_config not support u128 type #4853

AurevoirXavier opened this issue Jun 21, 2024 · 8 comments

Comments

@AurevoirXavier
Copy link
Contributor

AurevoirXavier commented Jun 21, 2024

with_genesis_config requires a serde_json::Value type. But it only supports up to u64.

But I think most chains are using u128 as their balance type.

https://substrate.stackexchange.com/questions/11100/number-out-of-range-on-configuring-balances/11522#11522

@skunert
Copy link
Contributor

skunert commented Jun 21, 2024

I think this was discussed before in #2963 and should have been fixed in #2987. @michalkucharczyk Have not looked deeply, but probably we should enable this feature in sc-chain-spec too?

@AurevoirXavier
Copy link
Contributor Author

AurevoirXavier commented Jun 21, 2024

I think this was discussed before in #2963 and should have been fixed in #2987. @michalkucharczyk Have not looked deeply, but probably we should enable this feature in sc-chain-spec too?

Well, I don't think that's actually a fix on the user side. We still need to construct that JSON on our end and then pass it to the with_genesis_config function.

For instance, if people don't pay attention to this, they will likely fail at:

@AurevoirXavier
Copy link
Contributor Author

AurevoirXavier commented Jun 21, 2024

This should fix the problem.

But should we leave this to the downstream?

What if make this function accept a D: DeserializeOwned or using function chain to add another patch like .with_genesis_config_patch(BalancesConfig { balances: vec![(.., ..)] }).

@michalkucharczyk
Copy link
Contributor

From what I understand, the creation of JSON failed. Not deserialization on runtime side. (some unwrap that is inside json! macro).

@michalkucharczyk
Copy link
Contributor

michalkucharczyk commented Jun 21, 2024

Basically this program fails (and this happens on node side):

[package]
name = "xxx"
version = "0.1.0"
edition = "2021"
[dependencies]
serde_json = {version = "1.0.117", default-features = false, features = ["alloc"] }
fn main() {
	serde_json::json!({
		"balances": {
			"balances": 1u128 << 112
		}
	});
}

@michalkucharczyk
Copy link
Contributor

I think this was discussed before in #2963 and should have been fixed in #2987. @michalkucharczyk Have not looked deeply, but probably we should enable this feature in sc-chain-spec too?

You mean that features shall be merged by cargo? Yeah, we could add this, as sc-chain-spec is on the node side. But I am not 100% sure how features eventually will be resolved.

BTW: if this genesis config was defined on the runtime side (as preset) then this would not be a problem.

@skunert
Copy link
Contributor

skunert commented Jun 24, 2024

Basically this program fails (and this happens on node side):

Yeah was a misconception on my side. Building the JSON the responsibility of the downstream user of polkadot-SDK and easily fixed by arbitrary_precision. IMO we can close here.

@skunert skunert closed this as completed Jun 24, 2024
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

No branches or pull requests

3 participants