-
Notifications
You must be signed in to change notification settings - Fork 4
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
analyzer/consensus: Support ParametersChange proposal #573
Conversation
badd77e
to
1a0d49b
Compare
analyzer/consensus/consensus.go
Outdated
submission.State.String(), | ||
submission.Deposit.String(), | ||
submission.Content.ChangeParameters.Module, | ||
submission.Content.ChangeParameters.Changes, |
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.
Changes is cbor.RawMessage
of one of the various ConsensusParameterChanges
types.
We could probably try unmarshaling this into var changes map[string]interface{}
and then marshaling it into JSON, and storing a JSONB. I think that should work in all cases that we are likely to ever hit, but not absolutely certain if there are any potential edge cases, so for now opted to just storing the raw value. The frontend or the API controller could still do this.
1a0d49b
to
f34a365
Compare
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.
Getting to be one fat table, this :)
Thank you! LGTM assuming you agree with the type change (see comments).
FYI keep an eye out on #574 in case it goes in before yours.
// 5 hardcoded NULLs for the proposal.Content.Upgrade fields. | ||
// 1 hardocded NULL for the proposal.Content.CancelUpgrade.ProposalID field. | ||
proposal.Content.ChangeParameters.Module, | ||
hex.EncodeToString(proposal.Content.ChangeParameters.Changes), |
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.
🤦 one day we'll use a sql library in genesis processing too ... it's just not justifiable to spend a day doing that busy work.
The name of the module whose parameters are to be changed | ||
by this 'parameters_change' proposal. | ||
parameters_change: | ||
type: string |
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.
It would be preferable to also have format: byte
here.
Examples:
Line 152 in 6b2fe2e
format: byte # means base64-encoded raw bytes |
Lines 2295 to 2303 in 6b2fe2e
runtime_bytecode: | |
type: string | |
format: byte | |
description: | | |
The runtime bytecode of the smart contract. This is the code stored on-chain that | |
describes a smart contract. Every contract has this info, but Nexus fetches | |
it separately, so the field may be missing for very fresh contracts (or if the fetching | |
process is stalled). | |
gas_used: |
Then our openapi generator will represent it as a simple []byte
on the Go side, which is more truthful. And when serializing to JSON, it will automatically base64 encode it because that's what the openapi standard prescribes. So you'll be able to drop the ugly manual transformation (p.ParametersChange = common.Ptr(base64.StdEncoding.EncodeToString(parametersChange))
and related lines).
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.
Will update, thanks 👍
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.
thank you! oh alternatively, I like the JSON solution (that you mention in the PR description) also
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.
Used the raw cbor message (bytes) for now.
f34a365
to
246651f
Compare
The tesnet proposal_id=9 on live deployments (that are already past the proposal height) should probably just be manually inserted in the DB.
TODO: