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

[Enhancement] Bail on database lookup errors. #3137

Merged
merged 13 commits into from
Jul 7, 2023
Merged

Conversation

ruseinov
Copy link
Contributor

@ruseinov ruseinov commented Jul 6, 2023

Summary of changes

Changes introduced in this pull request:

  • Propagate database lookup errors properly to avoid mismatches caused by missing state roots.

Reference issue to close (if applicable)

Closes #3126

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@ruseinov ruseinov enabled auto-merge (squash) July 6, 2023 14:16
CHANGELOG.md Outdated Show resolved Hide resolved
src/interpreter/fvm.rs Outdated Show resolved Hide resolved
Err(err)
}
// invalid consensus fault: cannot verify block header signature
Error::Signature(_) => Ok((None, total_gas)),
Copy link
Member

Choose a reason for hiding this comment

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

Do we know why is it okay to discard this error? I get that this logic was there before, I'm just curious.

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, AFAIK when the signature is not correct - we ignore the consensus fault, but we need to report the total gas used for the lookup.

src/interpreter/fvm3.rs Outdated Show resolved Hide resolved
src/interpreter/fvm3.rs Outdated Show resolved Hide resolved
ruseinov and others added 5 commits July 6, 2023 17:18
Co-authored-by: Hubert <hubert@chainsafe.io>
Co-authored-by: Hubert <hubert@chainsafe.io>
Co-authored-by: Hubert <hubert@chainsafe.io>
Co-authored-by: Hubert <hubert@chainsafe.io>
if let Ok(gas_used) = self.verify_block_signature(&bh_1) {
total_gas += gas_used;
if let Ok(gas_used) = self.verify_block_signature(&bh_2) {
let res = self.verify_block_signature(&bh_1);
Copy link
Contributor

Choose a reason for hiding this comment

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

verify_block_signature has three possible outputs: fatal error, non-fatal error, ok(gas_used). We can handle these three branches without any nesting. Not a big deal, but it would make the code easier to read for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was juggling with possible options to make it more readable, the trick here is that a non-fatal error still requires the gas to be passed around so the eloquence suffers there. Let me see what I can do here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@ruseinov ruseinov disabled auto-merge July 6, 2023 16:30
@ruseinov ruseinov enabled auto-merge (squash) July 7, 2023 07:11
@ruseinov ruseinov merged commit ec05f62 into main Jul 7, 2023
@ruseinov ruseinov deleted the ru/feature/lookup-error branch July 7, 2023 07:57
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.

[Enhancement] Figure out a way to throw a lookup error when there aren't enough state-roots.
3 participants