Skip to content

Commit c2c47b4

Browse files
committed
Regenerate XDR with latest Protocol 23 version (#800)
* 1. Run the generator: Change the commit hash to the right sha of stellar/stellar-xdr. Add any new filenames (if needed: here Stellar-exporter.x for Galexie). Run `make reset-xdr` from the project root. * 2. Post-generation fixups to work around bugs or project-specific stuff: * Move `xdr.Operation` into a hidden namespace to avoid conflicts with the SDK's `Operation`. * Minimize the diff by running `sed -ie s/\"/\'/g types/{curr,next}.d.ts` (because the generator uses a different prettier config--this could probably be fixed in the generator itself, but this is easy enough for now). * Add workarounds: - `type Hash = Opaque[];` is a necessary alias that doesn't get gen'd - `Hyper`, `UnsignedHyper`, and `ScSpecEventV0` need their signatures fixed because it should take a proper `Array` instead of a naked `[]` (enforced by `yarn lint`). - Some constants aren't generated correctly, ref. the linked issue * 3. Accommodate XDR additions or renames: * This accounts for any fields that encountered a rename as part of the new XDR version. In this case, `readBytes` was renamed to `diskReadBytes` because it's measured differently as a result of Core's state living in memory rather than on disk in most cases. * It also accounts for the unused extension point actually having a name now, so `xdr.ExtensionPoint` needs to use the structure- specific `xdr.SorobanTransactionDataExt`, instead. * Add docs to README for completeness
1 parent 58c0138 commit c2c47b4

27 files changed

+3492
-2973
lines changed

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
XDR_BASE_URL_CURR=https://github.com/stellar/stellar-xdr/raw/529d5176f24c73eeccfa5eba481d4e89c19b1181
1+
XDR_BASE_URL_CURR=https://github.com/stellar/stellar-xdr/raw/4b7a2ef7931ab2ca2499be68d849f38190b443ca
22
XDR_BASE_LOCAL_CURR=xdr/curr
33
XDR_FILES_CURR= \
44
Stellar-SCP.x \
@@ -11,10 +11,11 @@ XDR_FILES_CURR= \
1111
Stellar-contract-env-meta.x \
1212
Stellar-contract-meta.x \
1313
Stellar-contract-spec.x \
14-
Stellar-contract-config-setting.x
14+
Stellar-contract-config-setting.x \
15+
Stellar-exporter.x
1516
XDR_FILES_LOCAL_CURR=$(addprefix xdr/curr/,$(XDR_FILES_CURR))
1617

17-
XDR_BASE_URL_NEXT=https://github.com/stellar/stellar-xdr/raw/8c88608d0a20b01873056a5ec13be245e1f2aa27
18+
XDR_BASE_URL_NEXT=https://github.com/stellar/stellar-xdr/raw/4b7a2ef7931ab2ca2499be68d849f38190b443ca
1819
XDR_BASE_LOCAL_NEXT=xdr/next
1920
XDR_FILES_NEXT= \
2021
Stellar-SCP.x \
@@ -27,7 +28,8 @@ XDR_FILES_NEXT= \
2728
Stellar-contract-env-meta.x \
2829
Stellar-contract-meta.x \
2930
Stellar-contract-spec.x \
30-
Stellar-contract-config-setting.x
31+
Stellar-contract-config-setting.x \
32+
Stellar-exporter.x
3133
XDR_FILES_LOCAL_NEXT=$(addprefix xdr/next/,$(XDR_FILES_NEXT))
3234

3335
XDRGEN_COMMIT=master

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,22 @@ earlier versions of Node, so the tests need to run on those versions.)
146146

147147
#### Updating XDR definitions
148148

149+
XDR updates are complicated due to the fact that you need workarounds for bugs
150+
in the generator, formatter, or a namespace adjustment.
151+
149152
1. Make sure you have [Docker](https://www.docker.com/) installed and running.
150-
2. `make reset-xdr`
153+
2. Change the commit hash to the right version of [stellar-xdr](https://github.com/stellar/stellar-xdr) and add any filenames that might've been introduced.
154+
3. Run `make reset-xdr`
155+
4. Run `sed -ie s/\"/\'/g types/{curr,next}.d.ts` to minimize the diff (the generator's formatter uses `"` but the repo uses `'`).
156+
5. Move `xdr.Operation` into a hidden namespace to avoid conflicts with the SDK's `Operation`.
157+
6. Add generator workarounds:
158+
* `type Hash = Opaque[]` is a necessary alias that doesn't get generated
159+
* `Hyper`, `UnsignedHyper`, and `ScSpecEventV0` need their signatures
160+
fixed because linting wants an `Array` instead of a naked `[]`.
161+
* Some constants aren't generated correctly (e.g, Ctrl+F `SCSYMBOL_LIMIT` in `src/curr_generated.js`)
162+
7. Finally, make code adjustments related to the XDR (these are usually revealed by running the tests).
163+
164+
As an example PR to follow, [stellar-base#800](https://github.com/stellar/js-stellar-base/pull/800) has detailed steps for each part of the process.
151165

152166
## Usage
153167

0 commit comments

Comments
 (0)