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

feat(textual): Add Tx envelope Value Renderer #13600

Merged
merged 75 commits into from
Jan 11, 2023
Merged

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Oct 20, 2022

Description

Closes: #13579

For the implementation of this PR, I thought about 3 ways:

  1. Totally manually, i.e. for each new line in the desired value-rendered output, add it using fmt.Sprintfs. See beginning of implementation to get an idea.
  2. Use well-crafted protobuf structs and the existing MessageValueRenderer to value-render the tx
    • a. Create one Enveloppe proto message (internal), but we need to also add internal proto annotations to mark expert fields, and modify the MessageValueRenderer (which is already big, as it handles repeated too) to take into account this new expert proto annotation.
    • b. Create Part{1..6} proto messages (internal), where odd numbers are not expert, and even numbers are expert, and alternate between value-rendering them.

I went with 2b 2a in this PR, after #13600 (review)


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

tx/signing/sign_mode_handler.go Show resolved Hide resolved
tx/signing/sign_mode_handler.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 25, 2022

Codecov Report

Merging #13600 (93d4b5d) into main (2739f83) will increase coverage by 0.62%.
The diff coverage is 66.11%.

❗ Current head 93d4b5d differs from pull request most recent head e3e55b5. Consider uploading reports for the commit e3e55b5 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13600      +/-   ##
==========================================
+ Coverage   56.25%   56.88%   +0.62%     
==========================================
  Files         667      647      -20     
  Lines       56576    55253    -1323     
==========================================
- Hits        31829    31431     -398     
+ Misses      22165    21255     -910     
+ Partials     2582     2567      -15     
Impacted Files Coverage Δ
tx/textual/valuerenderer/tx.go 64.15% <64.15%> (ø)
tx/textual/valuerenderer/valuerenderer.go 78.33% <80.00%> (ø)
x/auth/keeper/genesis.go 0.00% <0.00%> (-50.00%) ⬇️
x/auth/keeper/account.go 53.33% <0.00%> (-18.34%) ⬇️
x/group/internal/math/dec.go 41.53% <0.00%> (-7.00%) ⬇️
x/gov/abci.go 90.29% <0.00%> (-6.86%) ⬇️
server/config/config.go 69.87% <0.00%> (-2.65%) ⬇️
x/nft/keeper/grpc_query.go 69.38% <0.00%> (-1.45%) ⬇️
x/nft/client/cli/query.go 61.72% <0.00%> (-0.72%) ⬇️
x/group/msgs.go 57.35% <0.00%> (-0.25%) ⬇️
... and 69 more

@github-actions github-actions bot removed the C:x/auth label Oct 25, 2022
@amaury1093 amaury1093 mentioned this pull request Nov 2, 2022
20 tasks
@sonarcloud
Copy link

sonarcloud bot commented Dec 7, 2022

[Cosmos SDK] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

tx/signing/sign_mode_handler.go Show resolved Hide resolved
tx/textual/internal/textualpb/enveloppe.proto Outdated Show resolved Hide resolved
tx/textual/internal/textualpb/envelope.proto Outdated Show resolved Hide resolved

// getHash gets the hash of raw bytes to be signed over:
// HEX(sha256(len(body_bytes) ++ body_bytes ++ len(auth_info_bytes) ++ auth_info_bytes))
func getHash(bodyBz, authInfoBz []byte) string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you're convinced me.

@amaury1093 amaury1093 enabled auto-merge (squash) January 11, 2023 09:50
@amaury1093
Copy link
Contributor Author

amaury1093 commented Jan 11, 2023

Going to fix the failing test in test-tx first

Edit: done

@sonarcloud
Copy link

sonarcloud bot commented Jan 11, 2023

[Cosmos SDK] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
No Duplication information No Duplication information

@amaury1093 amaury1093 enabled auto-merge (squash) January 11, 2023 10:51
@sonarcloud
Copy link

sonarcloud bot commented Jan 11, 2023

[Cosmos SDK - Tx] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
No Duplication information No Duplication information

@amaury1093 amaury1093 merged commit d5bcfb3 into main Jan 11, 2023
@amaury1093 amaury1093 deleted the am/13579-textual-tx branch January 11, 2023 12:25
0xmuralik pushed a commit to 0xmuralik/cosmos-sdk that referenced this pull request Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Textual Value renderer for the proto Tx struct
6 participants