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

[aptos-sdk-builder] Rebrand and re-emerge transaction-builder-generator #2151

Merged
merged 6 commits into from
Jul 23, 2022

Conversation

davidiw
Copy link
Contributor

@davidiw davidiw commented Jul 22, 2022

  • Renamed it, transaction-builder-generator is a long awkward name that doesn't align with what the project actually does. It is a tool to generate SDKs.
  • encode_ prefix on functions is unnecessarily verbose
  • Updated to a new version of downstream dependencies that reveal better errors on missing types
  • Added the missing type that was breaking generics

This change is Reviewable

@davidiw davidiw requested review from wrwg, zekun000 and movekevin July 22, 2022 02:22
@wrwg
Copy link
Contributor

wrwg commented Jul 22, 2022

Quick question: does this now also work again? Because it crashed after the module renaming and was deactivated. (Both for cached and framework run.)

@davidiw
Copy link
Contributor Author

davidiw commented Jul 22, 2022

Quick question: does this now also work again? Because it crashed after the module renaming and was deactivated. (Both for cached and framework run.)

Yup, I fixed it. First had to improve the upstream library to determine why it was exploding and then had to fix this. Apparently it was missing "TypeTag", which is sad because that was what we were looking to generate but failing to do so.

Mind you, it passed some tests, so I'm curious to see if it passes the litany of tests we have. 🤞

@wrwg
Copy link
Contributor

wrwg commented Jul 22, 2022

Quick question: does this now also work again? Because it crashed after the module renaming and was deactivated. (Both for cached and framework run.)

Yup, I fixed it. First had to improve the upstream library to determine why it was exploding and then had to fix this. Apparently it was missing "TypeTag", which is sad because that was what we were looking to generate but failing to do so.

Mind you, it passed some tests, so I'm curious to see if it passes the litany of tests we have. 🤞

Great! Can we keep the generated files checked in, and have a little shell to regenerate those guys? I don't want to go to the same ordeal again. In general there are two issues with the previous setup:

  • It is not friendly to IDEs as you can't see those generated functions in completion no do goto-definition. Most of us are using IDEs AFAICT.
  • It introduces a dependency of the build process from the thing which is being built. This is also called the "bootstrap problem" in compiler construction. If execution of the transaction builder gen crashes, then you can't build existing tests elsewhere, which in turn blocks you from debugging why it crashes.

@davidiw
Copy link
Contributor Author

davidiw commented Jul 22, 2022

This is a tricky situation, because on the one hand, you're right it is a pain in the ass. On the other hand, it builds uncomfortable nuance into the codebase -- that is, I must re-run the builder and copy the file over. Let me explore a couple solutions that might ... automate this.

@davidiw davidiw closed this Jul 22, 2022
@davidiw davidiw reopened this Jul 22, 2022
@wrwg
Copy link
Contributor

wrwg commented Jul 22, 2022

This is a tricky situation, because on the one hand, you're right it is a pain in the ass. On the other hand, it builds uncomfortable nuance into the codebase -- that is, I must re-run the builder and copy the file over. Let me explore a couple solutions that might ... automate this.

The most straightforward way is to build a test for this. We are doing this in the Move repo for generated artifacts like docs. See the cargo test target of the move-stdlib.

Practically there is little need to automate this since only a few people will run into the need to re-run this, and they should know what they are doing/need to do.

@wrwg
Copy link
Contributor

wrwg commented Jul 22, 2022

I must re-run the builder and copy the file over.

No copy should be needed. This should be done in Rust. (And also the test logic -- its like a baseline test.)

@@ -14,8 +14,8 @@ anyhow = "1.0.57"
bcs = "0.1.3"
heck = "0.3.2"
regex = "1.5.5"
serde-generate = { git = "https://github.com/aptos-labs/serde-reflection" }
serde-reflection = { git = "https://github.com/aptos-labs/serde-reflection" }
serde-generate = { git = "https://github.com/aptos-labs/serde-reflection", rev = "9ba2437dc079515f5a1797b8536b0ea7685678d0" }
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The upstream serde reflection has issues, we forked a while ago. Once we get into a good place, I'll chat with Mathieu about potentially using his.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is not upstream though? isn’t this our fork?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

@@ -14,7 +14,7 @@ fn main() {
no_check_layout_compatibility: false,
no_build_docs: false,
with_diagram: false,
no_script_builder: true, // TODO: consider bringing this back
no_script_builder: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

turns generation of the script builder back on.

@@ -25,7 +25,7 @@ fn initial_aptos_version() {
println!("@@@@@@@@@@@@ account {:?}", account);
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh crap this looks like mine. Can you please remove it? I'm surprised lint didn't catch this.

@@ -25,7 +25,7 @@ fn initial_aptos_version() {
println!("@@@@@@@@@@@@ account {:?}", account);
let txn = account
.transaction()
.payload(aptos_stdlib::encode_version_set_version(test_env.version_number + 1))
.payload(aptos_stdlib::version_set_version(test_env.version_number + 1))
.sequence_number(test_env.dr_sequence_number)
.sign();
println!("@@@@@@@@@@@@ txn {:?}", txn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

* Upgraded to a newer version that spit out more clean errors
* Fixed the missing TypeTag
* Remove encode and decode prefixes from functions
* Adjusted to new casing of module names
* Remove blocklist of unsupported functions
@davidiw
Copy link
Contributor Author

davidiw commented Jul 22, 2022

PR should be ready for review and hopefully landing, so I can focus on the next big challenge :)

davidiw added 3 commits July 22, 2022 09:14
Now that the former transaction-generator-builder is healthy, I've
reintroduced it. I've removed the unnecessary encode_ prefix and updated
the functions appropriately.
For move arguments, VecBytes and Vec<Vec<u8>> should be interchangeable.
The former is more natural, since theoretically, we can have nested
vectors of other types.
@@ -3,29 +3,15 @@

#![allow(unused_imports)]
Copy link
Contributor

Choose a reason for hiding this comment

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

why is not this called aptos_stdlib_builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hahaha, probably should rename these to just lib and no builder.

@@ -34,7 +34,7 @@ fn quote_type_as_format(type_tag: &TypeTag) -> Format {
U8 => Format::Bytes,
Vector(type_tag) => {
if type_tag.as_ref() == &U8 {
Format::TypeName("VecBytes".into())
Copy link
Contributor

@areshand areshand Jul 22, 2022

Choose a reason for hiding this comment

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

we may want to keep consistent with the types in move repo. If we need to change anything on the parsing of VecBytes in move repo, it would be much easier to use existing types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

VecBytes are a hack as far as I can tell. We should probably work with the team to remove them. Also move doesn't really have a notion of "transaction agruments".

@github-actions
Copy link
Contributor

✅ Forge test success

Forge is land-blocking

all up : 5578 TPS, 3063 ms latency, 6150 ms p99 latency,no expired txns

@github-actions
Copy link
Contributor

✅ Forge test success

Forge is land-blocking

all up : 5669 TPS, 3009 ms latency, 5450 ms p99 latency,no expired txns

davidiw added 2 commits July 22, 2022 16:46
SDK files are useful for ides and general code readability. This stores
them in the repo. They will automatically be rebuilt each time the user
builds cached-framework to make it easier to keep them up to date
without the user needing to explicitly figure this out.
@github-actions
Copy link
Contributor

✅ Forge test success

Forge is land-blocking

all up : 5883 TPS, 2889 ms latency, 5300 ms p99 latency,no expired txns

@davidiw davidiw merged commit 914654e into main Jul 23, 2022
@davidiw davidiw deleted the move branch July 23, 2022 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants