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

test: vaults fuzzing #918

Closed
wants to merge 76 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
483b442
feat: initial deploy to local devnet
eddort Dec 11, 2024
e5aa190
feat: speed up scratch deployment for local-devnet
eddort Dec 11, 2024
ee55926
refactor: add deployed-local-devnet.json to gitignore
eddort Dec 11, 2024
ce8c268
chore: add default pk for local devnet
tamtamchik Dec 12, 2024
2983d01
feat: decrease voting time for devnet
eddort Dec 17, 2024
e879318
fix: consensusVersion in VEBO defaults
eddort Dec 19, 2024
ce1e448
feat: update default params for devnet
eddort Dec 19, 2024
e622b3b
feat: custom SLOTS_PER_EPOCH support
eddort Dec 22, 2024
6c8bab8
fix: change the module type on curated-onchain-v1 for SimpleDVT in th…
Amuhar Dec 24, 2024
cf98121
fix: vebo access control and deploy tests
Amuhar Jan 9, 2025
517076e
feat: vebo gas, submitReportData, happyPath tests
Amuhar Jan 10, 2025
8fa4443
fix: submitReportData method tests
Amuhar Jan 10, 2025
afc5fa1
feat: test shareRate with fuzzing
sergeyWh1te Jan 10, 2025
e772d2a
Merge branch 'feat/vaults' into feat/vaults-fuzzing-share-rate
tamtamchik Jan 13, 2025
0b6fc5c
feat: test shareRate with fuzzing
sergeyWh1te Jan 13, 2025
6317957
feat: test shareRate with fuzzing
sergeyWh1te Jan 13, 2025
c289fb8
chore: some refactoring
tamtamchik Jan 13, 2025
d79df96
feat: test shareRate with fuzzing
sergeyWh1te Jan 14, 2025
3ac9843
Merge remote-tracking branch 'origin/develop' into feat/val-1556-move…
Amuhar Jan 15, 2025
167c387
feat: fuzz oracleReport
sergeyWh1te Jan 16, 2025
2386b48
chore: add oracle report related contracts
tamtamchik Jan 16, 2025
79ecbbb
fix: accounting initialization
tamtamchik Jan 16, 2025
7fc5b7f
feat: added _sharesRequestedToBurn to fuzzing
sergeyWh1te Jan 16, 2025
c9f78d0
feat: added _sharesRequestedToBurn to fuzzing
sergeyWh1te Jan 16, 2025
166ef4b
feat: refactor fuzz.ProtocolDeployment
sergeyWh1te Jan 17, 2025
c39aeea
feat: fix incorrect timestamp for Report
sergeyWh1te Jan 17, 2025
7d05ee2
chore: add todos
tamtamchik Jan 20, 2025
2571fe1
build(deps): bump undici from 5.28.4 to 5.28.5
dependabot[bot] Jan 22, 2025
1203e29
feat: wip fuzz handleOracleReport
sergeyWh1te Jan 22, 2025
ec51299
Merge pull request #928 from lidofinance/dependabot/npm_and_yarn/undi…
tamtamchik Jan 22, 2025
6ae1888
feat: fuzz clValidators after report
sergeyWh1te Jan 23, 2025
ea08979
feat: try to get elRewards
sergeyWh1te Jan 23, 2025
f7870a8
feat: invariant_handleOracleReport
sergeyWh1te Jan 29, 2025
2c5f189
Merge commit '2d11786ebc1f06165c501fa8e9fecef053e12ab9' into feat/loc…
mkurayan Jan 30, 2025
02ac654
feat: invariant_handleOracleReport
sergeyWh1te Jan 30, 2025
490652e
feat: check invariant lido.transfer
sergeyWh1te Jan 31, 2025
8b88a72
feat: check invariant_vaultsDonAffectSharesRate
sergeyWh1te Feb 4, 2025
2488ef7
feat: add block explorer verify params to hh config
eddort Feb 9, 2025
be1e2d8
Merge branch 'feat/local-devnet' of github.com:lidofinance/core into …
eddort Feb 9, 2025
e309222
test: fix new operators discrepancy
tamtamchik Feb 10, 2025
d4bcbf3
feat: move common tests setup to provision part
tamtamchik Feb 10, 2025
eef9523
feat: simplify provisioning
tamtamchik Feb 10, 2025
46e4593
fix: tests
tamtamchik Feb 10, 2025
f492007
feat: add mainnet integration tests to schedule
tamtamchik Feb 10, 2025
7dd0aa4
chore: update CODEOWNERS
tamtamchik Feb 10, 2025
7f6f404
Merge remote-tracking branch 'origin/feat/vaults' into feat/vaults-fu…
tamtamchik Feb 10, 2025
e9a302d
feat: stabilize tests
tamtamchik Feb 10, 2025
9e4e49e
Merge pull request #941 from lidofinance/feat/fix-mainnet-integration
tamtamchik Feb 11, 2025
667791a
fix: negative rebase
tamtamchik Feb 11, 2025
106c9c2
Merge pull request #943 from lidofinance/fix/develop
tamtamchik Feb 11, 2025
9a5a20a
Merge pull request #942 from lidofinance/develop
tamtamchik Feb 11, 2025
a4bd6b8
feat: hardhat based logs
tamtamchik Feb 11, 2025
3155741
chore: cleanup logs
tamtamchik Feb 11, 2025
d4a71e2
chore: refactor
tamtamchik Feb 12, 2025
986cfde
chore: migrate foundry to stable
tamtamchik Feb 14, 2025
b0c3352
Merge pull request #946 from lidofinance/fix/foundry
tamtamchik Feb 14, 2025
2f28a18
Merge pull request #944 from lidofinance/feat/auto-trace
tamtamchik Feb 14, 2025
a8734c3
Merge branch 'develop' into feat/val-1556-move-vebo-legacy-tests
tamtamchik Feb 14, 2025
087b03e
fix(test): vebo gas test
tamtamchik Feb 14, 2025
014df01
test: speed up gas validation test
tamtamchik Feb 14, 2025
1ef6b88
Merge pull request #917 from lidofinance/feat/val-1556-move-vebo-lega…
tamtamchik Feb 14, 2025
8ffcf2b
fix: hardhat config types
eddort Feb 17, 2025
72a4628
Revert "feat: speed up scratch deployment for local-devnet"
eddort Feb 17, 2025
965cd4c
Merge branch 'develop' of github.com:lidofinance/core into feat/local…
eddort Feb 17, 2025
6e7c60e
fix: integration tests
eddort Feb 17, 2025
d1fc7ec
fix: IDepositContract format
eddort Feb 17, 2025
f22a7a9
refactor: reset defaults
eddort Feb 17, 2025
f4d128f
refactor: env vars
eddort Feb 18, 2025
9492d8f
refactor: env example
eddort Feb 18, 2025
5e7e304
fix: initialize WithdrawalVault
eddort Feb 18, 2025
b403164
fix: hh etherscan config
eddort Feb 18, 2025
6089070
fix: wv initialize
eddort Feb 18, 2025
25b4eda
Merge pull request #896 from lidofinance/feat/local-devnet
tamtamchik Feb 18, 2025
bec2685
feat: merge develop into fuzzShareRate
sergeyWh1te Feb 19, 2025
144188f
feat: merge develop into fuzzShareRate
sergeyWh1te Feb 19, 2025
9177a9e
feat: merge develop into fuzzShareRate
sergeyWh1te Feb 19, 2025
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
8 changes: 2 additions & 6 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# CODEOWNERS: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

