Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy committed Sep 6, 2024
1 parent 3b4312f commit 283041a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ The contract orchestrates four governance operations:

- **Cancel TimeLock Proposal**: Again, similar to Interchain Governance, it cancels an existing governance proposal.

- **Approve Operator Proposal**: This function enables operator proposal approval by setting the proposal's approval status to true. It resets any previous voting and signals successful approval via a OperatorApproved event.
- **Approve Operator Proposal**: This function enables operator proposal approval by setting the proposal's approval status to true. It resets any previous voting and signals successful approval via a OperatorProposalApproved event.

- **Cancel Operator Approval**: Cancels an approved operator proposal, setting the approval status of the proposal to false and indicating successful cancellation through a `OperatorCancelled` event.
- **Cancel Operator Approval**: Cancels an approved operator proposal, setting the approval status of the proposal to false and indicating successful cancellation through a `OperatorProposalCancelled` event.

### Secure Execution of Operator Proposals

Each time a new operator proposal receives approval from governance, the operator voting count is reset to 0. This ensures that any previous votes on similar proposals will not affect the new proposal. When a operator proposal gathers the required number of signatory approvals, it becomes ready for execution. Before execution, the contract verifies the proposal's approval status. If the status is set to false, the transaction is reverted. Once executed successfully, the approval status of the proposal is reset, and a OperatorExecuted event gets emitted.
Each time a new operator proposal receives approval from governance, the operator voting count is reset to 0. This ensures that any previous votes on similar proposals will not affect the new proposal. When a operator proposal gathers the required number of signatory approvals, it becomes ready for execution. Before execution, the contract verifies the proposal's approval status. If the status is set to false, the transaction is reverted. Once executed successfully, the approval status of the proposal is reset, and a OperatorProposalExecuted event gets emitted.
6 changes: 3 additions & 3 deletions contracts/governance/AxelarServiceGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ contract AxelarServiceGovernance is InterchainGovernance, IAxelarServiceGovernan

operatorApprovals[proposalHash] = false;

emit OperatorExecuted(proposalHash, target, callData, nativeValue);
emit OperatorProposalExecuted(proposalHash, target, callData, nativeValue);

_call(target, callData, nativeValue);
}
Expand Down Expand Up @@ -131,12 +131,12 @@ contract AxelarServiceGovernance is InterchainGovernance, IAxelarServiceGovernan
} else if (commandType == uint256(ServiceGovernanceCommand.ApproveOperatorProposal)) {
operatorApprovals[proposalHash] = true;

emit OperatorApproved(proposalHash, target, callData, nativeValue);
emit OperatorProposalApproved(proposalHash, target, callData, nativeValue);
return;
} else if (commandType == uint256(ServiceGovernanceCommand.CancelOperatorApproval)) {
operatorApprovals[proposalHash] = false;

emit OperatorCancelled(proposalHash, target, callData, nativeValue);
emit OperatorProposalCancelled(proposalHash, target, callData, nativeValue);
return;
} else {
revert InvalidCommand();
Expand Down
6 changes: 3 additions & 3 deletions contracts/interfaces/IAxelarServiceGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ interface IAxelarServiceGovernance is IInterchainGovernance {
error NotApproved();
error NotAuthorized();

event OperatorApproved(
event OperatorProposalApproved(
bytes32 indexed proposalHash,
address indexed targetContract,
bytes callData,
uint256 nativeValue
);

event OperatorCancelled(
event OperatorProposalCancelled(
bytes32 indexed proposalHash,
address indexed targetContract,
bytes callData,
uint256 nativeValue
);

event OperatorExecuted(
event OperatorProposalExecuted(
bytes32 indexed proposalHash,
address indexed targetContract,
bytes callData,
Expand Down
26 changes: 13 additions & 13 deletions test/governance/AxelarServiceGovernance.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ describe('AxelarServiceGovernance', () => {
);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorApproved')
.to.emit(serviceGovernance, 'OperatorProposalApproved')
.withArgs(proposalHash, target, calldata, nativeValue);
});

Expand All @@ -180,7 +180,7 @@ describe('AxelarServiceGovernance', () => {
expect(isApproved).to.be.false;

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorApproved')
.to.emit(serviceGovernance, 'OperatorProposalApproved')
.withArgs(proposalHash, target, calldata, nativeValue);

isApproved = await serviceGovernance.isOperatorProposalApproved(target, calldata, nativeValue);
Expand All @@ -204,15 +204,15 @@ describe('AxelarServiceGovernance', () => {
);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorApproved')
.to.emit(serviceGovernance, 'OperatorProposalApproved')
.withArgs(proposalHash, target, calldata, nativeValue);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payloadCancel))
.to.emit(serviceGovernance, 'OperatorCancelled')
.to.emit(serviceGovernance, 'OperatorProposalCancelled')
.withArgs(proposalHash, target, calldata, nativeValue);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorApproved')
.to.emit(serviceGovernance, 'OperatorProposalApproved')
.withArgs(proposalHash, target, calldata, nativeValue);
});

Expand Down Expand Up @@ -251,7 +251,7 @@ describe('AxelarServiceGovernance', () => {
);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorApproved')
.to.emit(serviceGovernance, 'OperatorProposalApproved')
.withArgs(proposalHash, target, invalidCalldata, nativeValue);

await expectRevert(
Expand All @@ -277,15 +277,15 @@ describe('AxelarServiceGovernance', () => {
);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorApproved')
.to.emit(serviceGovernance, 'OperatorProposalApproved')
.withArgs(proposalHash, target, calldata, nativeValue);

await expect(
serviceGovernance
.connect(operator)
.executeOperatorProposal(target, calldata, nativeValue, { value: nativeValue }),
)
.to.emit(serviceGovernance, 'OperatorExecuted')
.to.emit(serviceGovernance, 'OperatorProposalExecuted')
.withArgs(proposalHash, target, calldata, nativeValue)
.and.to.emit(targetContract, 'TargetCalled');
});
Expand All @@ -302,7 +302,7 @@ describe('AxelarServiceGovernance', () => {
);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorApproved')
.to.emit(serviceGovernance, 'OperatorProposalApproved')
.withArgs(proposalHash, target, calldata, nativeValue);

[payload, proposalHash] = await getPayloadAndProposalHash(
Expand All @@ -313,7 +313,7 @@ describe('AxelarServiceGovernance', () => {
);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorCancelled')
.to.emit(serviceGovernance, 'OperatorProposalCancelled')
.withArgs(proposalHash, target, calldata, nativeValue);
});

Expand All @@ -329,7 +329,7 @@ describe('AxelarServiceGovernance', () => {
);

await expect(serviceGovernance.execute(govCommandID, governanceChain, governanceAddress.address, payload))
.to.emit(serviceGovernance, 'OperatorApproved')
.to.emit(serviceGovernance, 'OperatorProposalApproved')
.withArgs(proposalHash, target, calldata, nativeValue);

await ownerWallet
Expand All @@ -344,7 +344,7 @@ describe('AxelarServiceGovernance', () => {
const tx = await serviceGovernance.connect(operator).executeOperatorProposal(target, calldata, nativeValue);

await expect(tx)
.to.emit(serviceGovernance, 'OperatorExecuted')
.to.emit(serviceGovernance, 'OperatorProposalExecuted')
.withArgs(proposalHash, target, calldata, nativeValue)
.and.to.emit(targetContract, 'TargetCalled');

Expand Down Expand Up @@ -411,7 +411,7 @@ describe('AxelarServiceGovernance', () => {
const bytecodeHash = keccak256(bytecode);

const expected = {
london: '0x887cfc32099cde0389bc1f3f134f808dcdd51e718194ace8d423f5270f36f6fd',
london: '0x87891d8e17e62bddae5afa47c6231b236207b7c9cfff0810bc62b226a3765600',
}[getEVMVersion()];

expect(bytecodeHash).to.be.equal(expected);
Expand Down

0 comments on commit 283041a

Please sign in to comment.