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

[shuffle] Correctly generate Typescript bindings to Move scripts #9398

Merged
merged 7 commits into from
Oct 14, 2021

Conversation

dimroc
Copy link
Contributor

@dimroc dimroc commented Oct 12, 2021

Motivation

Prior to this PR, typescript generation was broken with mismatched types, and incorrect imports.

Here, we correctly generate typescript bindings to move scripts, with zero manual tweaking and just-in-time (JIT) generate typescript libraries for interactions with move scripts, right as a developer enters the shuffle REPL.

Notable highlights:

  1. Replaces javascript keywords like module with moduleName, and asserts the new ABI against a goldenfile.
  2. Uses newer version of serde-generate with first class support for deno typescript runtime.
  3. Adds a PeerToPeerScript typescript demo for TS runtime testing.
  4. E2E tests typescript generation with script above.
  5. Adds deno to the dev_setup.sh for codegen.
  6. Fixes bug where BigInt was erroneously used as the primitive over bigint.
  7. DenoFmt a bunch of temporarily checked in files. Will be deleted once the next JIT generate step is complete.
  8. Refactor .ts helpers into its own file to prevent clobbering by codegen.
  9. Typescript Codegen happens on shuffle new,console,test

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

  1. cargo test -p transaction-builder-generator
  2. cargo test -p shuffle

** Ignore files under generated/ from review.

Related PRs

Unblocks #9322, which adds a script function typescript demo.

@bors-libra bors-libra added this to In Review in bors Oct 12, 2021
@dimroc dimroc force-pushed the typescript-deno-txn-builders-scripts branch from 9c1c930 to 99315e2 Compare October 12, 2021 17:37
@dimroc dimroc force-pushed the typescript-deno-txn-builders-scripts branch 2 times, most recently from d012401 to ea0efb8 Compare October 12, 2021 19:57
@dimroc dimroc changed the title JIT generate Typescript bindings to Move scripts [shuffle] JIT generate Typescript bindings to Move scripts Oct 12, 2021
@dimroc dimroc changed the title [shuffle] JIT generate Typescript bindings to Move scripts [shuffle] Correctly generate Typescript bindings to Move scripts Oct 12, 2021
@dimroc dimroc force-pushed the typescript-deno-txn-builders-scripts branch 4 times, most recently from deb03dc to dce7a0e Compare October 13, 2021 01:16
@dimroc dimroc requested review from ma2bd and sunmilee October 13, 2021 01:16
@dimroc dimroc marked this pull request as ready for review October 13, 2021 02:50
@dimroc dimroc requested a review from a team October 13, 2021 02:50
@dimroc
Copy link
Contributor Author

dimroc commented Oct 13, 2021

In order to make the PR smaller, I'll be adding the commit that JIT generates the typescript. That way, generated/ will be removed and the file count will be smaller.

@dimroc dimroc marked this pull request as draft October 13, 2021 19:25
@dimroc dimroc force-pushed the typescript-deno-txn-builders-scripts branch 4 times, most recently from a17526e to 0d45797 Compare October 13, 2021 22:01
@dimroc dimroc marked this pull request as ready for review October 13, 2021 22:04
@dimroc dimroc force-pushed the typescript-deno-txn-builders-scripts branch from 0d45797 to dc69f1d Compare October 13, 2021 22:16
@libra-action
Copy link

LEC dependency change summary:

target packages:
  M bcs 0.1.3 (direct third-party, crates.io)
    * version upgraded from 0.1.2
    * (unchanged features: [none])
  M serde-generate 0.20.2 (direct third-party, crates.io)
    * version upgraded from 0.19.1
    * (unchanged features: [none])
  M serde-reflection 0.3.4 (direct third-party, crates.io)
    * version upgraded from 0.3.2
    * (unchanged features: [none])

@libra-action
Copy link

LSR dependency change summary:

target packages:
  M bcs 0.1.3 (direct third-party, crates.io)
    * version upgraded from 0.1.2
    * (unchanged features: [none])

@libra-action
Copy link

release binaries dependency change summary:

