-
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
Andrew7234/consensus tx body #655
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.
ya good way to do it
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, Andy! This brings a ton of value to the consensus layer, IMO.
I do have a request for change that involves a good number of lines of code, but is mostly mechanical now that you've done the hard work of finding all the relevant method names across all the coreapi versions.
4f8d5c8
to
3d59a39
Compare
unit tests incoming |
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 for the refactor!
Thank you also for the upcoming tests. IMO unit tests are less valuable in this particular case because it's mostly about decoding undecipherable binary blobs into something readable. So it's hard to set up a unit test that's much more than a copy of (a segment of) an e2e test. Will be nice to test out Cobalt and the failure case though.
[analyzer] store consensus tx body as json [api] return consensus tx body as json [tests] corresponding e2e changes [tests] fix damask test cases nits move tx body mapping outside; add cobalt-specific types rename migration address comments; add test lint
8c9cd7c
to
9e8d100
Compare
Task
api: Expose consensus tx body as JSON
We currently expose it as base64(cbor(actual_contents))
See e.g. https://nexus.oasis.io/v1/consensus/transactions/2a59b2765df414e0ac56af24f1a4769b9f559d92ace6c65eafcdff98e76a837f -- it's a staking.Transfer tx so we'd expect to see
amount
more readily exposed.Reported by @buberdds
This PR
We currently expose the consensus tx body as a base64(cbor-encode(body)). This PR updates the consensus analyzer to now store the tx body as a json object, and return it in the same manner via the api.
This PR includes a breaking API change by changing the type of
(consensus)Transaction.body
fromstring
->object
The current migration is a breaking migration and drops the existing column and re-adds it as a
json
type since postgres cannot automatically convert existingbytea
values tojson
. Existing consensus tx body data will be lost, and ideally this change should only be applied prior to a full reindex.Alternatives considered:
This seems alright but I'm not sure that it's worth it compared to just having the existing consensus body be empty for past txs. Open to suggestions!
Note: In order to çbor-unmarshal the
tx.Body
into the proper structs, I had to re-add some Method variables to the vendored oasis-core types. See coreapi/v22.2.11/consensus/api/transaction/transaction.go. Methods unique to cobalt/eden were linked to the damaskregisteredMethods
in their respective nodeapiconvert.go
files. All changes to the vendored damaskoasis-core
are simply re-adding code that was originally omitted for brevity.Note: There is a
SetEpoch
method defined in a cometbft(formerly tendermint) app but this is only used for testing, so it was omitted.Testing:
Sample output:
For anyone curious about our consensus tx distribution: