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

[cli] Fix issues with showing the output for a transaction #16190

Merged

Conversation

stefan-mysten
Copy link
Contributor

@stefan-mysten stefan-mysten commented Feb 11, 2024

Description

This fixes the panic that tabled throws when trying to show the output for a transaction that has no inputs or commands. (e.g., calling client call --package 0x2 --module kiosk --function default).

Test Plan

Existing tests, manual test.

Before:

thread 'main' panicked at /Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs:25:18:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2024-02-11T03:33:37.781716Z ERROR telemetry_subscribers: panicked at /Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs:25:18:
index out of bounds: the len is 0 but the index is 0 panic.file="/Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs" panic.line=25 panic.column=18

After:

Transaction Digest: ANmDQptNpb72oGKgb4Wygq9uFDWLxJwPAo865e75kP8N
╭─────────────────────────────────────────────────────────────────────────────────────────────╮
│ Transaction Data                                                                            │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│ Sender: 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea                  │
│ Gas Owner: 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea               │
│ Gas Budget: 1000000000 MIST                                                                 │
│ Gas Price: 1000 MIST                                                                        │
│ Gas Payment:                                                                                │
│  ┌──                                                                                        │
│  │ ID: 0x1270f13fabe5a1622179827643e8d0989a689a2dfb2e0ff74e97685186159c73                   │
│  │ Version: 17                                                                              │
│  │ Digest: 2DTL2j9YGvy92AUhd5ECzx3jGLCk98VA4muvWqu4A4xs                                     │
│  └──                                                                                        │
│                                                                                             │
│ Transaction Kind: Programmable                                                              │
│   No input objects for this transaction                                                     │
│ ╭──────────────────────────────────────────────────────────────────────────────────╮        │
│ │ Commands                                                                         │        │
│ ├──────────────────────────────────────────────────────────────────────────────────┤        │
│ │ 0  MoveCall:                                                                     │        │
│ │  ┌                                                                               │        │
│ │  │ Function:  default                                                            │        │
│ │  │ Module:    kiosk                                                              │        │
│ │  │ Package:   0x0000000000000000000000000000000000000000000000000000000000000002 │        │
│ │  └                                                                               │        │
│ ╰──────────────────────────────────────────────────────────────────────────────────╯        │
│                                                                                             │
│ Signatures:                                                                                 │
│    +OOZ8uwjS+XK3sz0TyMf19d6ouwLSfqiF57jSFxkH0KNJN2c9tDebN3JrqEHXV6wzON492THldd95oLDW+6UBA== │
│                                                                                             │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯

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

The CLI now properly handles the table output for a transaction that has no inputs or commands. For example, calling client call --package 0x2 --module kiosk --function default now has a properly formatted output.

…d tabled panics) when there is no input or command for the PTB
@stefan-mysten stefan-mysten requested review from a team February 11, 2024 06:45
Copy link

vercel bot commented Feb 11, 2024

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

Name Status Preview Comments Updated (UTC)
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 11, 2024 6:46am
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 11, 2024 6:46am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2024 6:46am
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2024 6:46am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2024 6:46am

Copy link
Contributor

@tzakian tzakian left a comment

Choose a reason for hiding this comment

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

