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

Streamline validation #3448

Merged
merged 10 commits into from
Jul 5, 2024
Prev Previous commit
Next Next commit
Updates docs of finalize_block and process_proposal
  • Loading branch information
grarco committed Jun 27, 2024
commit 2b2bbd835252323b80561e4e727f01e1ba082411
17 changes: 1 addition & 16 deletions crates/node/src/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,7 @@ where
/// of epoch changes and applies associated updates to validator sets,
/// etc. as necessary.
///
/// Validate and apply decrypted transactions unless
/// [`Shell::process_proposal`] detected that they were not submitted in
/// correct order or more decrypted txs arrived than expected. In that
/// case, all decrypted transactions are not applied and must be
/// included in the next `Shell::prepare_proposal` call.
///
/// Incoming wrapper txs need no further validation. They
/// are added to the block.
///
/// Error codes:
/// 0: Ok
/// 1: Invalid tx
/// 2: Tx is invalidly signed
/// 3: Wasm runtime error
/// 4: Invalid order of decrypted txs
/// 5. More decrypted txs than expected
/// Apply the transactions included in the block.
pub fn finalize_block(
&mut self,
req: shim::request::FinalizeBlock,
Expand Down
27 changes: 15 additions & 12 deletions crates/node/src/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ where
);
}
(
// FIXME: match this on the other side
if invalid_txs {
ProcessProposal::Reject
} else {
Expand Down Expand Up @@ -174,19 +175,21 @@ where
///
/// Error codes:
/// 0: Ok
/// 1: Invalid tx
/// 2: Tx is invalidly signed
/// 3: Wasm runtime error
/// 4: Invalid order of decrypted txs
/// 5. More decrypted txs than expected
/// 6. A transaction could not be decrypted
/// 7. An error in the vote extensions included in the proposal
/// 8. Not enough block space was available for some tx
/// 9. Replay attack
/// 1: Wasm runtime error
/// 2: Invalid tx
/// 3: Tx is invalidly signed
/// 4: Block is full
/// 5: Replay attempt
/// 6. Tx targets a different chain id
/// 7. Tx is expired
/// 8. Tx exceeds the gas limit
/// 9. Tx failed to pay fees
/// 10. An error in the vote extensions included in the proposal
/// 11. Not enough block space was available for some tx
/// 12. Tx wasm code is not allowlisted
///
/// INVARIANT: Any changes applied in this method must be reverted if the
/// proposal is rejected (unless we can simply overwrite them in the
/// next block).
/// INVARIANT: This function should not, under any circumstances, modify the
/// state since the proposal could be rejected.
#[allow(clippy::too_many_arguments)]
pub fn check_proposal_tx<CA>(
&self,
Expand Down