# Any PR to `master` branch with changes to production contracts notifies the protocol team
/contracts/ @lidofinance/lido-eth-protocol

# Any PR to `master` branch with changes to GitHub workflows notifies the workflow review team
/.github/workflows/ @lidofinance/review-gh-workflows
* @lidofinance/lido-eth-protocol
.github @lidofinance/review-gh-workflows
62 changes: 33 additions & 29 deletions .github/workflows/tests-integration-mainnet.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
name: Integration Tests
#on: [push]
#
#jobs:
# test_hardhat_integration_fork:
# name: Hardhat / Mainnet
# runs-on: ubuntu-latest
# timeout-minutes: 120
#
# services:
# hardhat-node:
# image: ghcr.io/lidofinance/hardhat-node:2.22.18
# ports:
# - 8545:8545
# env:
# ETH_RPC_URL: "${{ secrets.ETH_RPC_URL }}"
#
# steps:
# - uses: actions/checkout@v4
#
# - name: Common setup
# uses: ./.github/workflows/setup
#
# - name: Set env
# run: cp .env.example .env
#
# - name: Run integration tests
# run: yarn test:integration:fork:mainnet
# env:
# LOG_LEVEL: debug

on:
push:
schedule:
- cron: "0 10 */2 * *"

jobs:
test_hardhat_integration_fork:
name: Hardhat / Mainnet
runs-on: ubuntu-latest
timeout-minutes: 120

