-
Notifications
You must be signed in to change notification settings - Fork 30
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
Remove 256bit primitives and deprecated calls #181
base: master
Are you sure you want to change the base?
Conversation
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.
LGTM. Although let's hear from @xermicus before we do this, to ensure that they can live without this for solang.
Makes sense; based on that old PR to add them I get that this could be contentious. But yeah, a collection of reasons in favour of removing them offhand:
|
Fine by me if it's treated as a breaking change for a major release. |
This would break the Solang build, the https://github.com/hyperledger/solang/blob/main/src/abi/substrate.rs#L66 How else are we going to describe 256 bit integer types in the metadata for Solidity? |
That's a very good point; My assumption was that there will be a different way of representing them (in the next major release, together with this change), and if the coherent solution is to remove it as a primitive type first, I'm fine with it. Ultimately we asked for supporting it, not to just to get rid of it 😁 @jsdw @ascjones what do you have in mind and when will the next major release be out? A way to describe an integer type with varying bit length would be nice. Solidity knows signed and unsigned integer types of arbitrary size stepped by 8bits up to 256bits and currently we can't reflect that. We'll need some time as well to adapt other front-ends (polkadot-js) and the ink-metadata schema (which I think also requires a breaking change / major release). |
To me it feels like these points go hand in hand; I don't feel like we should add primitive types for every 8 bit increment to Currently, we expose a bunch of int-like types in https://github.com/paritytech/parity-common/blob/master/primitive-types/src/lib.rs, and the If you wanted to support arbitrary int/uint sizes, one approach today would be to do something similar and, given a type like: struct UInt<const N: usize>([u8; N]); One would implement scale_info::Type {
path: vec!["foo", "UInt"],
type_def: TypeDefComposite {
fields: vec![
Field {
ty: scale_info::Type {
type_def: TypeDefArray {
len: N,
type_params: scale_info::Type {
ty: TypeDefPrimitive::U8
}
}
}
}
]
}
} Without this I'm not super familiar with your requirements, and so if that isn't suitable then I'd be interested to hear why not and understand the issue better :) In general, the downside of this approach is that there is no "built-in" support for such types in scale-info, ie you need some custom logic to look out for and handle the relevant types based on their paths. The upside is that this approach is super versatile and allows for all sorts of custom handling of types which otherwise don't fit neatly into the scale-codec/scale-info type model, and the type model remains a fairly simple mapping to rust types :) |
@jsdw Thanks, I think that makes all sense and is very similar to what I had in mind. Straight off the bat I don't see why turning it basically into an array of bytes should not work. We need to stick to some |
@jsdw that does look like a good solution. Would make sense to hold off on merging this PR until we have the Solang side sorted and we're sure it's going to work? We need to make sure it works fine in e.g. polkadot-js |
From my side I'm in no rush to merge this PR, so please do take the time you need to explore the approach and comment back with your verdict :) |
@seanyoung do you have any updates from your side; I'm keen to know how you've been getting on! |
It's on our backlog but we currently lack resources for this. An external contributor might look into it, I can check the status. |
Remove
TypeDefPrimitive::I256
andTypeDefPrimitive::U256
variants (which on its own required no other changes).Since this will be a major breaking change, I removed the deprecated calls too.
@ascjones whaddya reckon?