Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions backend/node/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,12 +717,7 @@ def _set_vote(self, receipt: Receipt) -> Receipt:
receipt.vote = Vote.DISAGREE
return receipt

# 3. VM crash (exit_code, OOM, etc.) — validator couldn't validate
if result_code == public_abi.ResultCode.VM_ERROR:
receipt.vote = Vote.DISAGREE
return receipt

# 4. Deterministic violation: execution outcome or state diverges from leader
# 3. Deterministic violation: execution outcome or state diverges from leader
leader_receipt = self.leader_receipt
if (
leader_receipt.execution_result != receipt.execution_result
Expand All @@ -732,7 +727,7 @@ def _set_vote(self, receipt: Receipt) -> Receipt:
receipt.vote = Vote.DETERMINISTIC_VIOLATION
return receipt

# 5. Valid execution (RETURN or USER_ERROR) with matching state → agree
# 4. Valid execution with matching state → agree
receipt.vote = Vote.AGREE
return receipt

Expand Down
20 changes: 10 additions & 10 deletions tests/unit/test_set_vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ def test_none_error_code_not_timeout():
assert result.vote == Vote.DETERMINISTIC_VIOLATION


# --- VM crash (non-timeout) → DISAGREE ---
# --- VM error (non-timeout) → compared like any other result ---


def test_vm_error_exit_code_votes_disagree():
"""VM crash (exit_code) should be DISAGREE — validator couldn't validate."""
def test_vm_error_exit_code_mismatching_leader_votes_deterministic_violation():
"""VM error with different result from leader should be DETERMINISTIC_VIOLATION."""
leader_receipt = _make_success_receipt()
node = _make_node(leader_receipt)

Expand All @@ -232,11 +232,11 @@ def test_vm_error_exit_code_votes_disagree():
)

result = node._set_vote(receipt)
assert result.vote == Vote.DISAGREE
assert result.vote == Vote.DETERMINISTIC_VIOLATION


def test_vm_error_oom_votes_disagree():
"""VM OOM should be DISAGREE."""
def test_vm_error_oom_mismatching_leader_votes_deterministic_violation():
"""VM OOM with different result from leader should be DETERMINISTIC_VIOLATION."""
leader_receipt = _make_success_receipt()
node = _make_node(leader_receipt)

Expand All @@ -246,11 +246,11 @@ def test_vm_error_oom_votes_disagree():
)

result = node._set_vote(receipt)
assert result.vote == Vote.DISAGREE
assert result.vote == Vote.DETERMINISTIC_VIOLATION


def test_vm_error_matching_leader_still_disagree():
"""Even if leader and validator crash with same VM error, validator votes DISAGREE."""
def test_vm_error_matching_leader_votes_agree():
"""If leader and validator both get same VM error with same state, validator votes AGREE."""
leader_receipt = _make_receipt(
ResultCode.VM_ERROR,
b"exit_code 1",
Expand All @@ -267,7 +267,7 @@ def test_vm_error_matching_leader_still_disagree():
)

result = node._set_vote(validator_receipt)
assert result.vote == Vote.DISAGREE
assert result.vote == Vote.AGREE


# --- Nondet disagree takes precedence ---
Expand Down
Loading