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

Strong typing for Stellar #1755

Merged
merged 13 commits into from
Sep 24, 2021
Merged

Strong typing for Stellar #1755

merged 13 commits into from
Sep 24, 2021

Conversation

matejcik
Copy link
Contributor

@matejcik matejcik commented Aug 9, 2021

Changes most fields in Stellar protobuf to required. This mostly matches the Stellar XDR, so it should not introduce incompatibilities on caller sides.

The notable exception to "mostly matches" are the timebounds fields. In Stellar XDR, they are optional, and in the past, we would treat them as such. This PR makes timebounds required, and so rejects transactions without timebounds.
Per stellar/js-stellar-base#438 omitting timebounds is strongly discouraged by documentation and existing implementations, so I feel that we do not need to support this feature.
Incidentally, this fixes #1699

Several fields (memo_type, signer_type, asset.type) now use enums. There is another incompatibility: StellarAssetType is renamed to StellarAsset, so that StellarAssetType can be used as the name of the enum.

Enum values are binary-compatible with the previously existing fields.

ping @szymonlesisz or @matejkriz for the above, which require modifications in Connect:

  1. if the incoming data structure does not have timebounds, it must be rejected
  2. rename StellarAssetType to StellarAsset as appropriate. Or let me know if this is a bigger problem and we'll figure out some other way to name this.

all testcases have been regenerated with timebounds, and signatures checked against Stellar Laboratory. I renamed the testcases, which unfortunately breaks the UI diff.
fixes #2

@matejcik matejcik requested a review from mmilata August 9, 2021 13:34
@matejcik matejcik added this to To be reviewed in Firmware Pull Requests via automation Aug 9, 2021
@overcat
Copy link
Contributor

overcat commented Aug 18, 2021

Hi @matejcik, any updates here? If this PR can be merged, I can resolve #1691 and #1698 on this basis.

@matejcik
Copy link
Contributor Author

This is waiting for an internal review and presumably will be merged in September.

Please hold off on implementing the mentioned issues, it is currently unclear if we would accept such PRs.

@overcat
Copy link
Contributor

overcat commented Aug 18, 2021

This is waiting for an internal review and presumably will be merged in September.

Please hold off on implementing the mentioned issues, it is currently unclear if we would accept such PRs.

Thank you for your quick reply, I will discuss with you before implementation.

@JFWooten4
Copy link

How to update our firmware should this merge to main?

@prusnak prusnak removed their request for review September 3, 2021 20:04
Firmware Pull Requests automation moved this from To be reviewed to Finalizing Sep 6, 2021
Copy link
Member

@mmilata mmilata left a comment

Choose a reason for hiding this comment

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

LGTM! UI diff ack. Thanks for getting rid of confirm_timebounds_stellar.

common/protob/messages-stellar.proto Show resolved Hide resolved
@@ -1,4 +1,4 @@
# Base32 implementation taken from the micropython-lib's base64 module
# Base32 implementation taken from the micropython-lib'data base64 module
Copy link
Member

Choose a reason for hiding this comment

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

Runaway search & replace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in rebase

core/src/apps/stellar/layout.py Show resolved Hide resolved
@matejcik
Copy link
Contributor Author

matejcik commented Sep 7, 2021

rebased, fixed conflict with master.

this is now waiting for input from Connect side

@matejcik
Copy link
Contributor Author

matejcik commented Sep 8, 2021

TODO:

  • fix tests
  • add changelogs

BREAKING CHANGE: StellarAssetType is renamed to StellarAsset.
The name StellarAssetType is reused for the corresponding enum.

Enums are introduced in several other places. Their values correspond to
allowed values of (previously int) fields so this should not pose a
compatibility problem.

Many fields are now required. We believe that this should not pose a
compatibility problem, because all known interfaces to Stellar signing
actually accept Stellar XDR on input, whose required fields match the
protobuf schema.
@alex-jerechinsky alex-jerechinsky added this to 🏃‍♀️ In progress in FW · October 13 🍊 Sep 22, 2021
- removed boilerplate
- shortened some names
- dropped distinction between v0 and v1 tests because there's now no XDR
parsing involved
- shortened test bodies to check only fields relevant to the particular
test case

[no changelog]
[no changelog], covered in Stellar refactor changelog entries
@matejcik matejcik force-pushed the matejcik/stellar-typing branch 2 times, most recently from 31ea244 to 2a854eb Compare September 22, 2021 13:03
All test cases are generated and verified in Stellar Laboratory.
Source XDR is also tested to match the vectors, and it is easy to verify
in Laboratory directly.
@matejcik matejcik merged commit f484c42 into master Sep 24, 2021
FW · October 13 🍊 automation moved this from 🏃‍♀️ In progress to 🤝 Needs QA Sep 24, 2021
Firmware Pull Requests automation moved this from Finalizing to Merged Sep 24, 2021
@matejcik matejcik deleted the matejcik/stellar-typing branch September 24, 2021 08:30
@bosomt
Copy link

bosomt commented Sep 24, 2021

@matejcik anything that can/need to be checked on our side ?

@matejcik
Copy link
Contributor Author

is Stellar Account Viewer in your scope? if yes, then general operation of Stellar

@matejcik
Copy link
Contributor Author

in particular please check that #1699 is fixed

@bosomt
Copy link

bosomt commented Sep 24, 2021

@matejcik Stellar is not in our scope,
but of course we will keep it in needs QA column and we will test it during release testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Stellar: invalid signature if timebounds are set to 0/0 Test each and every operation in Stellar
5 participants