services:
hardhat-node:
image: ghcr.io/lidofinance/hardhat-node:2.22.17
ports:
- 8545:8545
env:
ETH_RPC_URL: "${{ secrets.ETH_RPC_URL }}"

steps:
- uses: actions/checkout@v4

- name: Common setup
uses: ./.github/workflows/setup

- name: Set env
run: cp .env.example .env

- name: Run integration tests
run: yarn test:integration:fork:mainnet
env:
LOG_LEVEL: debug
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ lib/abi/*.json
accounts.json
deployed-local.json
deployed-hardhat.json
deployed-local-devnet.json

# MacOS
.DS_Store
2 changes: 1 addition & 1 deletion deployed-holesky.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
"app:simple-dvt": {
"stakingRouterModuleParams": {
"moduleName": "SimpleDVT",
"moduleType": "simple-dvt-onchain-v1",
"moduleType": "curated-onchain-v1",
"targetShare": 50,
"moduleFee": 800,
"treasuryFee": 200,
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test = 'test'
cache = true

# The cache directory if enabled
cache_path = 'foundry/cache'
cache_path = 'foundry/cache'

# Only run tests in contracts matching the specified glob pattern
match_path = '**/test/**/*.t.sol'
Expand Down
16 changes: 5 additions & 11 deletions globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ declare namespace NodeJS {
LOCAL_KERNEL_ADDRESS?: string;
LOCAL_LEGACY_ORACLE_ADDRESS?: string;
LOCAL_LIDO_ADDRESS?: string;
LOCAL_WSTETH_ADDRESS?: string;
LOCAL_NOR_ADDRESS?: string;
LOCAL_ORACLE_DAEMON_CONFIG_ADDRESS?: string;
LOCAL_ORACLE_REPORT_SANITY_CHECKER_ADDRESS?: string;
Expand All @@ -48,7 +47,6 @@ declare namespace NodeJS {
LOCAL_VALIDATORS_EXIT_BUS_ORACLE_ADDRESS?: string;
LOCAL_WITHDRAWAL_QUEUE_ADDRESS?: string;
LOCAL_WITHDRAWAL_VAULT_ADDRESS?: string;
LOCAL_STAKING_VAULT_FACTORY_ADDRESS?: string;

/* for mainnet fork testing */
MAINNET_RPC_URL: string;
Expand All @@ -65,7 +63,6 @@ declare namespace NodeJS {
MAINNET_KERNEL_ADDRESS?: string;
MAINNET_LEGACY_ORACLE_ADDRESS?: string;
MAINNET_LIDO_ADDRESS?: string;
MAINNET_WSTETH_ADDRESS?: string;
MAINNET_NOR_ADDRESS?: string;
MAINNET_ORACLE_DAEMON_CONFIG_ADDRESS?: string;
MAINNET_ORACLE_REPORT_SANITY_CHECKER_ADDRESS?: string;
Expand All @@ -74,17 +71,14 @@ declare namespace NodeJS {
MAINNET_VALIDATORS_EXIT_BUS_ORACLE_ADDRESS?: string;
MAINNET_WITHDRAWAL_QUEUE_ADDRESS?: string;
MAINNET_WITHDRAWAL_VAULT_ADDRESS?: string;
MAINNET_STAKING_VAULT_FACTORY_ADDRESS?: string;

HOLESKY_RPC_URL?: string;
SEPOLIA_RPC_URL?: string;
MEKONG_RPC_URL?: string;

/* for contract sourcecode verification with `hardhat-verify` */
ETHERSCAN_API_KEY?: string;
BLOCKSCOUT_API_KEY?: string;

/* Scratch deploy environment variables */
NETWORK_STATE_FILE?: string;
/* for local devnet */
LOCAL_DEVNET_PK?: string;
LOCAL_DEVNET_CHAIN_ID?: string;
LOCAL_DEVNET_EXPLORER_API_URL?: string;
LOCAL_DEVNET_EXPLORER_URL?: string;
}
}
64 changes: 31 additions & 33 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import "hardhat-tracer";
import "hardhat-watcher";
import "hardhat-ignore-warnings";
import "hardhat-contract-sizer";
import "hardhat-gas-reporter";
import { HardhatUserConfig } from "hardhat/config";

import { mochaRootHooks } from "test/hooks";
Expand All @@ -22,12 +21,22 @@ import { getHardhatForkingConfig, loadAccounts } from "./hardhat.helpers";

const RPC_URL: string = process.env.RPC_URL || "";

export const ZERO_PK = "0x0000000000000000000000000000000000000000000000000000000000000000";

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
gasReporter: {
enabled: process.env.SKIP_GAS_REPORT ? false : true,
},
networks: {
"local": {
url: process.env.LOCAL_RPC_URL || RPC_URL,
},
"local-devnet": {
url: process.env.LOCAL_RPC_URL || RPC_URL,
accounts: [process.env.LOCAL_DEVNET_PK || ZERO_PK],
},
"mainnet-fork": {
url: process.env.MAINNET_RPC_URL || RPC_URL,
timeout: 20 * 60 * 1000, // 20 minutes
},
"hardhat": {
// setting base fee to 0 to avoid extra calculations doesn't work :(
// minimal base fee is 1 for EIP-1559
Expand All @@ -43,30 +52,32 @@ const config: HardhatUserConfig = {
},
forking: getHardhatForkingConfig(),
},
"local": {
url: process.env.LOCAL_RPC_URL || RPC_URL,
},
"holesky": {
url: process.env.HOLESKY_RPC_URL || RPC_URL,
chainId: 17000,
accounts: loadAccounts("holesky"),
},
"sepolia": {
url: process.env.SEPOLIA_RPC_URL || RPC_URL,
url: RPC_URL,
chainId: 11155111,
accounts: loadAccounts("sepolia"),
},
"sepolia-fork": {
url: process.env.SEPOLIA_RPC_URL || RPC_URL,
chainId: 11155111,
},
"mainnet-fork": {
url: process.env.MAINNET_RPC_URL || RPC_URL,
timeout: 20 * 60 * 1000, // 20 minutes
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY || "",
customChains: [
{
network: "local-devnet",
chainId: parseInt(process.env.LOCAL_DEVNET_CHAIN_ID ?? "32382", 10),
urls: {
apiURL: process.env.LOCAL_DEVNET_EXPLORER_API_URL ?? "",
browserURL: process.env.LOCAL_DEVNET_EXPLORER_URL ?? "",
},
},
],
apiKey: process.env.LOCAL_DEVNET_EXPLORER_API_URL
? {
"local-devnet": "local-devnet",
}
: process.env.ETHERSCAN_API_KEY || "",
},
solidity: {
compilers: [
Expand Down Expand Up @@ -120,16 +131,6 @@ const config: HardhatUserConfig = {
evmVersion: "istanbul",
},
},
{
version: "0.8.25",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: "cancun",
},
},
],
},
tracer: {
Expand All @@ -144,10 +145,7 @@ const config: HardhatUserConfig = {
},
watcher: {
test: {
tasks: [
{ command: "compile", params: { quiet: true } },
{ command: "test", params: { noCompile: true, testFiles: ["{path}"] } },
],
tasks: [{ command: "test", params: { testFiles: ["{path}"] } }],
files: ["./test/**/*"],
clearOnStart: true,
start: "echo Running tests...",
Expand All @@ -174,7 +172,7 @@ const config: HardhatUserConfig = {
contractSizer: {
alphaSort: false,
disambiguatePaths: false,
runOnCompile: process.env.SKIP_CONTRACT_SIZE ? false : true,
runOnCompile: true,
strict: true,
except: ["template", "mocks", "@aragon", "openzeppelin", "test"],
},
Expand Down
11 changes: 1 addition & 10 deletions lib/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FactoryOptions } from "hardhat/types";
import { LidoLocator } from "typechain-types";

import { addContractHelperFields, DeployedContract, getContractPath, loadContract, LoadedContract } from "lib/contract";
import { ConvertibleToString, cy, gr, log, yl } from "lib/log";
import { ConvertibleToString, cy, log, yl } from "lib/log";
import { incrementGasUsed, Sk, updateObjectInState } from "lib/state-file";

const GAS_PRIORITY_FEE = process.env.GAS_PRIORITY_FEE || null;
Expand Down Expand Up @@ -36,15 +36,11 @@ export async function makeTx(
log.withArguments(`Call: ${yl(contract.name)}[${cy(contract.address)}].${yl(funcName)}`, args);

const tx = await contract.getFunction(funcName)(...args, txParams);
log(` Transaction: ${tx.hash} (nonce ${yl(tx.nonce)})...`);

const receipt = await tx.wait();
const gasUsed = receipt.gasUsed;
incrementGasUsed(gasUsed, withStateFile);

log(` Executed (gas used: ${yl(gasUsed)})`);
log.emptyLine();

return receipt;
}

Expand Down Expand Up @@ -80,8 +76,6 @@ async function deployContractType2(
throw new Error(`Failed to send the deployment transaction for ${artifactName}`);
}

log(` Transaction: ${tx.hash} (nonce ${yl(tx.nonce)})`);

const receipt = await tx.wait();
if (!receipt) {
throw new Error(`Failed to wait till the transaction ${tx.hash} execution!`);
Expand All @@ -92,9 +86,6 @@ async function deployContractType2(
(contract as DeployedContract).deploymentGasUsed = gasUsed;
(contract as DeployedContract).deploymentTx = tx.hash;

log(` Deployed: ${gr(receipt.contractAddress!)} (gas used: ${yl(gasUsed)})`);
log.emptyLine();

await addContractHelperFields(contract, artifactName);

return contract as DeployedContract;
Expand Down
2 changes: 0 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ export * from "./signing-keys";
export * from "./state-file";
export * from "./string";
export * from "./time";
export * from "./transaction";
export * from "./type";
export * from "./units";
export * from "./deposit";
23 changes: 0 additions & 23 deletions lib/log.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import chalk from "chalk";
import path from "path";

import { TraceableTransaction } from "./type";

// @ts-expect-error TS2339: Property 'toJSON' does not exist on type 'BigInt'.
BigInt.prototype.toJSON = function () {
return this.toString();
Expand Down Expand Up @@ -127,24 +125,3 @@ log.debug = (title: string, records: Record<string, ConvertibleToString>) => {
Object.keys(records).forEach((label) => _record(` ${label}`, records[label]));
log.emptyLine();
};

log.traceTransaction = (name: string, tx: TraceableTransaction) => {
const value = tx.value === "0.0" ? "" : `Value: ${yl(tx.value)} ETH`;
const from = `From: ${yl(tx.from)}`;
const to = `To: ${yl(tx.to)}`;
const gasPrice = `Gas price: ${yl(tx.gasPrice)} gwei`;
const gasLimit = `Gas limit: ${yl(tx.gasLimit)}`;
const gasUsed = `Gas used: ${yl(tx.gasUsed)} (${yl(tx.gasUsedPercent)})`;
const block = `Block: ${yl(tx.blockNumber)}`;
const nonce = `Nonce: ${yl(tx.nonce)}`;

const color = tx.status ? gr : rd;
const status = `${color(name)} ${color(tx.status ? "confirmed" : "failed")}`;

log(`Transaction sent:`, yl(tx.hash));
log(` ${from} ${to} ${value}`);
log(` ${gasPrice} ${gasLimit} ${gasUsed}`);
log(` ${block} ${nonce}`);
log(` ${status}`);
log.emptyLine();
};
Loading
Loading