target packages:
  M bcs 0.1.3 (direct third-party, crates.io)
    * version upgraded from 0.1.2
    * (unchanged features: [none])
  M serde-generate 0.20.2 (direct third-party, crates.io)
    * version upgraded from 0.19.1
    * (unchanged features: [none])
  M serde-reflection 0.3.4 (direct third-party, crates.io)
    * version upgraded from 0.3.2
    * (unchanged features: [none])

bors-libra pushed a commit that referenced this pull request Oct 14, 2021
This is configured to run on CI via codegen-unit-test but ignored locally to
keep test suite fast for other devs.

Closes: #9398
@bors-libra bors-libra moved this from Queued to Testing in bors Oct 14, 2021
@github-actions
Copy link

Forge Test Result

Forge test runner is terminated
Logs: https://diem-development.kb.us-west1.gcp.cloud.es.io:9243/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(columns:!(),filters:!(),index:'2da2a6e0-f70a-11eb-ad53-b979a6c9b83a',interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))
Dashboard: http://mon.forge-0.aws.hlw3truzy4ls.com/d/overview/overview?from=1634179333188&to=1634180358474&orgId=1

❗ Forge Test failed - non-zero exit code for fgi

Repro cmd:

./scripts/fgi/run --tag land_987210db --base-image-tag land_b2f38ad1 --suite land_blocking_compat --report forge_report.json

@github-actions
Copy link

Cluster Test Result

Test runner setup time spent 281 secs
Compatibility test results for land_b2f38ad1 ==> land_987210db (PR)
1. All instances running land_b2f38ad1, generating some traffic on network
2. First full node land_b2f38ad1 ==> land_987210db, to validate new full node to old validator node traffic
3. First Validator node land_b2f38ad1 ==> land_987210db, to validate storage compatibility
4. First batch validators (14) land_b2f38ad1 ==> land_987210db, to test consensus and traffic between old full nodes and new validator node
5. First batch full nodes (14) land_b2f38ad1 ==> land_987210db
6. Second batch validators (15) land_b2f38ad1 ==> land_987210db, to upgrade rest of the validators
7. Second batch of full nodes (15) land_b2f38ad1 ==> land_987210db, to finish the network upgrade, time spent 643 secs
all up : 1133 TPS, 4008 ms latency, 4550 ms p99 latency, no expired txns, time spent 250 secs
Logs: http://kibana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-10-14T02:41:53Z',to:'2021-10-14T03:04:26Z'))
Dashboard: http://grafana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/d/performance/performance?from=1634179313000&to=1634180666000
Validator 1 logs: http://kibana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-10-14T02:41:53Z',to:'2021-10-14T03:04:26Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

Repro cmd:

./scripts/cti --tag land_b2f38ad1 --cluster-test-tag land_987210db -E BATCH_SIZE=15 -E UPDATE_TO_TAG=land_987210db --report report.json --suite land_blocking_compat

🎉 Land-blocking cluster test passed! 👌

@bors-libra
Copy link
Contributor

💔 Test Failed - ci-test

@bors-libra bors-libra moved this from Testing to In Review in bors Oct 14, 2021
@github-actions
Copy link

Forge Test Result

Compatibility test results for land_b2f38ad1 ==> land_987210db (PR)
1. Downgrade all validators to older version: land_b2f38ad1
2. Upgrading first Validator to new version: land_987210db
3. Upgrading rest of first batch to new version: land_987210db
4. upgrading second batch to new version: land_987210db
5. check swarm health
Compatibility test for land_b2f38ad1 ==> land_987210db passed
performance::performance-benchmark : 622 TPS, 7262 ms latency, 9550 ms p99 latency,no expired txns
Logs: https://diem-development.kb.us-west1.gcp.cloud.es.io:9243/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(columns:!(),filters:!(),index:'2da2a6e0-f70a-11eb-ad53-b979a6c9b83a',interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))
Dashboard: http://mon.forge-1.aws.hlw3truzy4ls.com/d/overview/overview?from=1634182705779&to=1634183858376&orgId=1

Repro cmd:

./scripts/fgi/run --tag land_987210db --base-image-tag land_b2f38ad1 --suite land_blocking_compat --report forge_report.json

🎉 Land-blocking forge test passed! 👌

@github-actions
Copy link

Cluster Test Result

