Skip to content

Commit

Permalink
fix: rename to executor
Browse files Browse the repository at this point in the history
  • Loading branch information
nxqbao committed Apr 2, 2024
1 parent ce1cde4 commit 143705d
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 93 deletions.
8 changes: 4 additions & 4 deletions src/extensions/sequential-governance/CoreGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ abstract contract CoreGovernance is Initializable, SignatureConsumer, VoteStatus
function _proposeProposal(
uint256 chainId,
uint256 expiryTimestamp,
address executer,
address executor,
bool loose,
address[] memory targets,
uint256[] memory values,
Expand All @@ -120,7 +120,7 @@ abstract contract CoreGovernance is Initializable, SignatureConsumer, VoteStatus
if (chainId == 0) revert ErrInvalidChainId(msg.sig, 0, block.chainid);
uint256 round_ = _createVotingRound(chainId);

proposal = Proposal.ProposalDetail(round_, chainId, expiryTimestamp, executer, loose, targets, values, calldatas, gasAmounts);
proposal = Proposal.ProposalDetail(round_, chainId, expiryTimestamp, executor, loose, targets, values, calldatas, gasAmounts);
proposal.validate(_proposalExpiryDuration);

bytes32 proposalHash = proposal.hash();
Expand Down Expand Up @@ -217,7 +217,7 @@ abstract contract CoreGovernance is Initializable, SignatureConsumer, VoteStatus
}

/**
* @dev The specified executer executes the proposal on an approved proposal.
* @dev The specified executor executes the proposal on an approved proposal.
*/
function _executeWithCaller(Proposal.ProposalDetail memory proposal, address caller) internal {
bytes32 proposalHash = proposal.hash();
Expand All @@ -228,7 +228,7 @@ abstract contract CoreGovernance is Initializable, SignatureConsumer, VoteStatus
}

if (_vote.status != VoteStatus.Approved) revert ErrProposalNotApproved();
if (caller != proposal.executer) revert ErrInvalidExecuter();
if (caller != proposal.executor) revert ErrInvalidExecutor();

