-
Notifications
You must be signed in to change notification settings - Fork 58
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
Refactor StoragePlaceholder
#1109
Comments
@bobbinth some points/questions about this:
|
Not necessarily generate but maybe identify that we need a public key from the user and then give user options to either select one of existing public keys that the client is tracking or generate a new one (we could start simple and then make it more sophisticated). Going back to my original example, I think we may need to modify it to look something like this: # simple value slot with the value initialized to 0
[[storage]]
name = "my_slot_1"
description = "some description of what this slot is for"
slot = 0
value = ["0", "0", "0", "0"]
# simple value slot which requires initialization of the first element to a u32 value
[[storage]]
name = "my_slot_2"
slot = 1
value = ["{{u32}}", "0", "0", "0"]
# simple value slot which requires initialization to an RpoFalcon512 public key
[[storage]]
name = "my_slot_3"
slot = 2
value = "{{auth::rpo_falcon512::pub_key}}"
# simple value slot which requires initialization to an RpoFalcon512 public key,
# but this could be a different public key from slot 2
[[storage]]
name = "my_slot_4"
slot = 2
value = "{{auth::rpo_falcon512::pub_key}}" The last two examples are the tricky ones: somehow we'll need to map Assuming we can do this mapping, we'll need to make sure this type can be converted into a Beyond that, in the CLI we'll need to figure out where to get the data. There are a few options here:
But I think these are conceptually easy assuming we know that To summarize: for slots that require inputs, we could have 2 scenarios:
For custom types, we'll need to figure out how to make the system extensible - but maybe for now we just stat with the hard-coded approach. Not addressed in this comment is how to handle multi-slot types and map slots. I haven't thought through these too much yet, but I'm hoping the methodology outlined above could also be applied to them. |
Does this negate I think an alternative that combines both aspects could be one of the following: Alternative 1: Specifying placeholder infoThere could be a # ...
[[storage]]
name = "token_metadata"
description = "Contains metadata about the token associated to the faucet account"
slot = 1
value = ["{{metadata.max_supply}}","{{metadata.token_symbol}}","{{metadata.decimals}}","0x0"]
# ...
[placeholders]
metadata.max_supply = { type = "u64", default_value = "0xFFFFFFFFFFFFFFFF", description = "Total amount of tokens that can be minted over the account's lifetime" }
metadata.token_symbol = { type = "String", description = "..." }
metadata.decimals = { type = "u8", description = "..." } Alternative 2: Specifying inline placeholder typeWe could specify inline types as well if we still wanted to have keyed values: # ...
[[storage]]
name = "token_metadata"
description = "Contains metadata about the token associated to the faucet account"
slot = 1
value = ["{{metadata.max_supply: u64}}","{{metadata.token_symbol: String}}","{{metadata.decimals: u8}}","0x0"] Both of these approaches would also allow for using keys in more than one location, although it might make the templates and validations unnecessarily more complex. In your approach the storage slot description can describe each of the inner templated values, for example, so there might not be a need to extend the format. As for the type information per se, I think we are interested in knowing to what type the type identifier maps, but also that the type can be converted to |
This is kind of what I had in mind - though, I can see how this could be more complicated then we'd like. For multi-slot values though, I was thinking there would be just a single value. Specifically, for simple slots (i.e., not maps), we have 3 ways of how to initialize things:
Full wordFull word is the simplest case and it would look like so: # simple value slot initialize with a hex value
[[storage]]
name = "my_slot_1"
slot = 0
value = "0x123456"
# simple value slot with individually initialized elements
[[storage]]
name = "my_slot_2"
slot = 1
value = [{ value = "1" }, { value = "2" }, { value = "3" }, { value = "4" }]
# simple value slot which requires user-provided value which can be any word
[[storage]]
name = "my_slot_3"
slot = 2
value = "{{word}}"
# simple value slot which requires user-provided value which should be Falcon public key
[[storage]]
name = "my_slot_4"
slot = 3
value = "{{auth::rpo_falcon512::pub_key}}" The data file for these could look like: my_slot_3 = ["5", "6", "7", "8"] # or could be a single hex encoded string
my_slot_4 = "0x123456789" Individual elementsFor individual elements, I think you are right that my proposal had some limitations. What we probably want to do is provide name/description for individual elements. Maybe something like this could work: [[storage]]
name = "token_metadata"
description = "Contains metadata about the token associated to the faucet account"
slot = 0
value = [
{ name = "max_supply", description = "Maximum supply of the token in base units", value = "{{felt}}" },
{ name = "symbol", description = "Ticker symbol used to identify the token", value = "{{TokenSymbol}}" },
{ name = "decimals", description = "Number of decimal places", value = "{{u32}}" },
{ value = "0" },
] The data file for these could look like: token_metadata.max_supply = "1000000000"
token_metadata.symbol = "ETH"
token_metadata.decimals = "9" Or maybe even: [token_metadata]
max_supply = "1000000000"
symbol = "ETH"
decimals = "9" Multi-word valuesFor multi-word values, we could provide just one name/description for the whole value. For example: # A two-word value that can be initialized with any valid words
[[storage]]
name = "some_data"
slots = [0, 1]
value = "{{word}}" # or maybe better use {{any}}?
# A 4-word value where the type should be an ECDSA public key (64 bytes)
[[storage]]
name = "pub_key"
slots = [0, 1, 3, 4]
value = "{{auth::ecdsa::secp256k1::pub_key}}" The data file for these could look like: some_data = "0x124567..."
pub_key = """
-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEeYRv0S7Zf5CNh5/APxiT6xoY+z521DHT
FgLdUPUP2e/3jkYDuZTbCHP8zEHm7nhG6AUOpJCbTF2J2vWkC1i3Yg==
-----END PUBLIC KEY-----
""" |
I think that works but it might have some usability problems. For values that are hardcoded, in your specs it's as if we were assuming the type is [[storage]]
name = "token_metadata"
description = "Contains metadata about the token associated to the faucet account"
slot = 0
value = [
# ...
{ name = "symbol", description = "...", value = "0x12345" }, # we can't do `value="TST"` because we can't automatically infer the type
# ...
] In your ECDSA example, you could not hardcode the key within the original TOML because you don't know how to parse the string the correct way into a set of words. |
Something like this could encompass all variants: [[storage]]
id = "token_metadata"
description = "Contains metadata about the token associated to the faucet account"
slot = 0
value = [
{ type = "felt", id = "max_supply", description = "Maximum supply of the token in base units" }, # placeholder
{ type = "TokenSymbol", value = "TST" }, # hardcoded non-felt type
{ type = "u8", id = "decimals", description = "Number of decimal places" }, # placeholder
{ value = "0" }, # could also be just "0"? maybe type can be inferred to either felt or word depending on "position"
]
[[storage]]
id = "faucet_pubkey"
description = "Contains the falcon public key"
slot = 1
type = "auth::rpo_falcon512::pub_key" # placeholder
[[storage]]
id = "owner_pubkey"
description = "Contains the ECDSA public key"
slots = [2,3,4,5]
type = "auth::ecdsa::secp256k1::pub_key" # hardcoded non-word type
value = """
-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEeYRv0S7Zf5CNh5/APxiT6xoY+z521DHT
FgLdUPUP2e/3jkYDuZTbCHP8zEHm7nhG6AUOpJCbTF2J2vWkC1i3Yg==
-----END PUBLIC KEY-----
""" In this example, |
I like this approach! Yes, let's add One question is how to specify "generic" type for multi-slot values. Maybe something like this would work? [[storage]]
name = "some_data"
slots = [0, 1]
type = "[word; 2]" Or maybe we should just have |
Closed by #1124 |
For making the component template API more usable, we could add more context to the templating aspect of the storage layout. Specifically, we could move from having generic keys to something more oriented toward describing the "type" or "kind" of data requirements.
(Link)
The text was updated successfully, but these errors were encountered: