Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 0 additions & 2 deletions backend/consensus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,6 @@ def _build_timeout_receipt(validator_dict: dict) -> Receipt:
mode=ExecutionMode.VALIDATOR,
contract_state={},
node_config=validator_dict,
eq_outputs={},
execution_result=ExecutionResultStatus.ERROR,
vote=None,
genvm_result={
Expand Down Expand Up @@ -1835,7 +1834,6 @@ def _build_internal_error_receipt(
mode=ExecutionMode.VALIDATOR,
contract_state={},
node_config=validator_dict,
eq_outputs={},
execution_result=ExecutionResultStatus.ERROR,
vote=Vote.TIMEOUT,
genvm_result={
Expand Down
14 changes: 9 additions & 5 deletions backend/node/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ async def _run_genvm(
self.timing_callback("GENVM_PREPARATION_START")

leader_res: None | dict[int, bytes]
if self.leader_receipt is None:
if self.leader_receipt is None or not self.leader_receipt.eq_outputs:
leader_res = None
else:
leader_res = {
Expand Down Expand Up @@ -1053,10 +1053,14 @@ async def _run_genvm(
result = Receipt(
result=genvmbase.encode_result_to_bytes(result.result),
gas_used=0,
eq_outputs={
k: base64.b64encode(v).decode("ascii")
for k, v in result.eq_outputs.items()
},
eq_outputs=(
{
k: base64.b64encode(v).decode("ascii")
for k, v in result.eq_outputs.items()
}
if self.validator_mode == ExecutionMode.LEADER
else None
),
pending_transactions=result.pending_transactions,
vote=None,
execution_result=result_exec_code,
Expand Down
10 changes: 7 additions & 3 deletions backend/node/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ class Receipt:
mode: ExecutionMode
contract_state: dict[str, str]
node_config: dict
eq_outputs: dict[int, str]
execution_result: ExecutionResultStatus
eq_outputs: dict[int, str] | None = None
vote: Optional[Vote] = None
pending_transactions: Iterable[PendingTransaction] = ()
genvm_result: dict[str, str] | None = None
Expand All @@ -229,7 +229,7 @@ def to_dict(self, strip_contract_state: bool = False):
"mode": self.mode.value,
"contract_state": {} if strip_contract_state else self.contract_state,
"node_config": self.node_config,
"eq_outputs": self.eq_outputs,
**({"eq_outputs": self.eq_outputs} if self.eq_outputs is not None else {}),
"pending_transactions": [
pending_transaction.to_dict()
for pending_transaction in self.pending_transactions
Expand All @@ -254,7 +254,11 @@ def from_dict(cls, input: dict) -> Optional["Receipt"]:
mode=ExecutionMode.from_string(input.get("mode")),
contract_state=input.get("contract_state"),
node_config=input.get("node_config"),
eq_outputs={int(k): v for k, v in input.get("eq_outputs", {}).items()},
eq_outputs=(
{int(k): v for k, v in raw_eq.items()}
if (raw_eq := input.get("eq_outputs"))
else None
),
pending_transactions=[
PendingTransaction.from_dict(pending_transaction)
for pending_transaction in input.get("pending_transactions", [])
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/consensus/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,8 @@ async def exec_with_dynamic_state(transaction: Transaction, llm_mocked: bool):
"address": node["address"],
"private_key": node["private_key"],
},
eq_outputs={},
execution_result=ExecutionResultStatus.SUCCESS,
eq_outputs={} if mode == ExecutionMode.LEADER else None,
)

if USE_MOCK_LLMS:
Expand Down
1 change: 0 additions & 1 deletion tests/unit/consensus/test_validator_exec_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def _make_receipt(address: str, vote: Vote) -> Receipt:
mode=ExecutionMode.VALIDATOR,
contract_state={},
node_config={"address": address},
eq_outputs={},
execution_result=ExecutionResultStatus.SUCCESS,
vote=vote,
genvm_result={"raw_error": {"fatal": False}},
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_leader_llm_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ async def test_validator_fatal_error_returns_receipt():
mode=ExecutionMode.LEADER,
contract_state={},
node_config={},
eq_outputs={},
execution_result=ExecutionResultStatus.SUCCESS,
eq_outputs={},
vote=None,
genvm_result=None,
)
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/test_set_vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def _make_receipt(
mode=ExecutionMode.VALIDATOR,
contract_state=contract_state or {},
node_config={},
eq_outputs={},
execution_result=execution_result,
vote=None,
genvm_result={
Expand All @@ -69,8 +68,8 @@ def _make_success_receipt() -> Receipt:
mode=ExecutionMode.LEADER,
contract_state={"slot": "data"},
node_config={},
eq_outputs={},
execution_result=ExecutionResultStatus.SUCCESS,
eq_outputs={},
vote=None,
genvm_result=None,
)
Expand Down Expand Up @@ -191,7 +190,6 @@ def test_no_genvm_result_does_not_crash():
mode=ExecutionMode.VALIDATOR,
contract_state={},
node_config={},
eq_outputs={},
execution_result=ExecutionResultStatus.ERROR,
vote=None,
genvm_result=None,
Expand Down
Loading