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

Coral getter, readme update #97

Merged
merged 6 commits into from
Oct 20, 2023
Merged
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
72 changes: 37 additions & 35 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,42 @@ EnclaveVerifierTest:testRaveEvidence2() (gas: 1123695)
EnclaveVerifierTest:testRaveEvidence3() (gas: 1123760)
EnclaveVerifierTest:testRemoveLeafX509() (gas: 336920)
EnclaveVerifierTest:testSetup() (gas: 115053)
GuardianModuleTest:testRave() (gas: 35926457)
GuardianModuleTest:testRoateGuardianKeyWithInvalidRaveReverts() (gas: 855653)
GuardianModuleTest:testRoateGuardianToInvalidPubKeyReverts() (gas: 22830)
GuardianModuleTest:testRotateGuardianKeyFromNonGuardianReverts() (gas: 20245)
GuardianModuleTest:testRave() (gas: 37541075)
GuardianModuleTest:testRoateGuardianKeyWithInvalidRaveReverts() (gas: 855915)
GuardianModuleTest:testRoateGuardianToInvalidPubKeyReverts() (gas: 22865)
GuardianModuleTest:testRotateGuardianKeyFromNonGuardianReverts() (gas: 20280)
PufferPoolIntegrationTest:testMulticallStrategyDepositOnGoerli() (gas: 302650)
PufferPoolTest:testBurn(address) (runs: 256, μ: 66339, ~: 66324)
PufferPoolTest:testDeposit(address,uint256) (runs: 256, μ: 97060, ~: 97178)
PufferPoolTest:testBurn(address) (runs: 256, μ: 66320, ~: 66306)
PufferPoolTest:testDeposit(address,uint256) (runs: 256, μ: 97002, ~: 97112)
PufferPoolTest:testDepositRevertsForTooSmallAmount() (gas: 15040)
PufferPoolTest:testMultipleDeposits() (gas: 123090)
PufferPoolTest:testRatioChange() (gas: 188957)
PufferPoolTest:testRatioChangeSandwichAttack(uint256,uint256) (runs: 256, μ: 181213, ~: 181399)
PufferPoolTest:testSetup() (gas: 32425)
PufferPoolTest:testStorageS() (gas: 19447)
PufferProtocolTest:testCreateExistingStrategyShouldFail() (gas: 8797746687696156720)
PufferProtocolTest:testCreatePufferStrategy() (gas: 259915)
PufferProtocolTest:testEmptyQueue() (gas: 32870)
PufferProtocolTest:testExtendCommitment() (gas: 459017)
PufferProtocolTest:testProofOfReserve() (gas: 150836)
PufferProtocolTest:testProvisionNode() (gas: 3639823)
PufferProtocolTest:testRegisterInvalidPrivKeyShares() (gas: 78626)
PufferProtocolTest:testRegisterInvalidPubKeyShares() (gas: 78822)
PufferProtocolTest:testRegisterMoreValidatorsThanTheLimit() (gas: 727128)
PufferProtocolTest:testRegisterMultipleValidatorKeysAndDequeue(bytes32,bytes32) (runs: 256, μ: 1922838, ~: 1922838)
PufferProtocolTest:testRegisterToInvalidStrategy() (gas: 56273)
PufferProtocolTest:testRegisterWithInvalidAmountPaid() (gas: 81529)
PufferProtocolTest:testRegisterWithoutRAVE() (gas: 33542)
PufferProtocolTest:testSetProtocolFeeRate() (gas: 33278)
PufferProtocolTest:testSetSmoothingCommitment() (gas: 35089)
PufferProtocolTest:testSetSmoothingCommitment(bytes32) (runs: 256, μ: 52260, ~: 52260)
PufferProtocolTest:testSetup() (gas: 12818)
PufferProtocolTest:testSkipProvisioning() (gas: 873245)
PufferProtocolTest:testStopRegistration() (gas: 998787)
PufferProtocolTest:testUpgrade() (gas: 3881019)
PufferStrategyTest:testBeaconUpgrade() (gas: 103226)
PufferStrategyTest:testGetEigenPod() (gas: 25959)
WithdrawalPoolTest:testWithdrawETH() (gas: 160220)
WithdrawalPoolTest:testWithdrawETHWithSignature() (gas: 172454)
PufferPoolTest:testMultipleDeposits() (gas: 123046)
PufferPoolTest:testRatioChange() (gas: 189082)
PufferPoolTest:testRatioChangeSandwichAttack(uint256,uint256) (runs: 256, μ: 180853, ~: 181042)
PufferPoolTest:testSetup() (gas: 32449)
PufferPoolTest:testStorageS() (gas: 19425)
PufferProtocolTest:testCreateExistingStrategyShouldFail() (gas: 8797746687696156717)
PufferProtocolTest:testCreatePufferStrategy() (gas: 259907)
PufferProtocolTest:testEmptyQueue() (gas: 32675)
PufferProtocolTest:testExtendCommitment() (gas: 559444)
PufferProtocolTest:testGetPayload() (gas: 175292)
PufferProtocolTest:testProofOfReserve() (gas: 151365)
PufferProtocolTest:testProvisionNode() (gas: 4090444)
PufferProtocolTest:testRegisterInvalidPrivKeyShares() (gas: 78761)
PufferProtocolTest:testRegisterInvalidPubKeyShares() (gas: 78957)
PufferProtocolTest:testRegisterMoreValidatorsThanTheLimit() (gas: 851492)
PufferProtocolTest:testRegisterMultipleValidatorKeysAndDequeue(bytes32,bytes32) (runs: 256, μ: 2182462, ~: 2182462)
PufferProtocolTest:testRegisterToInvalidStrategy() (gas: 56376)
PufferProtocolTest:testRegisterWithInvalidAmountPaid() (gas: 81647)
PufferProtocolTest:testRegisterWithInvalidBLSPubKey() (gas: 30727)
PufferProtocolTest:testRegisterWithoutRAVE() (gas: 33532)
PufferProtocolTest:testSetProtocolFeeRate() (gas: 33314)
PufferProtocolTest:testSetSmoothingCommitment() (gas: 35126)
PufferProtocolTest:testSetSmoothingCommitment(bytes32) (runs: 256, μ: 52319, ~: 52319)
PufferProtocolTest:testSetup() (gas: 12730)
PufferProtocolTest:testSkipProvisioning() (gas: 1026027)
PufferProtocolTest:testStopRegistration() (gas: 1123081)
PufferProtocolTest:testUpgrade() (gas: 4111855)
PufferStrategyTest:testBeaconUpgrade() (gas: 106006)
PufferStrategyTest:testGetEigenPod() (gas: 25937)
WithdrawalPoolTest:testWithdrawETH() (gas: 160266)
WithdrawalPoolTest:testWithdrawETHWithSignature() (gas: 172460)
62 changes: 24 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
# <h1 align="center"> Forge Template </h1>

