Verify the last decision with VerifyProposal before delivering it during a view change

オープン
#774 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
go

調査の方向性

Start by reading ValidateLastDecision and its callers, validateViewDataMsg and validateNewViewMsg, then check the Verifier documentation in pkg/api and the related cases in viewchanger_test.go. Add coverage for both view change paths with VerifyProposal succeeding and failing; done means rejection delivers nothing, while success still delivers the decision.

索引モデルが issue の本文から書いたものです。

説明

Background

On the normal path, a node calls Verifier.VerifyProposal on a proposal when it gets the pre-prepare (View.verifyProposal), before it sends a prepare. A proposal is delivered only after a commit quorum, so every delivered proposal has passed VerifyProposal on that node.

What happens during a view change

A node that is exactly one sequence behind can catch up during a view change, using the LastDecision carried in a ViewData. This happens in two places:

  • validateViewDataMsg, when the node receives a ViewData directly;
  • validateNewViewMsg, for the ViewData messages inside a NewView.

In both places, when the last decision's sequence is the node's sequence + 1, the node calls ValidateLastDecision and then deliverDecision. ValidateLastDecision checks that:

  • the last decision is set and its metadata can be parsed;
  • its view is lower than the requested next view;
  • there are at least a quorum of signatures from distinct signers, and each one passes Verifier.VerifyConsenterSig.

VerifyProposal isn't called on this path. So the delivered proposal is checked only as far as VerifyConsenterSig covers it. The API doesn't require VerifyConsenterSig to cover the whole proposal, and in practice it may not. For example, an application might sign the header and metadata, and check that the payload matches the header only in VerifyProposal. In that case, the payload delivered on this path is never checked against the header.

On the NewView path, the signature on each ViewData is verified only after deliverDecision. That is deliberate, because the delivered decision may be a reconfiguration that changes the keys. It also means the quorum signatures are the only check that runs before delivery.

Proposed fix

In ValidateLastDecision, after the signature checks, call verifier.VerifyProposal on the last decision, and return an error if it fails.

  • Both callers of ValidateLastDecision are on the one-behind path. There, the application state (last committed decision, configuration, verification sequence) is the same as when the proposal was first verified. So a correct decision should pass VerifyProposal again.
  • Call only Verifier.VerifyProposal, not View.verifyProposal. The view-specific checks there (view number, decisions in view, blacklist, previous-commit digest) are relative to the current view, and don't hold for a decision made in an earlier view.
  • Build the proposal once, outside the signature loop. ValidateLastDecision could also return the proposal and signatures, so the two callers don't each rebuild them.
  • VerifyProposal runs at most once per delivery. validateNewViewMsg returns after the first delivery, and after a ViewData delivery the node is no longer one behind.
  • If VerifyProposal rejects a correct decision, for example because the application's checks depend on time, the node doesn't deliver it and catches up through sync instead. Safety is not affected.
  • Update the Verifier doc in pkg/api to say that VerifyProposal may also be called on a proposal that was already decided, before it is delivered.
Tests
  • In viewchanger_test.go, for both the ViewData and the NewView paths:
    • when the last decision is one ahead and VerifyProposal returns an error, nothing is delivered and the message is rejected;
    • when VerifyProposal succeeds, the decision is still delivered.
  • Existing view changer tests that mock Verifier without a VerifyProposal expectation will need one added.
  • Optionally, make the test app's VerifyProposal stricter (it accepts any payload today), so that the integration tests exercise this path.

Written by Claude (AI assistant) on behalf of Hagar Meir.

主要言語
Go
スター
110
フォーク
41
平均マージ
20時間 59分
マージ済み PR(30日)
27

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hyperledger/SmartBFT のほかの issue

hyperledger/SmartBFT の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。