Skip to content

Commit

Permalink
Move off of Compound node provider proxy (#206)
Browse files Browse the repository at this point in the history
Instead of hardcoding the fork url to be the Compound node provider
proxy, we introduce a new `MAINNET_RPC_URL` env variable to allow the
developer to set their own node provider.
  • Loading branch information
kevincheng96 authored Sep 6, 2024
1 parent e36c8cc commit da0cfcd
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 40 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 @@ -38,4 +38,4 @@ jobs:
forge test --via-ir
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 @@ -153,23 +153,18 @@ In the root-level `remappings.txt` file, these remappings look ordinary, like `q

Whenever a new remapping is added to `remappings.txt`, a corresponding entry must be added to `remappings-relative.txt` that prefixes the remapping path with `..` to maintain sub-project compiles; this is covered with an example in the [Dependencies](#dependencies) section.

## 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 @@ -182,7 +177,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/ReplayableTransactions.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ contract ReplayableTransactionsTest 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/quark-core-scripts/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/quark-core-scripts/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/quark-core-scripts/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/quark-core-scripts/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/quark-core-scripts/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/quark-core-scripts/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/quark-core-scripts/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/quark-core/isValidSignature.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ contract isValidSignatureTest 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

0 comments on commit da0cfcd

Please sign in to comment.