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

Make object directly passable in tx's #7090

Merged
merged 64 commits into from
Mar 24, 2023
Merged

Make object directly passable in tx's #7090

merged 64 commits into from
Mar 24, 2023

Conversation

gerben-stavenga
Copy link
Contributor

@gerben-stavenga gerben-stavenga commented Mar 13, 2023

Description

This PR makes (whitelisted) objects directly passable in non-script tx's. The overall strategy is that each allowed struct is associated with a "constructor" in the module that defines the struct, which will construct the type. The argument will be the BCS encoded parameter values of the constructor call, if the constructor takes the same values in the same order as the struct fields this will be identical.

Overall the flow is that a call to eg.

entry fun my_func(x: std::string::String foo) { ... }

let's say my_func("aptos") will effectively be exectuted as if the user has written a script like

let s = std::string::utf8("aptos")
my_func(s)

The same works for objects

entry fun send(x: Object, to: address);

a call send(0xCAFE, 0xC0FFEE)

will effectively run like

let o = aptos_std::object::address_to_object(0xCAFE)
send(o, 0xC0FFEE)

Notice that I included type inference in the call to address_to_object, from the expected return type. The algorithm works recursively so in principle nested structs etc. will work fine.

Test Plan

@gerben-stavenga gerben-stavenga changed the title First attempt at making object passable Make object directly passable in tx's Mar 19, 2023
@gerben-stavenga gerben-stavenga marked this pull request as ready for review March 19, 2023 01:58
.all(|types| Self::match_return_type(types.0, types.1, map))
},
// For the rest we need to assure the types match
_ => std::mem::discriminant(returned) == std::mem::discriminant(expected),
Copy link
Contributor

Choose a reason for hiding this comment

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

TyParam(usize)

what if we get this? what is this even? it would seem like a violation

Also these all have Eq / PartialEq -- why not leverage that?

Copy link
Contributor

@wrwg wrwg left a comment

Choose a reason for hiding this comment

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

We need a fix for the error propagation problem.

@gerben-stavenga gerben-stavenga enabled auto-merge (squash) March 24, 2023 00:08
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

✅ Forge suite land_blocking success on 065ee15cf73298e622a33d4e6cebb844b8b343d2

performance benchmark with full nodes : 5605 TPS, 7002 ms latency, 12100 ms p99 latency,(!) expired 1040 out of 2394480 txns
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite framework_upgrade success on cb4ba0a57c998c60cbab65af31a64875d2588ca5 ==> 065ee15cf73298e622a33d4e6cebb844b8b343d2

Compatibility test results for cb4ba0a57c998c60cbab65af31a64875d2588ca5 ==> 065ee15cf73298e622a33d4e6cebb844b8b343d2 (PR)
Upgrade the nodes to version: 065ee15cf73298e622a33d4e6cebb844b8b343d2
framework_upgrade::framework-upgrade::full-framework-upgrade : 6440 TPS, 5835 ms latency, 9200 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for cb4ba0a57c998c60cbab65af31a64875d2588ca5 ==> 065ee15cf73298e622a33d4e6cebb844b8b343d2 passed
Test Ok

@github-actions
Copy link
Contributor

✅ Forge suite compat success on testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 065ee15cf73298e622a33d4e6cebb844b8b343d2

Compatibility test results for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 065ee15cf73298e622a33d4e6cebb844b8b343d2 (PR)
1. Check liveness of validators at old version: testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b
compatibility::simple-validator-upgrade::liveness-check : 8160 TPS, 4737 ms latency, 8500 ms p99 latency,no expired txns
2. Upgrading first Validator to new version: 065ee15cf73298e622a33d4e6cebb844b8b343d2
compatibility::simple-validator-upgrade::single-validator-upgrade : 3758 TPS, 10450 ms latency, 14900 ms p99 latency,no expired txns
3. Upgrading rest of first batch to new version: 065ee15cf73298e622a33d4e6cebb844b8b343d2
compatibility::simple-validator-upgrade::half-validator-upgrade : 4438 TPS, 8886 ms latency, 10900 ms p99 latency,no expired txns
4. upgrading second batch to new version: 065ee15cf73298e622a33d4e6cebb844b8b343d2
compatibility::simple-validator-upgrade::rest-validator-upgrade : 6678 TPS, 5549 ms latency, 11400 ms p99 latency,no expired txns
5. check swarm health
Compatibility test for testnet_2d8b1b57553d869190f61df1aaf7f31a8fc19a7b ==> 065ee15cf73298e622a33d4e6cebb844b8b343d2 passed
Test Ok

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.

6 participants