Test runner setup time spent 289 secs
Compatibility test results for land_b2f38ad1 ==> land_987210db (PR)
1. All instances running land_b2f38ad1, generating some traffic on network
2. First full node land_b2f38ad1 ==> land_987210db, to validate new full node to old validator node traffic
3. First Validator node land_b2f38ad1 ==> land_987210db, to validate storage compatibility
4. First batch validators (14) land_b2f38ad1 ==> land_987210db, to test consensus and traffic between old full nodes and new validator node
5. First batch full nodes (14) land_b2f38ad1 ==> land_987210db
6. Second batch validators (15) land_b2f38ad1 ==> land_987210db, to upgrade rest of the validators
7. Second batch of full nodes (15) land_b2f38ad1 ==> land_987210db, to finish the network upgrade, time spent 695 secs
all up : 1125 TPS, 4030 ms latency, 4600 ms p99 latency, no expired txns, time spent 250 secs
Logs: http://kibana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-10-14T03:37:59Z',to:'2021-10-14T04:03:40Z'))
Dashboard: http://grafana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/d/performance/performance?from=1634182679000&to=1634184220000
Validator 1 logs: http://kibana.ct-0-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-10-14T03:37:59Z',to:'2021-10-14T04:03:40Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

Repro cmd:

./scripts/cti --tag land_b2f38ad1 --cluster-test-tag land_987210db -E BATCH_SIZE=15 -E UPDATE_TO_TAG=land_987210db --report report.json --suite land_blocking_compat

🎉 Land-blocking cluster test passed! 👌

@dimroc
Copy link
Contributor Author

dimroc commented Oct 14, 2021

/land

@bors-libra bors-libra moved this from In Review to Queued in bors Oct 14, 2021
@bors-libra bors-libra moved this from Queued to Testing in bors Oct 14, 2021
@github-actions
Copy link

Forge Test Result

Compatibility test results for land_b580d224 ==> land_c800ee12 (PR)
1. Downgrade all validators to older version: land_b580d224
2. Upgrading first Validator to new version: land_c800ee12
3. Upgrading rest of first batch to new version: land_c800ee12
4. upgrading second batch to new version: land_c800ee12
5. check swarm health
Compatibility test for land_b580d224 ==> land_c800ee12 passed
performance::performance-benchmark : 626 TPS, 7226 ms latency, 9150 ms p99 latency,no expired txns
Logs: https://diem-development.kb.us-west1.gcp.cloud.es.io:9243/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(columns:!(),filters:!(),index:'2da2a6e0-f70a-11eb-ad53-b979a6c9b83a',interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))
Dashboard: http://mon.forge-0.aws.hlw3truzy4ls.com/d/overview/overview?from=1634194878980&to=1634196031422&orgId=1

Repro cmd:

./scripts/fgi/run --tag land_c800ee12 --base-image-tag land_b580d224 --suite land_blocking_compat --report forge_report.json

🎉 Land-blocking forge test passed! 👌

@github-actions
Copy link

Cluster Test Result

Test runner setup time spent 258 secs
Compatibility test results for land_b580d224 ==> land_c800ee12 (PR)
1. All instances running land_b580d224, generating some traffic on network
2. First full node land_b580d224 ==> land_c800ee12, to validate new full node to old validator node traffic
3. First Validator node land_b580d224 ==> land_c800ee12, to validate storage compatibility
4. First batch validators (14) land_b580d224 ==> land_c800ee12, to test consensus and traffic between old full nodes and new validator node
5. First batch full nodes (14) land_b580d224 ==> land_c800ee12
6. Second batch validators (15) land_b580d224 ==> land_c800ee12, to upgrade rest of the validators
7. Second batch of full nodes (15) land_b580d224 ==> land_c800ee12, to finish the network upgrade, time spent 650 secs
all up : 1148 TPS, 3959 ms latency, 4500 ms p99 latency, no expired txns, time spent 250 secs
Logs: http://kibana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-10-14T07:00:56Z',to:'2021-10-14T07:23:09Z'))
Dashboard: http://grafana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/d/performance/performance?from=1634194856000&to=1634196189000
Validator 1 logs: http://kibana.ct-2-k8s-testnet.aws.hlw3truzy4ls.com/app/kibana#/discover?_g=(time:(from:'2021-10-14T07:00:56Z',to:'2021-10-14T07:23:09Z'))&_a=(columns:!(log),query:(language:kuery,query:'kubernetes.pod_name:"val-1"'),sort:!(!('@timestamp',desc)))

