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

SIMD-0182: Consume requested CUs for sBPF failures #182

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

tao-stones
Copy link
Contributor

No description provided.

@tao-stones tao-stones marked this pull request as ready for review October 4, 2024 17:31
@Benhawkins18 Benhawkins18 changed the title Conditional cu charging SIMD-0182: Conditional cu charging Oct 8, 2024
Comment on lines +98 to +100
If VM execution returns any error except `SyscallError`, transaction's CU meter
should be fully depleted, in another words, all requested CUs are consumed;
otherwise consumes the actual executed CUs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity, why make syscall errors exempt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding is syscall not happen in VM realm. @Lichtso @ptaffet-jump please correct me if I'm wrong.

Copy link

@topointon-jump topointon-jump Nov 3, 2024

Choose a reason for hiding this comment

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

Syscall errors are never thrown in the middle of basic blocks, so we can easily know exactly how many CUs were consumed when the error was thrown. This is why we can safely make them exempt.

proposals/simd-0182-conditional-cu-metering.md Outdated Show resolved Hide resolved
proposals/simd-0182-conditional-cu-metering.md Outdated Show resolved Hide resolved
proposals/simd-0182-conditional-cu-metering.md Outdated Show resolved Hide resolved

## Detailed Design

If VM execution returns any error except `SyscallError`, transaction's CU meter
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that with direct mapping enabled, we convert EbpfError::AccessViolation into the SyscallError variant here: https://github.com/anza-xyz/agave/blob/af0ed22174999cb62579a0621f6b274c85ebf267/programs/bpf_loader/src/lib.rs#L1501

I am assuming that this access violation should also deplete compute units and should not be considered as an exception right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, same reasoning as: #182 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Should consume all cu's or not?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we should. This is not caused by a syscall so the exact instruction counter would have to be calculated otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just want to call out that this type of access violation is probably going to be fairly common when direct mapping is enabled. So it's not exactly true to say that these types of errors are "rare, exceptional situations" or "A rare case" as we say in the SIMD. We should update the SIMD to say that these types of failures are "less common" rather than rare at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

I see that with direct mapping enabled, we convert EbpfError::AccessViolation into the SyscallError variant here: https://github.com/anza-xyz/agave/blob/af0ed22174999cb62579a0621f6b274c85ebf267/programs/bpf_loader/src/lib.rs#L1501

I am assuming that this access violation should also deplete compute units and should not be considered as an exception right?

@tao-stones this should probably be made explicit in the SIMD. Maybe we can say that all EBPF errors from the vm are treated as irregular.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmm, imo, SIMD's text If VM execution returns any error except SyscallError, .... is clearer.

@tao-stones tao-stones changed the title SIMD-0182: Conditional cu charging SIMD-0182: Consume requested CUs for sBPF failures Nov 21, 2024
Copy link

@topointon-jump topointon-jump left a comment

Choose a reason for hiding this comment

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

This is awesome


## Detailed Design

If VM execution returns any error except `SyscallError`, transaction's CU meter

Choose a reason for hiding this comment

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

I see that with direct mapping enabled, we convert EbpfError::AccessViolation into the SyscallError variant here: https://github.com/anza-xyz/agave/blob/af0ed22174999cb62579a0621f6b274c85ebf267/programs/bpf_loader/src/lib.rs#L1501

I am assuming that this access violation should also deplete compute units and should not be considered as an exception right?

@tao-stones this should probably be made explicit in the SIMD. Maybe we can say that all EBPF errors from the vm are treated as irregular.

Copy link

@ravyu-jump ravyu-jump left a comment

Choose a reason for hiding this comment

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

LGTM

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