_tryExecute(_vote, proposal);
}
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/sequential-governance/GlobalCoreGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract contract GlobalCoreGovernance is CoreGovernance {
function _proposeGlobal(
uint256 expiryTimestamp,
GlobalProposal.TargetOption[] calldata targetOptions,
address executer,
address executor,
bool loose,
uint256[] memory values,
bytes[] memory calldatas,
Expand All @@ -51,7 +51,7 @@ abstract contract GlobalCoreGovernance is CoreGovernance {
) internal virtual {
uint256 round_ = _createVotingRound(0);
GlobalProposal.GlobalProposalDetail memory globalProposal =
GlobalProposal.GlobalProposalDetail(round_, expiryTimestamp, executer, loose, targetOptions, values, calldatas, gasAmounts);
GlobalProposal.GlobalProposalDetail(round_, expiryTimestamp, executor, loose, targetOptions, values, calldatas, gasAmounts);
Proposal.ProposalDetail memory proposal = globalProposal.intoProposalDetail(_resolveTargets({ targetOptions: targetOptions, strict: true }));
proposal.validate(_proposalExpiryDuration);

Expand Down
10 changes: 5 additions & 5 deletions src/libraries/GlobalProposal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ library GlobalProposal {
// Nonce to make sure proposals are executed in order
uint256 nonce;
uint256 expiryTimestamp;
address executer;
address executor;
bool loose;
TargetOption[] targetOptions;
uint256[] values;
bytes[] calldatas;
uint256[] gasAmounts;
}

// keccak256("GlobalProposalDetail(uint256 nonce,uint256 expiryTimestamp,address executer,bool loose,uint8[] targetOptions,uint256[] values,bytes[] calldatas,uint256[] gasAmounts)");
// keccak256("GlobalProposalDetail(uint256 nonce,uint256 expiryTimestamp,address executor,bool loose,uint8[] targetOptions,uint256[] values,bytes[] calldatas,uint256[] gasAmounts)");
bytes32 public constant TYPE_HASH = 0x8fdb3bc7211cb44f39a2cae84127672c4570a00720dfbf2bb58285070faa28da;

/**
Expand All @@ -56,7 +56,7 @@ library GlobalProposal {
* TYPE_HASH,
* proposal.nonce,
* proposal.expiryTimestamp,
* proposal.executer,
* proposal.executor,
* proposal.loose,
* targetsHash,
* valuesHash,
Expand All @@ -70,7 +70,7 @@ library GlobalProposal {
mstore(ptr, TYPE_HASH)
mstore(add(ptr, 0x20), mload(self)) // proposal.nonce
mstore(add(ptr, 0x40), mload(add(self, 0x20))) // proposal.expiryTimestamp
mstore(add(ptr, 0x60), mload(add(self, 0x40))) // proposal.executer
mstore(add(ptr, 0x60), mload(add(self, 0x40))) // proposal.executor
mstore(add(ptr, 0x80), mload(add(self, 0x60))) // proposal.loose

let arrayHashed
Expand All @@ -93,7 +93,7 @@ library GlobalProposal {
detail_.nonce = self.nonce;
detail_.chainId = 0;
detail_.expiryTimestamp = self.expiryTimestamp;
detail_.executer = self.executer;
detail_.executor = self.executor;
detail_.loose = self.loose;

detail_.targets = new address[](self.targetOptions.length);
Expand Down
10 changes: 5 additions & 5 deletions src/libraries/Proposal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ library Proposal {
uint256 expiryTimestamp;
// The address that execute the proposal after the proposal passes.
// Leave this address as address(0) to auto-execute by the last valid vote.
address executer;
address executor;
// A `loose` proposal will revert the whole proposal if encounter one internal failed.
// A non-`loose` proposal will ignore the failed internal calls.
bool loose;
Expand All @@ -38,7 +38,7 @@ library Proposal {
uint256[] gasAmounts;
}

// keccak256("ProposalDetail(uint256 nonce,uint256 chainId,uint256 expiryTimestamp,address executer,bool loose,address[] targets,uint256[] values,bytes[] calldatas,uint256[] gasAmounts)");
// keccak256("ProposalDetail(uint256 nonce,uint256 chainId,uint256 expiryTimestamp,address executor,bool loose,address[] targets,uint256[] values,bytes[] calldatas,uint256[] gasAmounts)");
bytes32 public constant TYPE_HASH = 0x98e2bc443e89d620038081eb862bc4dd7a26e2eba7a2a87201642f9419340a57;

/**
Expand Down Expand Up @@ -79,7 +79,7 @@ library Proposal {
// proposal.nonce,
// proposal.chainId,
// proposal.expiryTimestamp
// proposal.executer
// proposal.executor
// proposal.loose
// targetsHash,
// valuesHash,
Expand All @@ -94,7 +94,7 @@ library Proposal {
mstore(add(ptr, 0x20), mload(proposal)) // proposal.nonce
mstore(add(ptr, 0x40), mload(add(proposal, 0x20))) // proposal.chainId
mstore(add(ptr, 0x60), mload(add(proposal, 0x40))) // proposal.expiryTimestamp
mstore(add(ptr, 0x80), mload(add(proposal, 0x80))) // proposal.executer
mstore(add(ptr, 0x80), mload(add(proposal, 0x80))) // proposal.executor
mstore(add(ptr, 0xa0), mload(add(proposal, 0x80))) // proposal.loose

let arrayHashed
Expand All @@ -114,7 +114,7 @@ library Proposal {
* @dev Returns whether the proposal is auto-executed on the last valid vote.
*/
function isAutoExecute(ProposalDetail memory proposal) internal pure returns (bool) {
return proposal.executer == address(0);
return proposal.executor == address(0);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/mainchain/MainchainBridgeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ contract MainchainBridgeManager is BridgeManager, GovernanceRelay, GlobalGoverna
Ballot.VoteType[] calldata supports_,
Signature[] calldata signatures
) external onlyGovernor {
_requireExecuter(proposal.executer, msg.sender);
_requireExecutor(proposal.executor, msg.sender);
_relayProposal(proposal, supports_, signatures, DOMAIN_SEPARATOR, msg.sender);
}

Expand All @@ -56,13 +56,13 @@ contract MainchainBridgeManager is BridgeManager, GovernanceRelay, GlobalGoverna
Ballot.VoteType[] calldata supports_,
Signature[] calldata signatures
) external onlyGovernor {
_requireExecuter(globalProposal.executer, msg.sender);
_requireExecutor(globalProposal.executor, msg.sender);
_relayGlobalProposal({ globalProposal: globalProposal, supports_: supports_, signatures: signatures, domainSeparator: DOMAIN_SEPARATOR, creator: msg.sender });
}

function _requireExecuter(address executer, address caller) internal pure {
if (executer != address(0) && caller != executer) {
revert ErrNonExecuterCannotRelay(executer, caller);
function _requireExecutor(address executor, address caller) internal pure {
if (executor != address(0) && caller != executor) {
revert ErrNonExecutorCannotRelay(executor, caller);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/ronin/gateway/RoninBridgeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ contract RoninBridgeManager is BridgeManager, GovernanceProposal, GlobalGovernan
function propose(
uint256 chainId,
uint256 expiryTimestamp,
address executer,
address executor,
bool loose,
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata calldatas,
uint256[] calldata gasAmounts
) external onlyGovernor {
_proposeProposal(chainId, expiryTimestamp, executer, loose, targets, values, calldatas, gasAmounts, msg.sender);
_proposeProposal(chainId, expiryTimestamp, executor, loose, targets, values, calldatas, gasAmounts, msg.sender);
}

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ contract RoninBridgeManager is BridgeManager, GovernanceProposal, GlobalGovernan
*/
function proposeProposalForCurrentNetwork(
uint256 expiryTimestamp,
address executer,
address executor,
bool loose,
address[] calldata targets,
uint256[] calldata values,
Expand All @@ -94,7 +94,7 @@ contract RoninBridgeManager is BridgeManager, GovernanceProposal, GlobalGovernan
Proposal.ProposalDetail memory _proposal = _proposeProposal({
chainId: block.chainid,
expiryTimestamp: expiryTimestamp,
executer: executer,
executor: executor,
loose: loose,
targets: targets,
values: values,
Expand Down Expand Up @@ -136,7 +136,7 @@ contract RoninBridgeManager is BridgeManager, GovernanceProposal, GlobalGovernan
*/
function proposeGlobal(
uint256 expiryTimestamp,
address executer,
address executor,
bool loose,
GlobalProposal.TargetOption[] calldata targetOptions,
uint256[] calldata values,
Expand All @@ -145,7 +145,7 @@ contract RoninBridgeManager is BridgeManager, GovernanceProposal, GlobalGovernan
) external onlyGovernor {
_proposeGlobal({
expiryTimestamp: expiryTimestamp,
executer: executer,
executor: executor,
loose: loose,
targetOptions: targetOptions,
values: values,
Expand Down
8 changes: 4 additions & 4 deletions src/utils/CommonErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ error ErrInvalidProposal(bytes32 actual, bytes32 expected);
error ErrProposalNotApproved();

/**
* @dev Error of the caller is not the specified executer.
* @dev Error of the caller is not the specified executor.
*/
error ErrInvalidExecuter();
error ErrInvalidExecutor();

/**
* @dev Error of the `caller` to relay is not the specified `executer`.
* @dev Error of the `caller` to relay is not the specified `executor`.
*/
error ErrNonExecuterCannotRelay(address executer, address caller);
error ErrNonExecutorCannotRelay(address executor, address caller);
16 changes: 8 additions & 8 deletions test/bridge/integration/BaseIntegration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ contract BaseIntegration_Test is Base_Test {
// set targets
GlobalProposal.GlobalProposalDetail memory globalProposal = _roninProposalUtils.createGlobalProposal({
expiryTimestamp: block.timestamp + 10,
executer: address(0),
executor: address(0),
loose: false,
targetOption: GlobalProposal.TargetOption.BridgeManager,
value: 0,
Expand All @@ -335,7 +335,7 @@ contract BaseIntegration_Test is Base_Test {
// set bridge contract
GlobalProposal.GlobalProposalDetail memory globalProposal = _roninProposalUtils.createGlobalProposal({
expiryTimestamp: block.timestamp + 10,
executer: address(0),
executor: address(0),
loose: false,
targetOption: GlobalProposal.TargetOption.BridgeManager,
value: 0,
Expand All @@ -355,7 +355,7 @@ contract BaseIntegration_Test is Base_Test {
bytes memory calldata_ = abi.encodeCall(IBridgeManagerCallbackRegister.registerCallbacks, (param.callbackRegisters));
GlobalProposal.GlobalProposalDetail memory globalProposal = _roninProposalUtils.createGlobalProposal({
expiryTimestamp: block.timestamp + 10,
executer: address(0),
executor: address(0),
loose: false,
targetOption: GlobalProposal.TargetOption.BridgeManager,
value: 0,
Expand All @@ -374,7 +374,7 @@ contract BaseIntegration_Test is Base_Test {
// set min governors
GlobalProposal.GlobalProposalDetail memory globalProposal = _roninProposalUtils.createGlobalProposal({
expiryTimestamp: block.timestamp + 10,
executer: address(0),
executor: address(0),
loose: false,
targetOption: GlobalProposal.TargetOption.BridgeManager,
value: 0,
Expand Down Expand Up @@ -414,7 +414,7 @@ contract BaseIntegration_Test is Base_Test {
// set targets
GlobalProposal.GlobalProposalDetail memory globalProposal = _mainchainProposalUtils.createGlobalProposal({
expiryTimestamp: block.timestamp + 10,
executer: address(0),
executor: address(0),
loose: false,
targetOption: GlobalProposal.TargetOption.BridgeManager,
value: 0,
Expand All @@ -432,7 +432,7 @@ contract BaseIntegration_Test is Base_Test {
// set bridge contract
GlobalProposal.GlobalProposalDetail memory globalProposal = _mainchainProposalUtils.createGlobalProposal({
expiryTimestamp: block.timestamp + 10,
executer: address(0),
executor: address(0),
loose: false,
targetOption: GlobalProposal.TargetOption.BridgeManager,
value: 0,
Expand All @@ -452,7 +452,7 @@ contract BaseIntegration_Test is Base_Test {
bytes memory calldata_ = abi.encodeCall(IBridgeManagerCallbackRegister.registerCallbacks, (param.callbackRegisters));
GlobalProposal.GlobalProposalDetail memory globalProposal = _mainchainProposalUtils.createGlobalProposal({
expiryTimestamp: block.timestamp + 10,
executer: address(0),
executor: address(0),
loose: false,
targetOption: GlobalProposal.TargetOption.BridgeManager,
value: 0,
Expand All @@ -471,7 +471,7 @@ contract BaseIntegration_Test is Base_Test {
// set min governors
GlobalProposal.GlobalProposalDetail memory globalProposal = _roninProposalUtils.createGlobalProposal({
expiryTimestamp: block.timestamp + 10,
executer: address(0),
executor: address(0),
loose: false,
targetOption: GlobalProposal.TargetOption.BridgeManager,
value: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import { LibSort } from "solady/utils/LibSort.sol";

import "../../BaseIntegration.t.sol";

contract ProposalWithExecuter_CurrentNetworkProposal_RoninBridgeManager_Test is BaseIntegration_Test {
contract ProposalWithExecutor_CurrentNetworkProposal_RoninBridgeManager_Test is BaseIntegration_Test {
event ProposalVoted(bytes32 indexed proposalHash, address indexed voter, Ballot.VoteType support, uint256 weight);
event ProposalApproved(bytes32 indexed proposalHash);
event ProposalExecuted(bytes32 indexed proposalHash, bool[] successCalls, bytes[] returnDatas);

error ErrInvalidExecuter();
error ErrInvalidExecutor();
error ErrProposalNotApproved();
error ErrInvalidProposalNonce(bytes4 sig);
error ErrLooseProposalInternallyRevert(uint, bytes);
Expand Down Expand Up @@ -62,7 +62,7 @@ contract ProposalWithExecuter_CurrentNetworkProposal_RoninBridgeManager_Test is

_proposal.nonce = _roninBridgeManager.round(block.chainid) + 1;
_proposal.chainId = block.chainid;
_proposal.executer = address(0);
_proposal.executor = address(0);
_proposal.loose = false;
_proposal.expiryTimestamp = block.timestamp + _proposalExpiryDuration;

Expand All @@ -81,7 +81,7 @@ contract ProposalWithExecuter_CurrentNetworkProposal_RoninBridgeManager_Test is
// Should the auto proposal executes on the last valid vote
function test_autoProposal_strictProposal_WhenAllInternalCallsPass() public {
_proposal.loose = false;
_proposal.executer = address(0);
_proposal.executor = address(0);

vm.expectEmit(false, true, true, true);
emit ProposalVoted(_anyValue, _param.roninBridgeManager.governors[0], Ballot.VoteType.For, 100);
Expand Down Expand Up @@ -112,10 +112,10 @@ contract ProposalWithExecuter_CurrentNetworkProposal_RoninBridgeManager_Test is
_roninBridgeManager.execute(_proposal);
}

// Should the non-auto proposal be execute by the specified executer
function test_executerProposal_strictProposal_WhenAllInternalCallsPass() public {
// Should the non-auto proposal be execute by the specified executor
function test_executorProposal_strictProposal_WhenAllInternalCallsPass() public {
_proposal.loose = false;
_proposal.executer = _param.roninBridgeManager.governors[0];
_proposal.executor = _param.roninBridgeManager.governors[0];
_proposal.gasAmounts[1] = 1_000_000; // Set gas for the second call becomes success

vm.expectEmit(false, true, true, true);
Expand All @@ -142,8 +142,8 @@ contract ProposalWithExecuter_CurrentNetworkProposal_RoninBridgeManager_Test is
}

// Should revert when the auto proposal get executed again
function test_executerProposal_revertWhen_proposalIsAlreadyExecuted() external {
test_executerProposal_strictProposal_WhenAllInternalCallsPass();
function test_executorProposal_revertWhen_proposalIsAlreadyExecuted() external {
test_executorProposal_strictProposal_WhenAllInternalCallsPass();

vm.expectRevert(abi.encodeWithSelector(ErrProposalNotApproved.selector));

Expand All @@ -152,9 +152,9 @@ contract ProposalWithExecuter_CurrentNetworkProposal_RoninBridgeManager_Test is
}

// Should the non-auto proposal can not be execute by other governor
function test_executerProposal_revertWhen_proposalIsExecutedByAnotherGovernor() external {
function test_executorProposal_revertWhen_proposalIsExecutedByAnotherGovernor() external {
_proposal.loose = false;
_proposal.executer = _param.roninBridgeManager.governors[0];
_proposal.executor = _param.roninBridgeManager.governors[0];
_proposal.gasAmounts[1] = 1_000_000; // Set gas for the second call becomes success

vm.expectEmit(false, true, true, true);
Expand All @@ -172,7 +172,7 @@ contract ProposalWithExecuter_CurrentNetworkProposal_RoninBridgeManager_Test is
assertEq(_roninBridgeManager.proposalVoted(block.chainid, _proposal.nonce, _param.roninBridgeManager.governors[0]), true);
assertEq(_roninBridgeManager.getBridgeOperators(), _beforeRelayedOperators);

vm.expectRevert(abi.encodeWithSelector(ErrInvalidExecuter.selector));
vm.expectRevert(abi.encodeWithSelector(ErrInvalidExecutor.selector));
vm.prank(_param.roninBridgeManager.governors[1]);
_roninBridgeManager.execute(_proposal);
}
Expand Down
Loading

0 comments on commit 143705d

Please sign in to comment.