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

[Verifier] verify-bytecode-meter prints module/function breakdown #16963

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

amnn
Copy link
Member

@amnn amnn commented Mar 29, 2024

Description

Use a custom meter to track every function and module that is verified, and display all of them.

Test Plan

deepbook$ cargo run --bin sui -p sui \
  -- client verify-bytecode-meter    \
  --module build/DeepBook/bytecode_modules/math.mv

╭──────────────────────────────────────╮
│ Package will pass metering check!    │
├──────────────────────────────────────┤
│ Limits                               │
├─────────────────────────┬────────────┤
│ packages                │ 16,000,000 │
│   modules               │ 16,000,000 │
│     functions           │ 16,000,000 │
├─────────────────────────┴────────────┤
│ Ticks Used                           │
├─────────────────────────┬────────────┤
│ <unknown>               │     41,915 │
│   math                  │     41,915 │
│     unsafe_mul          │      1,225 │
│     unsafe_mul_round    │      5,675 │
│     mul                 │      2,410 │
│     mul_round           │      2,905 │
│     unsafe_div          │      1,225 │
│     unsafe_div_round    │      6,085 │
│     div_round           │      2,905 │
│     count_leading_zeros │     19,485 │
├─────────────────────────┴────────────┤
│ Package will pass metering check!    │
╰──────────────────────────────────────╯

Stack


If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section.

Type of Change (Check all that apply)

  • protocol change
  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

sui client verify-bytecode-meter prints a breakdown of verifier cost by module and function in a package.

@amnn amnn requested review from dariorussi, stefan-mysten and a team March 29, 2024 17:19
@amnn amnn self-assigned this Mar 29, 2024
Copy link

vercel bot commented Mar 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 1:35pm
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 1:35pm
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2024 1:35pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Apr 8, 2024 1:35pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Apr 8, 2024 1:35pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Apr 8, 2024 1:35pm

"Package will NOT pass metering check!"
};

// Add overall header and footer message;
Copy link
Member Author

Choose a reason for hiding this comment

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

This was quite fiddly (very order sensitive, and lots of magic numbers). Unsure whether there's a cleaner way to do this with tabled so tips appreciated!

Copy link
Contributor

Choose a reason for hiding this comment

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

I remember fiddling with it too, but I don't have any tips on top of my mind. I think in the newer version of tabled things are a bit cleaner, but there's a lot of breaking changes and did not get around updating everything.


// Add overall header and footer message;
table.with(TablePanel::header(message));
table.with(TablePanel::footer(message));
Copy link
Member Author

Choose a reason for hiding this comment

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

Duplicating the message to deal with long outputs where the top might have scrolled off the top of the screen.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say that this is even desired, having both footers and headers for long tables is useful!

amnn added 2 commits April 8, 2024 15:33
## Description

Use a custom meter to track every function and module that is
verified, and display all of them.

## Test Plan

```
deepbook$ cargo run --bin sui -p sui \
  -- client verify-bytecode-meter    \
  --module build/DeepBook/bytecode_modules/math.mv

╭──────────────────────────────────────╮
│ Package will pass metering check!    │
├──────────────────────────────────────┤
│ Limits                               │
├─────────────────────────┬────────────┤
│ packages                │ 16,000,000 │
│   modules               │ 16,000,000 │
│     functions           │ 16,000,000 │
├─────────────────────────┴────────────┤
│ Ticks Used                           │
├─────────────────────────┬────────────┤
│ <unknown>               │     41,915 │
│   math                  │     41,915 │
│     unsafe_mul          │      1,225 │
│     unsafe_mul_round    │      5,675 │
│     mul                 │      2,410 │
│     mul_round           │      2,905 │
│     unsafe_div          │      1,225 │
│     unsafe_div_round    │      6,085 │
│     div_round           │      2,905 │
│     count_leading_zeros │     19,485 │
├─────────────────────────┴────────────┤
│ Package will pass metering check!    │
╰──────────────────────────────────────╯
```
Copy link
Contributor

@dariorussi dariorussi left a comment

Choose a reason for hiding this comment

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

it looks good to me and great break down of info

@amnn amnn merged commit d296555 into main Apr 8, 2024
43 checks passed
@amnn amnn deleted the amnn/verify-acc branch April 8, 2024 15:12
amnn added a commit that referenced this pull request Apr 8, 2024
When passing modules to `sui client verify-bytecode-meter`, support
passing multiple `--modules` to be treated as a single package.

## Test Plan

```
deepbook$ cargo run --bin sui -p sui               \
  -- client verify-bytecode-meter                  \
  --module build/DeepBook/bytecode_modules/math.mv \
  --module build/DeepBook/bytecode_modules/clob.mv

Running bytecode verifier for 2 modules
╭──────────────────────────────────────────────────╮
│ Package will pass metering check!                │
├──────────────────────────────────────────────────┤
│ Limits                                           │
├─────────────────────────────────────┬────────────┤
│ packages                            │ 16,000,000 │
│   modules                           │ 16,000,000 │
│     functions                       │ 16,000,000 │
├─────────────────────────────────────┴────────────┤
│ Ticks Used                                       │
├─────────────────────────────────────┬────────────┤
│ <unknown>                           │  1,859,140 │
│   math                              │     41,915 │
│     unsafe_mul                      │      1,225 │
│     unsafe_mul_round                │      5,675 │
│     mul                             │      2,410 │
│     mul_round                       │      2,905 │
│     unsafe_div                      │      1,225 │
│     unsafe_div_round                │      6,085 │
│     div_round                       │      2,905 │
│     count_leading_zeros             │     19,485 │
│   clob                              │  1,817,225 │
│     destroy_empty_level             │      1,205 │
│     create_account                  │        360 │
│     create_pool                     │        480 │
│     deposit_base                    │      5,490 │
│     deposit_quote                   │      5,490 │
│     withdraw_base                   │      6,500 │
│     withdraw_quote                  │      6,500 │
│     swap_exact_base_for_quote       │     20,805 │
│     swap_exact_quote_for_base       │     18,590 │
│     match_bid_with_quote_quantity   │    383,275 │
│     match_bid                       │    310,200 │
│     match_ask                       │    316,500 │
│     place_market_order              │     37,615 │
│     inject_limit_order              │     70,195 │
│     place_limit_order               │    184,740 │
│     order_is_bid                    │        540 │
│     emit_order_canceled             │      4,905 │
│     emit_order_filled               │      8,335 │
│     cancel_order                    │     57,890 │
│     remove_order                    │     20,095 │
│     cancel_all_orders               │     64,425 │
│     batch_cancel_order              │    102,405 │
│     list_open_orders                │     57,300 │
│     account_balance                 │      6,620 │
│     get_market_price                │      3,265 │
│     get_level2_book_status_bid_side │     39,785 │
│     get_level2_book_status_ask_side │     39,785 │
│     get_level2_book_status          │     23,545 │
│     get_order_status                │     20,385 │
├─────────────────────────────────────┴────────────┤
│ Package will pass metering check!                │
╰──────────────────────────────────────────────────╯
```

## Stack

- #16903 
- #16941 
- #16945 
- #16963 

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [x] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes

`sui client verify-bytecode-meter` supports passing multiple `--module`
flags to verify multiple compiled modules together as if they were one
package.
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.

4 participants