Repro cmd:

./scripts/cti --tag land_b580d224 --cluster-test-tag land_c800ee12 -E BATCH_SIZE=15 -E UPDATE_TO_TAG=land_c800ee12 --report report.json --suite land_blocking_compat

🎉 Land-blocking cluster test passed! 👌

@bors-libra bors-libra force-pushed the typescript-deno-txn-builders-scripts branch from dc69f1d to c800ee1 Compare October 14, 2021 07:23
@bors-libra bors-libra removed this from Testing in bors Oct 14, 2021
@bors-libra bors-libra merged commit c800ee1 into diem:main Oct 14, 2021
@bors-libra bors-libra temporarily deployed to Sccache October 14, 2021 07:23 Inactive
@bors-libra bors-libra temporarily deployed to Docker October 14, 2021 07:24 Inactive
@bors-libra bors-libra temporarily deployed to Sccache October 14, 2021 07:24 Inactive
@bors-libra bors-libra temporarily deployed to Docker October 14, 2021 07:24 Inactive
@libra-action
Copy link

Dependency update review

bcs updated: 0.1.2 --> 0.1.3

No known advisories
No change in the build script
No change in any file with unsafe code
The source and crates.io code are the same
Cilck to show details
Click to show version diff summary
total files changed6
total rust files changed3
total loc change36
Click to show changed files
  • tests/serde.rs
  • src/ser.rs
  • Cargo.toml
  • Cargo.toml.orig
  • .cargo_vcs_info.json
  • src/de.rs

serde-generate updated: 0.19.1 --> 0.20.2

No known advisories
No change in the build script
No change in any file with unsafe code
The source and crates.io code are the same
Cilck to show details
Click to show version diff summary
total files changed39
total rust files changed21
total loc change1,392
Click to show changed files
  • runtime/typescript/serde/types.ts
  • tests/python_runtime.rs
  • runtime/typescript/bincode/mod.ts
  • runtime/typescript/serde/serializer.ts
  • tests/cpp_runtime.rs
  • README.md
  • runtime/typescript/serde/deserializer.ts
  • tests/rust_generation.rs
  • runtime/typescript/bcs/bcsDeserializer.ts
  • runtime/typescript/serde/mod.ts
  • src/lib.rs
  • src/python3.rs
  • runtime/typescript/bincode/bincodeSerializer.ts
  • tests/cpp_generation.rs
  • src/cpp.rs
  • tests/java_generation.rs
  • src/test_utils.rs
  • tests/rust_runtime.rs
  • runtime/typescript/serde/binaryDeserializer.ts
  • tests/typescript_runtime.rs
  • tests/golang_runtime.rs
  • runtime/typescript/serde/binarySerializer.ts
  • runtime/typescript/bcs/mod.ts
  • Cargo.lock
  • tests/csharp_generation.rs
  • .cargo_vcs_info.json
  • Cargo.toml
  • tests/golang_generation.rs
  • src/rust.rs
  • src/typescript.rs
  • tests/java_runtime.rs
  • tests/typescript_generation.rs
  • runtime/typescript/bcs/bcsSerializer.ts
  • Cargo.toml.orig
  • runtime/typescript/bincode/bincodeDeserializer.ts
  • tests/python_generation.rs
  • src/csharp.rs
  • tests/csharp_runtime.rs
  • runtime/typescript/bincode/index.ts

serde-reflection updated: 0.3.2 --> 0.3.4

No known advisories
No change in the build script
No change in any file with unsafe code
The source and crates.io code are the same
Cilck to show details
Click to show version diff summary
total files changed10
total rust files changed6
total loc change486
Click to show changed files
  • README.md
  • src/ser.rs
  • tests/format.rs
  • .cargo_vcs_info.json
  • Cargo.toml.orig
  • Cargo.toml
  • src/format.rs
  • src/trace.rs
  • src/lib.rs
  • tests/serde.rs
Click to show the files that differ in crates.io from the git source
  • src/lib.rs

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.

None yet

4 participants