Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prover escrow and 712-signed quotes #8877

Merged
merged 7 commits into from
Oct 1, 2024
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
16 changes: 5 additions & 11 deletions l1-contracts/src/core/ProofCommitmentEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ import {Timestamp} from "@aztec/core/libraries/TimeMath.sol";
contract ProofCommitmentEscrow is IProofCommitmentEscrow {
using SafeERC20 for IERC20;

struct Stake {
uint256 amount;
address prover;
}

struct WithdrawRequest {
uint256 amount;
Timestamp executableAt;
Expand All @@ -29,7 +24,6 @@ contract ProofCommitmentEscrow is IProofCommitmentEscrow {
mapping(address => uint256) public deposits;
mapping(address => WithdrawRequest) public withdrawRequests;
IERC20 public immutable token;
Stake public stake;

modifier onlyRollup() {
require(msg.sender == ROLLUP, Errors.ProofCommitmentEscrow__NotOwner(msg.sender));
Expand Down Expand Up @@ -103,9 +97,8 @@ contract ProofCommitmentEscrow is IProofCommitmentEscrow {
* The prover must have sufficient balance
* The prover's balance will be reduced by the bond amount
*/
function stakeBond(uint256 _amount, address _prover) external override onlyRollup {
function stakeBond(address _prover, uint256 _amount) external override onlyRollup {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Natspec should have the params etc. But think we are generally missing some of that. So seems like something that could be acceptable for now, and then lets create a big ass "update natspec" issue.

Created #8912

deposits[_prover] -= _amount;
stake = Stake({amount: _amount, prover: _prover});

emit StakeBond(_prover, _amount);
}
Expand All @@ -115,9 +108,10 @@ contract ProofCommitmentEscrow is IProofCommitmentEscrow {
*
* @dev Only callable by the owner
*/
function unstakeBond() external override onlyRollup {
deposits[stake.prover] += stake.amount;
delete stake;
function unstakeBond(address _prover, uint256 _amount) external override onlyRollup {
deposits[_prover] += _amount;

emit UnstakeBond(_prover, _amount);
}

/**
Expand Down
14 changes: 2 additions & 12 deletions l1-contracts/src/core/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
return _hashTypedDataV4(EpochProofQuoteLib.hash(quote));
}

function verifySignedQuote(EpochProofQuoteLib.SignedEpochProofQuote memory signedQuote)
public
view
override(IRollup)
{
bytes32 digest = quoteToDigest(signedQuote.quote);
address recoveredSigner = ECDSA.recover(digest, SignatureLib.toBytes(signedQuote.signature));
require(recoveredSigner == signedQuote.quote.prover);
}

/**
* @notice Prune the pending chain up to the last proven block
*
Expand Down Expand Up @@ -358,7 +348,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
// We don't currently unstake,
// but we will as part of https://github.com/AztecProtocol/aztec-packages/issues/8652.
// Blocked on submitting epoch proofs to this contract.
PROOF_COMMITMENT_ESCROW.stakeBond(_quote.quote.bondAmount, _quote.quote.prover);
PROOF_COMMITMENT_ESCROW.stakeBond(_quote.quote.prover, _quote.quote.bondAmount);

proofClaim = DataStructures.EpochProofClaim({
epochToProve: epochToProve,
Expand Down Expand Up @@ -586,7 +576,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup {
view
override(IRollup)
{
verifySignedQuote(_quote);
SignatureLib.verify(_quote.signature, _quote.quote.prover, quoteToDigest(_quote.quote));

Slot currentSlot = getCurrentSlot();
address currentProposer = getCurrentProposer();
Expand Down
6 changes: 3 additions & 3 deletions l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ interface IProofCommitmentEscrow {
event StartWithdraw(address indexed withdrawer, uint256 amount, Timestamp executableAt);
event ExecuteWithdraw(address indexed withdrawer, uint256 amount);
event StakeBond(address indexed prover, uint256 amount);
event UnstakeBond(address indexed prover);
event UnstakeBond(address indexed prover, uint256 amount);

function deposit(uint256 _amount) external;
function startWithdraw(uint256 _amount) external;
function executeWithdraw() external;
function stakeBond(uint256 _bondAmount, address _prover) external;
function unstakeBond() external;
function stakeBond(address _prover, uint256 _amount) external;
function unstakeBond(address _prover, uint256 _amount) external;
function minBalanceAtTime(Timestamp _timestamp, address _prover) external view returns (uint256);
}
3 changes: 0 additions & 3 deletions l1-contracts/src/core/interfaces/IRollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ interface IRollup {
external
view
returns (bytes32);
function verifySignedQuote(EpochProofQuoteLib.SignedEpochProofQuote calldata _quote)
external
view;

function archive() external view returns (bytes32);
function archiveAt(uint256 _blockNumber) external view returns (bytes32);
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/src/mock/MockProofCommitmentEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ contract MockProofCommitmentEscrow is IProofCommitmentEscrow {
// do nothing
}

function unstakeBond() external override {
function unstakeBond(address _prover, uint256 _amount) external override {
// do nothing
}

function stakeBond(uint256 _amount, address _prover) external override {
function stakeBond(address _prover, uint256 _amount) external override {
// do nothing
}

Expand Down
Loading
Loading