Skip to content

Commit

Permalink
Move off of Compound node provider proxy (#71)
Browse files Browse the repository at this point in the history
Similar change to compound-finance/quark#206
  • Loading branch information
kevincheng96 authored Sep 6, 2024
1 parent d646473 commit 3cdea8b
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gas-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
| grep -E '^test' \
| tee .gas-snapshot.new
env:
NODE_PROVIDER_BYPASS_KEY: ${{ secrets.NODE_PROVIDER_BYPASS_KEY }}
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}

- name: Check diff tolerance
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
forge test -vvv
id: test
env:
NODE_PROVIDER_BYPASS_KEY: ${{ secrets.NODE_PROVIDER_BYPASS_KEY }}
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }}
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,18 @@ Callbacks need to be explicitly turned on by Quark scripts. Specifically, this i

[Quark Builder Helper](./src/builder/QuarkBuilderHelper.sol) is a contract with functions outside of constructing _Quark operations_ that might still be helpful for those using the QuarkBuilder. For example, there is a helper function to determine the bridgeability of assets on different chains.

## Fork tests and NODE_PROVIDER_BYPASS_KEY
## Fork tests and MAINNET_RPC_URL

Some tests require forking mainnet, e.g. to exercise use-cases like
supplying and borrowing in a comet market.

For a "fork url" we use our rate-limited node provider endpoint at
`https://node-provider.compound.finance/ethereum-mainnet`. Setting up a
fork quickly exceeds the rate limits, so we use a bypass key to allow fork
tests to exceed the rate limits.
The "fork url" is specified using the environment variable `MAINNET_RPC_URL`.
It can be any node provider for Ethereum mainnet, such as Infura or Alchemy.

A bypass key for Quark development can be found in 1Password as a
credential named "Quark Dev node-provider Bypass Key". The key can then be
set during tests via the environment variable `NODE_PROVIDER_BYPASS_KEY`,
like so:
The environment variable can be set when running tests, like so:

```
$ NODE_PROVIDER_BYPASS_KEY=... forge test
$ MAINNET_RPC_URL=... forge test
```

## Updating gas snapshots
Expand All @@ -61,7 +56,7 @@ You can accept the diff and update the baseline if the increased gas usage
is intentional. Just run the following command:

```sh
$ NODE_PROVIDER_BYPASS_KEY=... ./script/update-snapshot.sh
$ MAINNET_RPC_URL=... ./script/update-snapshot.sh
```

Then commit the updated snapshot file:
Expand Down
4 changes: 1 addition & 3 deletions test/ApproveAndSwap.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ contract ApproveAndSwapTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
// Warp to the block where the quote is valid
19121945
);
Expand Down
4 changes: 1 addition & 3 deletions test/CCTPBridgeActions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ contract CCTPBridge is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/CometClaimRewards.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ contract CometClaimRewardsTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/CometRepayAndWithdrawMultipleAssets.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ contract CometRepayAndWithdrawMultipleAssetsTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/CometSupplyActions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ contract SupplyActionsTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/CometSupplyMultipleAssetsAndBorrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ contract CometSupplyMultipleAssetsAndBorrowTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/CometWithdrawActions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ contract WithdrawActionsTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/ConditionalMulticall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ contract ConditionalMulticallTest is Test {

function setUp() public {
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/Ethcall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ contract EthcallTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);

Expand Down
4 changes: 1 addition & 3 deletions test/Multicall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ contract MulticallTest is Test {

function setUp() public {
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/Paycall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ contract PaycallTest is Test {

function setUp() public {
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/Quotecall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ contract QuotecallTest is Test {

function setUp() public {
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/RecurringSwap.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ contract RecurringSwapTest is Test {
constructor() {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);

Expand Down
4 changes: 1 addition & 3 deletions test/TransferActions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ contract TransferActionsTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/UniswapFlashLoan.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ contract UniswapFlashLoanTest is Test {

function setUp() public {
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/UniswapFlashSwapExactOut.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ contract UniswapFlashSwapExactOutTest is Test {

function setUp() public {
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/UniswapSwapActions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ contract UniswapSwapActionsTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down
4 changes: 1 addition & 3 deletions test/WrapperScripts.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ contract WrapperScriptsTest is Test {
function setUp() public {
// Fork setup
vm.createSelectFork(
string.concat(
"https://node-provider.compound.finance/ethereum-mainnet/", vm.envString("NODE_PROVIDER_BYPASS_KEY")
),
vm.envString("MAINNET_RPC_URL"),
18429607 // 2023-10-25 13:24:00 PST
);
factory = new QuarkWalletProxyFactory(address(new QuarkWallet(new CodeJar(), new QuarkStateManager())));
Expand Down

0 comments on commit 3cdea8b

Please sign in to comment.