-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
1,663 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024 Aztec Labs. | ||
pragma solidity >=0.8.27; | ||
|
||
import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; | ||
|
||
interface ISlasher { | ||
function slash(IPayload _payload) external returns (bool); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024 Aztec Labs. | ||
pragma solidity >=0.8.27; | ||
|
||
import {ISlasher} from "@aztec/core/interfaces/ISlasher.sol"; | ||
import {SlashingProposer} from "@aztec/core/staking/SlashingProposer.sol"; | ||
import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; | ||
|
||
contract Slasher is ISlasher { | ||
SlashingProposer public immutable PROPOSER; | ||
|
||
event SlashFailed(address target, bytes data, bytes returnData); | ||
|
||
error Slasher__CallerNotProposer(address caller, address proposer); // 0x44c1f74f | ||
|
||
constructor(uint256 _n, uint256 _m) { | ||
PROPOSER = new SlashingProposer(msg.sender, this, _n, _m); | ||
} | ||
|
||
function slash(IPayload _payload) external override(ISlasher) returns (bool) { | ||
require( | ||
msg.sender == address(PROPOSER), Slasher__CallerNotProposer(msg.sender, address(PROPOSER)) | ||
); | ||
|
||
IPayload.Action[] memory actions = _payload.getActions(); | ||
|
||
for (uint256 i = 0; i < actions.length; i++) { | ||
// Allow failure of individual calls but emit the failure! | ||
(bool success, bytes memory returnData) = actions[i].target.call(actions[i].data); | ||
if (!success) { | ||
emit SlashFailed(actions[i].target, actions[i].data, returnData); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024 Aztec Labs. | ||
pragma solidity >=0.8.27; | ||
|
||
import {ISlasher} from "@aztec/core/interfaces/ISlasher.sol"; | ||
import {IGovernanceProposer} from "@aztec/governance/interfaces/IGovernanceProposer.sol"; | ||
import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; | ||
import {EmpireBase} from "@aztec/governance/proposer/EmpireBase.sol"; | ||
|
||
/** | ||
* @notice A SlashingProposer implementation following the empire model | ||
*/ | ||
contract SlashingProposer is IGovernanceProposer, EmpireBase { | ||
address public immutable INSTANCE; | ||
ISlasher public immutable SLASHER; | ||
|
||
constructor(address _instance, ISlasher _slasher, uint256 _slashingQuorum, uint256 _roundSize) | ||
EmpireBase(_slashingQuorum, _roundSize) | ||
{ | ||
INSTANCE = _instance; | ||
SLASHER = _slasher; | ||
} | ||
|
||
function getExecutor() public view override(EmpireBase, IGovernanceProposer) returns (address) { | ||
return address(SLASHER); | ||
} | ||
|
||
function getInstance() public view override(EmpireBase, IGovernanceProposer) returns (address) { | ||
return INSTANCE; | ||
} | ||
|
||
function _execute(IPayload _proposal) internal override(EmpireBase) returns (bool) { | ||
return SLASHER.slash(_proposal); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
l1-contracts/src/governance/proposer/GovernanceProposer.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024 Aztec Labs. | ||
pragma solidity >=0.8.27; | ||
|
||
import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; | ||
import {IGovernanceProposer} from "@aztec/governance/interfaces/IGovernanceProposer.sol"; | ||
import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; | ||
import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; | ||
import {EmpireBase} from "./EmpireBase.sol"; | ||
|
||
/** | ||
* @notice A GovernanceProposer implementation following the empire model | ||
* Beware that while governance generally do not care about the implementation | ||
* this implementation will since it is dependent on the sequencer selection. | ||
* This also means that the implementation here will need to be "updated" if | ||
* the interfaces of the sequencer selection changes, for example going optimistic. | ||
*/ | ||
contract GovernanceProposer is IGovernanceProposer, EmpireBase { | ||
IRegistry public immutable REGISTRY; | ||
|
||
constructor(IRegistry _registry, uint256 _n, uint256 _m) EmpireBase(_n, _m) { | ||
REGISTRY = _registry; | ||
} | ||
|
||
function getExecutor() public view override(EmpireBase, IGovernanceProposer) returns (address) { | ||
return REGISTRY.getGovernance(); | ||
} | ||
|
||
function getInstance() public view override(EmpireBase, IGovernanceProposer) returns (address) { | ||
return REGISTRY.getRollup(); | ||
} | ||
|
||
function _execute(IPayload _proposal) internal override(EmpireBase) returns (bool) { | ||
return IGovernance(getExecutor()).propose(_proposal); | ||
} | ||
} |
Oops, something went wrong.