Left one nit on possibly doing an early return to minimize diff size, but otherwise Lgtm.

}
SuiCallArg::Object(SuiObjectArg::Receiving { object_id, .. }) => {
builder.push_record(vec![format!("{i:<3} Receiving Object ID: {}", object_id)]);
if !inputs.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: may be nicer to phrase this change in terms of something like
if inputs.is_empty() { return write!(EMPTY CASE...} and then the rest of the code can stay the same. But fine with it as-is as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, will do that! Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, there are two tables being built, so returning early will not allow the second table (commands) to be built.

@stefan-mysten stefan-mysten merged commit 266311d into MystenLabs:main Feb 11, 2024
40 checks passed
@stefan-mysten stefan-mysten deleted the cli_fix_table_grid_error branch February 11, 2024 16:30
stefan-mysten added a commit to stefan-mysten/sui that referenced this pull request Feb 11, 2024
…s#16190)

## Description 

This fixes the panic that tabled throws when trying to show the output
for a transaction that has no inputs or commands. (e.g., calling `client
call --package 0x2 --module kiosk --function default`).

## Test Plan 

Existing tests, manual test.

Before:
```
thread 'main' panicked at /Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs:25:18:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2024-02-11T03:33:37.781716Z ERROR telemetry_subscribers: panicked at /Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs:25:18:
index out of bounds: the len is 0 but the index is 0 panic.file="/Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs" panic.line=25 panic.column=18
```

After:
```
Transaction Digest: ANmDQptNpb72oGKgb4Wygq9uFDWLxJwPAo865e75kP8N
╭─────────────────────────────────────────────────────────────────────────────────────────────╮
│ Transaction Data                                                                            │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│ Sender: 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea                  │
│ Gas Owner: 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea               │
│ Gas Budget: 1000000000 MIST                                                                 │
│ Gas Price: 1000 MIST                                                                        │
│ Gas Payment:                                                                                │
│  ┌──                                                                                        │
│  │ ID: 0x1270f13fabe5a1622179827643e8d0989a689a2dfb2e0ff74e97685186159c73                   │
│  │ Version: 17                                                                              │
│  │ Digest: 2DTL2j9YGvy92AUhd5ECzx3jGLCk98VA4muvWqu4A4xs                                     │
│  └──                                                                                        │
│                                                                                             │
│ Transaction Kind: Programmable                                                              │
│   No input objects for this transaction                                                     │
│ ╭──────────────────────────────────────────────────────────────────────────────────╮        │
│ │ Commands                                                                         │        │
│ ├──────────────────────────────────────────────────────────────────────────────────┤        │
│ │ 0  MoveCall:                                                                     │        │
│ │  ┌                                                                               │        │
│ │  │ Function:  default                                                            │        │
│ │  │ Module:    kiosk                                                              │        │
│ │  │ Package:   0x0000000000000000000000000000000000000000000000000000000000000002 │        │
│ │  └                                                                               │        │
│ ╰──────────────────────────────────────────────────────────────────────────────────╯        │
│                                                                                             │
│ Signatures:                                                                                 │
│    +OOZ8uwjS+XK3sz0TyMf19d6ouwLSfqiF57jSFxkH0KNJN2c9tDebN3JrqEHXV6wzON492THldd95oLDW+6UBA== │
│                                                                                             │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯
```
---
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
Fixed the CLI to handle the table output for a transaction that has no
inputs or commands. (e.g., calling `client call --package 0x2 --module
kiosk --function default`).
stefan-mysten added a commit that referenced this pull request Feb 12, 2024
…16193)

## Description 

This fixes the panic that tabled throws when trying to show the output
for a transaction that has no inputs or commands. (e.g., calling `client
call --package 0x2 --module kiosk --function default`).

## Test Plan 

Existing tests, manual test.

Before:
```
thread 'main' panicked at /Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs:25:18:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2024-02-11T03:33:37.781716Z ERROR telemetry_subscribers: panicked at /Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs:25:18:
index out of bounds: the len is 0 but the index is 0 panic.file="/Users/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tabled-0.15.0/src/grid/records/records_mut.rs" panic.line=25 panic.column=18
```

After:
```
Transaction Digest: ANmDQptNpb72oGKgb4Wygq9uFDWLxJwPAo865e75kP8N
╭─────────────────────────────────────────────────────────────────────────────────────────────╮
│ Transaction Data                                                                            │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│ Sender: 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea                  │
│ Gas Owner: 0x0fe375fff0ee40d20c54a7f2478b9b5c7eaa3625b7611f9661ec5faefb4a6fea               │
│ Gas Budget: 1000000000 MIST                                                                 │
│ Gas Price: 1000 MIST                                                                        │
│ Gas Payment:                                                                                │
│  ┌──                                                                                        │
│  │ ID: 0x1270f13fabe5a1622179827643e8d0989a689a2dfb2e0ff74e97685186159c73                   │
│  │ Version: 17                                                                              │
│  │ Digest: 2DTL2j9YGvy92AUhd5ECzx3jGLCk98VA4muvWqu4A4xs                                     │
│  └──                                                                                        │
│                                                                                             │
│ Transaction Kind: Programmable                                                              │
│   No input objects for this transaction                                                     │
│ ╭──────────────────────────────────────────────────────────────────────────────────╮        │
│ │ Commands                                                                         │        │
│ ├──────────────────────────────────────────────────────────────────────────────────┤        │
│ │ 0  MoveCall:                                                                     │        │
│ │  ┌                                                                               │        │
│ │  │ Function:  default                                                            │        │
│ │  │ Module:    kiosk                                                              │        │
│ │  │ Package:   0x0000000000000000000000000000000000000000000000000000000000000002 │        │
│ │  └                                                                               │        │
│ ╰──────────────────────────────────────────────────────────────────────────────────╯        │
│                                                                                             │
│ Signatures:                                                                                 │
│    +OOZ8uwjS+XK3sz0TyMf19d6ouwLSfqiF57jSFxkH0KNJN2c9tDebN3JrqEHXV6wzON492THldd95oLDW+6UBA== │
│                                                                                             │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯
```
---
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
Fixed the CLI to handle the table output for a transaction that has no
inputs or commands. (e.g., calling `client call --package 0x2 --module
kiosk --function default`).
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.

2 participants