Skip to content
Draft
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
11 changes: 7 additions & 4 deletions docs/ProcessRegistry.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ Submits a state transition with zero-knowledge proof.

- Updates latest state root
- Increments vote counts
- Emits `ProcessStateRootUpdated`
- Emits `ProcessStateTransitioned`

#### setProcessResults

Expand Down Expand Up @@ -409,13 +409,16 @@ event ProcessDurationChanged(bytes32 indexed processId, uint256 duration)

Emitted when process duration is modified.

### ProcessStateRootUpdated
### ProcessStateTransitioned

```solidity
event ProcessStateRootUpdated(
event ProcessStateTransitioned(
bytes32 indexed processId,
address indexed sender,
uint256 newStateRoot
uint256 oldStateRoot,
uint256 newStateRoot,
uint256 newVotersCount,
uint256 newOverwrittenVotesCount
)
```

Expand Down
9 changes: 8 additions & 1 deletion src/ProcessRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,14 @@ contract ProcessRegistry is IProcessRegistry {
p.overwrittenVotesCount += st.overwrittenVotesCount;
++p.batchNumber;

emit ProcessStateRootUpdated(processId, msg.sender, st.rootHashAfter);
emit ProcessStateTransitioned(
processId,
msg.sender,
st.rootHashBefore,
st.rootHashAfter,
p.votersCount,
p.overwrittenVotesCount
);
}

/// @inheritdoc IProcessRegistry
Expand Down
10 changes: 9 additions & 1 deletion src/interfaces/IProcessRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ interface IProcessRegistry {
* @param sender The address of the sender.
* @param newStateRoot The new state root of the process.
*/
event ProcessStateRootUpdated(bytes32 indexed processId, address indexed sender, uint256 newStateRoot);
event ProcessStateTransitioned(
bytes32 indexed processId,
address indexed sender,
uint256 oldStateRoot,
uint256 newStateRoot,
uint256 newVotersCount,
uint256 newOverwrittenVotesCount
);

/*
* @notice Emitted when the results of a process are set.
* @param processId The ID of the process.
Expand Down
4 changes: 2 additions & 2 deletions test/ProcessRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,8 @@ contract ProcessRegistryTest is Test, TestHelpers {
vm.mockCall(KZG_PRECOMPILE, "", abi.encode(FIELD_ELEMENTS_PER_BLOB, BLS_MODULUS));

// Submit state transition
emit IProcessRegistry.ProcessStateRootUpdated(processId, address(this), ROOT_HASH_BEFORE);
processRegistry.submitStateTransition(processId, STATETRANSITION_ABI_PROOF, stateTransitionInputs());
emit IProcessRegistry.ProcessStateTransitioned(processId, address(this), ROOT_HASH_AFTER);
processRegistry.submitStateTransition(processId, stateTransitionZKProof, stateTransitionInputs());

// Verify state after transition
process = processRegistry.getProcess(processId);
Expand Down
Loading