**Template repository for getting started quickly with Foundry projects**

![Github Actions](https://github.com/foundry-rs/forge-template/workflows/CI/badge.svg)

## Getting Started

Click "Use this template" on [GitHub](https://github.com/foundry-rs/forge-template) to create a new repository with this repo as the initial state.

Or, if your repo already exists, run:
```sh
forge init
forge build
forge test
# <h1 align="center"> Puffer Protocol </h1>
[![Github Actions][gha-badge]][gha] [![Website][Website-badge]][Website] [![Docs][docs-badge]][docs]
[![Discord][discord-badge]][discord] [![X][X-badge]][X] [![Foundry][foundry-badge]][foundry]

[Website-badge]: https://img.shields.io/badge/WEBSITE-8A2BE2
[Website]: https://www.puffer.fi
[X-badge]: https://img.shields.io/twitter/follow/puffer_finance
[X]: https://twitter.com/puffer_finance
[discord]: https://discord.gg/pufferfi
[docs-badge]: https://img.shields.io/badge/DOCS-8A2BE2
[docs]: https://docs.puffer.fi/
[discord-badge]: https://dcbadge.vercel.app/api/server/pufferfi?style=flat
[gha]: https://github.com/PufferFinance/PufferPool/actions
[gha-badge]: https://github.com/PufferFinance/PufferPool/actions/workflows/ci.yml/badge.svg
[foundry]: https://getfoundry.sh
[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg

![PUFFERS](image.png)

# Tests

Installing dependencies and running tests can be executed running:
```

## Writing your first test

All you need is to `import forge-std/Test.sol` and then inherit it from your test contract. Forge-std's Test contract comes with a pre-instatiated [cheatcodes environment](https://book.getfoundry.sh/cheatcodes/), the `vm`. It also has support for [ds-test](https://book.getfoundry.sh/reference/ds-test.html)-style logs and assertions. Finally, it supports Hardhat's [console.log](https://github.com/brockelmore/forge-std/blob/master/src/console.sol). The logging functionalities require `-vvvv`.

```solidity
pragma solidity 0.8.10;

import "forge-std/Test.sol";

contract ContractTest is Test {
function testExample() public {
vm.roll(100);
console.log(1);
emit log("hi");
assertTrue(true);
}
}
```

## Development

This project uses [Foundry](https://getfoundry.sh). See the [book](https://book.getfoundry.sh/getting-started/installation.html) for instructions on how to install and use Foundry.
forge test -vvv --match-path './test/unit/*'
```
5 changes: 3 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ bracket_spacing = true

[rpc_endpoints]
# mainnet="https://eth-mainnet-public.unifra.io"
mainnet="https://eth.llamarpc.com"
goerli="https://ethereum-goerli-archive.allthatnode.com"
# mainnet="https://eth.llamarpc.com"
# goerli="https://ethereum-goerli-archive.allthatnode.com"
goerli="${GOERLI_RPC_URL}"

[invariant]
# fail_on_revert=true
Expand Down
Binary file added image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions script/1_DeployGuardians.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import { Safe } from "safe-contracts/Safe.sol";
import { SafeProxy } from "safe-contracts/proxies/SafeProxy.sol";
import { SafeProxyFactory } from "safe-contracts/proxies/SafeProxyFactory.sol";
import { console } from "forge-std/console.sol";
import { AccessManager } from "openzeppelin/access/manager/AccessManager.sol";
import { Strings } from "openzeppelin/utils/Strings.sol";

// forge script script/1_DeployGuardians.s.sol:DeployGuardians --rpc-url=$EPHEMERY_RPC_URL --sig 'run(address[] calldata, uint256)' "[0x5F9a7EA6A79Ef04F103bfe7BD45dA65476a5155C]" 1
contract DeployGuardians is BaseScript {
address safeProxy;
address safeImplementation;

function run(address[] calldata guardians, uint256 threshold) public broadcast returns (Safe, GuardianModule) {
function run(address[] calldata guardians, uint256 threshold, bytes calldata emptyData) public broadcast returns (Safe, GuardianModule) {
safeProxy = vm.envOr("SAFE_PROXY_ADDRESS", address(new SafeProxyFactory()));
safeImplementation = vm.envOr("SAFE_IMPLEMENTATION_ADDRESS", address(new Safe()));

Expand All @@ -24,14 +25,17 @@ contract DeployGuardians is BaseScript {

EnclaveVerifier verifier = new EnclaveVerifier(100);

Safe guardiansSafe = this.deploySafe(guardians, threshold, address(0), "");
AccessManager accessManager = new AccessManager(_broadcaster);

GuardianModule module = new GuardianModule(verifier, guardiansSafe);
Safe guardiansSafe = deploySafe(guardians, threshold, address(0), emptyData);

GuardianModule module = new GuardianModule(verifier, guardiansSafe, address(accessManager));

// console.log(address(guardiansSafe), "<-- Guardians multisig deployed");

string memory obj = "";
vm.serializeAddress(obj, "guardians", address(guardiansSafe));
vm.serializeAddress(obj, "accessManager", address(accessManager));
vm.serializeAddress(obj, "guardianModule", address(module));
vm.serializeAddress(obj, "safeProxyFactory", address(safeProxy));
vm.serializeAddress(obj, "safeImplementation", address(safeImplementation));
Expand All @@ -45,7 +49,7 @@ contract DeployGuardians is BaseScript {
}

function deploySafe(address[] calldata owners, uint256 threshold, address to, bytes calldata data)
public
internal
returns (Safe)
{
address zeroAddress = address(0);
Expand Down
4 changes: 2 additions & 2 deletions script/DeployPuffer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ contract DeployPuffer is BaseScript {

PufferProtocol pufferProtocolImpl;

AccessManager accessManager = new AccessManager(_broadcaster);
AccessManager accessManager = AccessManager(stdJson.readAddress(guardiansDeployment, ".accessManager"));

{
// PufferTreasury
Expand Down Expand Up @@ -80,7 +80,7 @@ contract DeployPuffer is BaseScript {
pufferProtocol.initialize({
accessManager: address(accessManager),
pool: pool,
withdrawalPool: address(withdrawalPool),
withdrawalPool: withdrawalPool,
guardianSafeModule: guardiansModule
});

Expand Down
14 changes: 14 additions & 0 deletions shell-scripts/deploy_puffer_protocol.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PK is for anvil #1 account and he is the deployer
export PK=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
export RPC_URL=http://localhost:8545

forge script script/1_DeployGuardians.s.sol:DeployGuardians --rpc-url=$RPC_URL --sig 'run(address[] calldata, uint256, bytes calldata)' "[0xDDDeAfB492752FC64220ddB3E7C9f1d5CcCdFdF0]" 1 "" --broadcast

forge script script/SetGuardianEnclaveMeasurements.s.sol:SetEnclaveMeasurements --rpc-url=$RPC_URL --broadcast --sig "run(bytes32,bytes32)" -vvvv 0x2f1488bd64b2c85fc3fe4fa535a89cfa5282ae960e902664ff5390909333e78c 0x83d719e77deaca1470f6baf62a4d774303c899db69020f9c70ee1dfc08c7ce9e

forge script script/AddLeafX509.s.sol:AddLeaftX509 --rpc-url=$RPC_URL --broadcast --sig "run(bytes)" -vvvv 0x308204a130820309a003020102020900d107765d32a3b096300d06092a864886f70d01010b0500307e310b3009060355040613025553310b300906035504080c0243413114301206035504070c0b53616e746120436c617261311a3018060355040a0c11496e74656c20436f72706f726174696f6e3130302e06035504030c27496e74656c20534758204174746573746174696f6e205265706f7274205369676e696e67204341301e170d3136313132323039333635385a170d3236313132303039333635385a307b310b3009060355040613025553310b300906035504080c0243413114301206035504070c0b53616e746120436c617261311a3018060355040a0c11496e74656c20436f72706f726174696f6e312d302b06035504030c24496e74656c20534758204174746573746174696f6e205265706f7274205369676e696e6730820122300d06092a864886f70d01010105000382010f003082010a0282010100a97a2de0e66ea6147c9ee745ac0162686c7192099afc4b3f040fad6de093511d74e802f510d716038157dcaf84f4104bd3fed7e6b8f99c8817fd1ff5b9b864296c3d81fa8f1b729e02d21d72ffee4ced725efe74bea68fbc4d4244286fcdd4bf64406a439a15bcb4cf67754489c423972b4a80df5c2e7c5bc2dbaf2d42bb7b244f7c95bf92c75d3b33fc5410678a89589d1083da3acc459f2704cd99598c275e7c1878e00757e5bdb4e840226c11c0a17ff79c80b15c1ddb5af21cc2417061fbd2a2da819ed3b72b7efaa3bfebe2805c9b8ac19aa346512d484cfc81941e15f55881cc127e8f7aa12300cd5afb5742fa1d20cb467a5beb1c666cf76a368978b50203010001a381a43081a1301f0603551d2304183016801478437b76a67ebcd0af7e4237eb357c3b8701513c300e0603551d0f0101ff0404030206c0300c0603551d130101ff0402300030600603551d1f045930573055a053a051864f687474703a2f2f7472757374656473657276696365732e696e74656c2e636f6d2f636f6e74656e742f43524c2f5347582f4174746573746174696f6e5265706f72745369676e696e6743412e63726c300d06092a864886f70d01010b050003820181006708b61b5c2bd215473e2b46af99284fbb939d3f3b152c996f1a6af3b329bd220b1d3b610f6bce2e6753bded304db21912f385256216cfcba456bd96940be892f5690c260d1ef84f1606040222e5fe08e5326808212a447cfdd64a46e94bf29f6b4b9a721d25b3c4e2f62f58baed5d77c505248f0f801f9fbfb7fd752080095cee80938b339f6dbb4e165600e20e4a718812d49d9901e310a9b51d66c79909c6996599fae6d76a79ef145d9943bf1d3e35d3b42d1fb9a45cbe8ee334c166eee7d32fcdc9935db8ec8bb1d8eb3779dd8ab92b6e387f0147450f1e381d08581fb83df33b15e000a59be57ea94a3a52dc64bdaec959b3464c91e725bbdaea3d99e857e380a23c9d9fb1ef58e9e42d71f12130f9261d7234d6c37e2b03dba40dfdfb13ac4ad8e13fd3756356b6b50015a3ec9580b815d87c2cef715cd28df00bbf2a3c403ebf6691b3f05edd9143803ca085cff57e053eec2f8fea46ea778a68c9be885bc28225bc5f309be4a2b74d3a03945319dd3c7122fed6ff53bb8b8cb3a03c

cast send 0xDDDeAfB492752FC64220ddB3E7C9f1d5CcCdFdF0 --value 10ether --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --rpc-url=$RPC_URL

forge script script/DeployPuffer.s.sol:DeployPuffer --rpc-url=$RPC_URL --broadcast

Loading