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: shapella upgrade followups #624

Merged
merged 252 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
252 commits
Select commit Hold shift + click to select a range
69da980
fix tests
bulbozaur Feb 13, 2023
aa465af
chore: fix outdated command
folkyatina Feb 14, 2023
4e3b482
fix: lost `constant` for initial holder
folkyatina Feb 14, 2023
c2eddb9
test: fix lido initialization
folkyatina Feb 14, 2023
fa0c065
test: fix lost awaits
folkyatina Feb 14, 2023
3cf8fc8
chore: fix a warning
folkyatina Feb 14, 2023
7394e11
Bump hardhat version. Integrate foundry
Psirex Feb 14, 2023
b353d08
test: AccountingOracle submit extra data handlers refactor
manneredboor Feb 14, 2023
6b53867
Merge pull request #617 from lidofinance/feature/shapella-upgrade-tes…
manneredboor Feb 14, 2023
5eeadd2
test: rm log
manneredboor Feb 14, 2023
ddbc5df
test: fix lido test for initial holder
folkyatina Feb 14, 2023
8eafde4
test: fix stethpermit tests
folkyatina Feb 14, 2023
5f752a1
test: fix wsteth tests
folkyatina Feb 14, 2023
3867cfd
test: fix staking-router-deposits test
folkyatina Feb 14, 2023
c257dd3
test: fix deposit_distribution test
folkyatina Feb 14, 2023
f12d785
test: fix node-operators-registry test
folkyatina Feb 14, 2023
f12b385
test: fix deposit test
folkyatina Feb 14, 2023
cced043
test: fix lido_deposit_iteration_limit
folkyatina Feb 14, 2023
b985e64
test: fix lido_happy_path
folkyatina Feb 14, 2023
5e0eff2
test: AccountingOracle.submitReportExtraDataList enforces the deadline
manneredboor Feb 14, 2023
5ead926
test: AccountingOracle.submitReportExtraDataList checks extra data hash
manneredboor Feb 14, 2023
74f5404
test: minor fixes for lido test
folkyatina Feb 14, 2023
faae58a
test: AccountingOracle.submitReportExtraDataList check successes by e…
manneredboor Feb 14, 2023
2268b9e
Merge remote-tracking branch 'origin/feature/shapella-upgrade' into f…
folkyatina Feb 14, 2023
39842a4
test: fix nor-penalty test
folkyatina Feb 14, 2023
0e8c1ad
test: fix happy path
folkyatina Feb 14, 2023
28a548c
test: fix withdrawal-queue test
folkyatina Feb 14, 2023
1d61164
test: fix withdrawal-request-nft test
folkyatina Feb 14, 2023
7aa6355
test: AccountingOracle.submitReportExtraDataList checks ref slot
manneredboor Feb 14, 2023
3af9c5b
test: description fix
manneredboor Feb 14, 2023
5f20bb9
test: fix steth test
folkyatina Feb 14, 2023
3db2184
test: AccountingOracle.submitReportExtraDataList delivers the data to…
manneredboor Feb 14, 2023
e841c74
test: AccountingOracle.submitReportExtraDataList updates extra data p…
manneredboor Feb 14, 2023
576e2dd
Remove hardhat-foundry due to incompatibility with solidity-coverage
Psirex Feb 15, 2023
8e529e7
Update test:gas command network argument
Psirex Feb 15, 2023
be71608
test: fix lido handleOracleReport test
folkyatina Feb 15, 2023
35dd327
test: fix burner tests
folkyatina Feb 15, 2023
f0c43c1
accounting oracle: fix docs, define consensus rules for empty extra data
skozin Feb 15, 2023
b0553c0
exit bus oracle: fix docs
skozin Feb 15, 2023
54627a5
accounting oracle: fix a forgotten test
skozin Feb 15, 2023
40ace2e
accounting oracle: fix the code added in f0c43c1d
skozin Feb 15, 2023
9c951ee
test: AccountingOracle.submitReportExtraDataList enforces data safety…
manneredboor Feb 15, 2023
c4f4b07
test: AccountingOracle.submitReportExtraDataList enforces data safety…
manneredboor Feb 15, 2023
f1a8842
test: fix lido penalties and slashing test
folkyatina Feb 15, 2023
97c132a
chore: remove forgotten .only
folkyatina Feb 15, 2023
c1b8e58
test: AccountingOracle.submitReportExtraDataList enforces data safety…
manneredboor Feb 15, 2023
3e2fbd1
test: AccountingOracle.submitReportExtraDataList should cueck node op…
manneredboor Feb 15, 2023
0023e4b
ValidatorExitBusOracle: add pauser and resumer to initialize()
arwer13 Feb 15, 2023
542f849
feat: pub getter for the eip712 steth helper
TheDZhon Feb 15, 2023
53c84b8
test: `MAX_NODE_OPERATORS_COUNT` reward distr gas
TheDZhon Feb 15, 2023
2c083fc
Add Foundry tests for MinFirstAllocationStrategy
Psirex Feb 15, 2023
0050dea
feat: static totals storage
krogla Feb 16, 2023
b1a0556
Merge remote-tracking branch 'origin/feature/nor-optimize' into featu…
TheDZhon Feb 16, 2023
f28fe08
Merge branch 'test/node-operators-limit' into feature/shapella-upgrad…
TheDZhon Feb 16, 2023
a1c8162
Merge remote-tracking branch 'origin/feath/eip712-helper-getter' into…
TheDZhon Feb 16, 2023
f025fd8
Merge remote-tracking branch 'origin/feature/shapella-upgrade-tests-a…
TheDZhon Feb 16, 2023
3303451
Move all MemUtils tests to Foundry
Psirex Feb 16, 2023
868c2c6
test: AccountingOracle.submitReportExtraDataList checks items count
manneredboor Feb 16, 2023
06b24ae
Merge remote-tracking branch 'origin/feature/nonzero_shares_and_tvl' …
TheDZhon Feb 16, 2023
2765404
test: AccountingOracle initial values zero-checking
manneredboor Feb 16, 2023
af7d39c
feat: add more submitReportExtraDataList tests
Jeday Feb 16, 2023
b768886
feat: add extraDataFormat tests for submitReport
Jeday Feb 16, 2023
d2a6f2c
Merge branches 'feature/shapella-upgrade-tests-accounting-oracle' and…
Jeday Feb 16, 2023
39c4fe1
fix: switch reverts position in AccountOracle._submitReportExtraDataList
manneredboor Feb 16, 2023
8f14b14
fix: replace check for maxNodeOperatorsPerItem to assert in Accountin…
manneredboor Feb 16, 2023
3990e55
test: AccountingOracle.submitReportExtraDataList enforces data format
manneredboor Feb 16, 2023
c7c46c3
test: fix doubled constant
manneredboor Feb 16, 2023
3c14ab0
feat: add extra check for extraData format
Jeday Feb 16, 2023
25153b9
feat: test for zeroHash non empty data
Jeday Feb 16, 2023
2b10209
chore: abi
Jeday Feb 16, 2023
c78a426
Merge branch 'feature/shapella-upgrade-tests-accounting-oracle' of gi…
Jeday Feb 16, 2023
08980f0
fix: missing export
Jeday Feb 16, 2023
86e51c3
PausableUntil: add tests and getResumeSinceTimestamp() view
arwer13 Feb 16, 2023
8b8a97f
fix: typos in comments
arwer13 Feb 16, 2023
833de28
Merge remote-tracking branch 'origin/pausable-to-exit-bus-init' into …
TheDZhon Feb 16, 2023
1351b16
fix: move updates from SR to NOR
krogla Feb 16, 2023
82862dd
test: more initil tests for AccountingOracle
manneredboor Feb 16, 2023
934e0fd
refactor: rename a few shortened names
arwer13 Feb 16, 2023
4aaaad7
Merge pull request #625 from lidofinance/refactor-shortened-names
TheDZhon Feb 16, 2023
f89e443
Calculate deposits count in Lido contract
Psirex Feb 17, 2023
f2d2b2f
Merge branch 'feature/shapella-upgrade-followups' into fix/deposit-flow
Psirex Feb 17, 2023
ae1f643
Fix some failed tests
Psirex Feb 17, 2023
a5a6623
Remove unaccounted eth check from deposit
Psirex Feb 17, 2023
644fadb
Remove stakingModuleId check from Lido
Psirex Feb 17, 2023
716651e
Update naming and comments in the StakingRouter
Psirex Feb 17, 2023
eacf204
feat: view to get claimable ether for request
folkyatina Feb 17, 2023
5e35d35
🏗️: WithdrawalRequestNFT -> WithdrawalQueueERC721
folkyatina Feb 17, 2023
1278fb5
feat: add WarnExtraDataIncompleteProcessing event test
Jeday Feb 17, 2023
75db579
refactor: update stuck/exited counts
krogla Feb 17, 2023
cc3761a
fix and multiple improvements to OracleReportSanityChecker
arwer13 Feb 17, 2023
d88250c
refactor: remove Math64 lib
krogla Feb 17, 2023
8a55b07
feat: add trailing byte tests
Jeday Feb 17, 2023
7a7c9eb
feat: test for successful legacy oracle migration
Jeday Feb 17, 2023
8073c3d
fix: transfer to themselves
folkyatina Feb 17, 2023
4b566e7
fix: limit recalc, tests
krogla Feb 17, 2023
10ac6cb
fix: add OracleDaemonConfig to LidoLocator
TheDZhon Feb 17, 2023
77fcbae
fix: balanceOf decreasing on claim
folkyatina Feb 17, 2023
8932c10
💅: remove payable address from WithdrawalRequest
folkyatina Feb 17, 2023
cb9049a
fix: optimize binary search by excluding last element
folkyatina Feb 17, 2023
fa03bfc
fix: remove unnecessary variable
folkyatina Feb 17, 2023
8aa6a71
fix: move pause on initialize to PausableUntil
folkyatina Feb 17, 2023
271f9c7
fix: right arg for InitializedV1
folkyatina Feb 17, 2023
97f1120
fix: remove unused errors
folkyatina Feb 17, 2023
6da696c
chore: comments about initial token holder
TheDZhon Feb 18, 2023
09f8735
Merge pull request #608 from lidofinance/feature/nonzero_shares_and_tvl
TheDZhon Feb 18, 2023
9ecf5f4
doc: mention foundry in README
TheDZhon Feb 18, 2023
3d25bff
chore: remove extra space
TheDZhon Feb 18, 2023
2b5b9a9
Merge pull request #619 from lidofinance/feature/foundry
TheDZhon Feb 18, 2023
fabb410
Merge remote-tracking branch 'origin/feature/shapella-upgrade-followu…
TheDZhon Feb 18, 2023
c5be3cf
Merge pull request #628 from lidofinance/refactor/nft_renaming
TheDZhon Feb 18, 2023
01c6038
chore: format one-liners, tighten BP limits
TheDZhon Feb 18, 2023
69f1744
chore: _checkLimitValue > instead of >=
TheDZhon Feb 18, 2023
eda9868
Merge pull request #629 from lidofinance/sanity-max-per-item-count
TheDZhon Feb 18, 2023
74238d4
Merge remote-tracking branch 'origin/feature/nor-optimize' into featu…
TheDZhon Feb 18, 2023
113fb29
oracles: fix: prevent re-submitting data for the same ref. slot again
skozin Feb 18, 2023
e769b9c
oracles: remove incorrect test (fix copy-paste)
skozin Feb 18, 2023
3201eb8
accounting oracle (code style): fix code layout
skozin Feb 18, 2023
fece521
tests: remove unused var
skozin Feb 18, 2023
21aaf33
test: revive some oracle tests
TheDZhon Feb 18, 2023
ac31d94
Merge branch 'feature/shapella-upgrade-followups' into fix/oracle-dae…
TheDZhon Feb 18, 2023
c0437d4
fix: update locator test stubs/structs
TheDZhon Feb 18, 2023
86987eb
chore: hashconsensus acl tests using evmsnapshot
TheDZhon Feb 18, 2023
5b2c9d8
test: +reportComponents of LidoLocator
TheDZhon Feb 18, 2023
9867298
Merge pull request #630 from lidofinance/fix/oracle-daemon-config-loc…
TheDZhon Feb 18, 2023
b18a1e7
doc: handleOracleReport with eth_call JSON-RPC API
TheDZhon Feb 18, 2023
ce3bdab
fix: replace _initializePausable() with _pause
folkyatina Feb 18, 2023
c621c91
🏗️: skip grantRole if zero address
folkyatina Feb 18, 2023
bdb8f78
fix: add assert to EnumerableSet remove
folkyatina Feb 18, 2023
d6c03f6
Merge remote-tracking branch 'origin/feature/shapella-upgrade-followu…
folkyatina Feb 18, 2023
36693c1
🏗️: skip _grantRole for zero addresses
folkyatina Feb 18, 2023
91a9ffe
fix: add asserts to EnumerableSet operations
folkyatina Feb 18, 2023
4052ece
Merge pull request #632 from lidofinance/fix/audit_info_issues
TheDZhon Feb 19, 2023
988bafe
Merge remote-tracking branch 'origin/feature/shapella-upgrade-followu…
TheDZhon Feb 19, 2023
c118b21
Merge pull request #633 from lidofinance/fix/transfer_to_themselves
TheDZhon Feb 19, 2023
8c16b5d
doc: provide an explainer about burn limits
TheDZhon Feb 19, 2023
616f434
chore: revertsWithCustomError for hashconsensus
TheDZhon Feb 19, 2023
f016373
refactor: simulated share rate naming everywhere
TheDZhon Feb 19, 2023
f11eb9a
chore: DONT_FINALIZE_WITHDRAWALS comment
TheDZhon Feb 19, 2023
55c2b09
chore: improve doc for 'checkSimulatedShareRate'
TheDZhon Feb 19, 2023
14503a5
Minor deposit methods changes
Psirex Feb 19, 2023
5333cfe
Add GenericStub test contract
Psirex Feb 19, 2023
6be4dbb
Add tests for different Lido deposit scenarios
Psirex Feb 19, 2023
c1e56e4
Merge branch 'feature/shapella-upgrade-followups' into fix/deposit-flow
Psirex Feb 19, 2023
f2adad1
Update ABIs
Psirex Feb 19, 2023
768fa19
test: validatorsExitBus oracle: deploy: fix code style
DiRaiks Feb 19, 2023
bc81d74
test: validatorsExitBus oracle: acces control: add access control tests
DiRaiks Feb 19, 2023
3c6616e
exit bus oracle: fix docs
skozin Feb 19, 2023
f98d514
exit bus oracle: require node operators' validator indices to increase
skozin Feb 19, 2023
49888bf
Merge branch 'feature/shapella-upgrade-followups' into feature/shapel…
TheDZhon Feb 19, 2023
3e2803f
Merge pull request #618 from lidofinance/feature/shapella-upgrade-tes…
TheDZhon Feb 19, 2023
cdb94dd
Implement events emitting configuration for GenericStub
Psirex Feb 19, 2023
354f081
update wei to use wei.int and wei.str as JS tags
Psirex Feb 19, 2023
e2462c7
Remove dead code and rename props in GenericStub
Psirex Feb 19, 2023
23fbc1b
fix bytes
loga4 Feb 20, 2023
320e6aa
chore: format submit report data test
Jeday Feb 20, 2023
59c3649
Merge remote-tracking branch 'origin/feature/shapella-upgrade-followu…
folkyatina Feb 20, 2023
2568bdd
Merge remote-tracking branch 'origin/feature/shapella-upgrade-followu…
TheDZhon Feb 20, 2023
0fc22a8
fix: initialization fixes to match the upstream
TheDZhon Feb 20, 2023
81e862e
Merge pull request #637 from lidofinance/feature/shapella-upgrade-tes…
TheDZhon Feb 20, 2023
b57fbb2
test: validatorsExitBus oracle: access control: minor fix
DiRaiks Feb 20, 2023
a7c7bfb
Merge branch 'feature/nor-optimize' into feature/shapella-upgrade-fol…
TheDZhon Feb 20, 2023
22f0430
test: ValidatorsExitBusOracle._handleConsensusReportData enforces dat…
manneredboor Feb 20, 2023
c5d3a4f
update handle report test
bulbozaur Feb 20, 2023
d213e0e
test: ValidatorsExitBusOracle._handleConsensusReportData enforces dat…
manneredboor Feb 20, 2023
8872c37
test: ValidatorsExitBusOracle._handleConsensusReportData invokes sani…
manneredboor Feb 20, 2023
c44e0f7
feat: parent contract internal checks test
Jeday Feb 20, 2023
4e69de7
chore: abi
Jeday Feb 20, 2023
fdbc5c1
Merge pull request #636 from lidofinance/fix/preliminary-audit-fixes
TheDZhon Feb 20, 2023
d1477f8
Merge branch 'feature/shapella-upgrade-tests-validators-exit-bus-orac…
Jeday Feb 20, 2023
6c129c6
feat: getTotalRequestsProcessed tests
Jeday Feb 20, 2023
bd17933
test: ValidatorsExitBusOracle._handleConsensusReportData validates re…
manneredboor Feb 20, 2023
67ea946
feat: improve WithdrawalQueue interface
folkyatina Feb 20, 2023
2e9d69c
test: ValidatorsExitBusOracle._handleConsensusReportData updates proc…
manneredboor Feb 20, 2023
8a42e43
feat: getProcessingState tests
Jeday Feb 20, 2023
19cf415
Merge branch 'feature/shapella-upgrade-tests-validators-exit-bus-orac…
Jeday Feb 20, 2023
aeca08c
feat: use embedded EIP712 for StETH
TheDZhon Feb 20, 2023
7690377
test: ValidatorsExitBusOracle._handleConsensusReportData updates tota…
manneredboor Feb 20, 2023
af306e7
Merge pull request #639 from lidofinance/feature/report-tests
TheDZhon Feb 20, 2023
58e1601
fix: proper checks on claim and claimable ether
folkyatina Feb 20, 2023
d1f172e
chore: abi
folkyatina Feb 20, 2023
a991347
test: fix wq test
folkyatina Feb 20, 2023
c63fcbb
test: -obsolete `lidoHandleOracleReport.test.js`
TheDZhon Feb 20, 2023
eb19d96
test: ValidatorsExitBusOracle._handleConsensusReportData checks that …
manneredboor Feb 20, 2023
61e1ce3
add check address
loga4 Feb 20, 2023
90b526f
test: ValidatorsExitBusOracle._handleConsensusReportData emits Valida…
manneredboor Feb 20, 2023
41d2413
test: remove unrelevant testcase
manneredboor Feb 20, 2023
dc90118
feat: pause tests and clean up
Jeday Feb 20, 2023
b90b6f9
chore: abi
Jeday Feb 20, 2023
2d67863
Merge branch 'feature/shapella-upgrade-tests-validators-exit-bus-orac…
Jeday Feb 20, 2023
be5fbd7
💅: tidy up interfaces
folkyatina Feb 20, 2023
044951f
Merge branch 'feature/shapella-upgrade-followups' of github.com:lidof…
Jeday Feb 20, 2023
4472dfb
fix: snapshot variable not defined
Jeday Feb 20, 2023
dd5c631
Merge pull request #640 from lidofinance/fix/embedded-eip712
TheDZhon Feb 20, 2023
1a02980
Merge pull request #641 from lidofinance/feature/shapella-upgrade-che…
TheDZhon Feb 20, 2023
6d05f56
Merge remote-tracking branch 'origin/feature/shapella-upgrade-followu…
TheDZhon Feb 20, 2023
62572d2
Merge pull request #626 from lidofinance/fix/deposit-flow
TheDZhon Feb 20, 2023
694c669
Merge pull request #638 from lidofinance/feature/shapella-upgrade-tes…
TheDZhon Feb 20, 2023
79abc23
test: fix eip712 deploy factory
TheDZhon Feb 20, 2023
0228972
Merge pull request #627 from lidofinance/feature/wq_finalized_ether
TheDZhon Feb 20, 2023
9663a94
refactor: IEIP712 -> IEIP712StETH
TheDZhon Feb 20, 2023
e260aba
Merge branch 'feature/shapella-upgrade-followups' into feature/some-a…
folkyatina Feb 20, 2023
e2aae6b
Merge pull request #616 from lidofinance/feature/some-awaits
folkyatina Feb 20, 2023
1a361d1
fix rewards distribution tests
bulbozaur Feb 20, 2023
191aa59
Merge pull request #643 from lidofinance/feature/rewards-distribution…
TheDZhon Feb 20, 2023
991ab15
refactor: sig keys lib
krogla Feb 20, 2023
6f3f333
fix: nor test mock
krogla Feb 20, 2023
ccecef2
refactor: remove comments
krogla Feb 20, 2023
e07c122
test: fix hash consensus test initialization
folkyatina Feb 20, 2023
f291dd2
Add early return to NOR obtainDepositData()
Psirex Feb 20, 2023
aa30cea
💅: docs
folkyatina Feb 20, 2023
6cb8edc
feat: +eip712Domain for StETHPermit
TheDZhon Feb 20, 2023
419ce82
refactor: fixes, comments
krogla Feb 21, 2023
9e333af
refactor: tests, events
krogla Feb 21, 2023
ccca7f3
Merge branch 'feature/nor-optimize' into tmp
krogla Feb 21, 2023
43b9cb8
feat: signing keys lib refactor
krogla Feb 21, 2023
ef4d114
test: fix
krogla Feb 21, 2023
14a0cf0
fix: summary deposited counter
krogla Feb 21, 2023
68585ff
fix: tests, update summary method rename
krogla Feb 21, 2023
987e35c
💅: wq fomatting
folkyatina Feb 21, 2023
44154d7
chore: comments
krogla Feb 21, 2023
8400167
Merge pull request #645 from lidofinance/feature/nor-sigkeyslib
TheDZhon Feb 21, 2023
a60d007
fix: nor test mock
krogla Feb 20, 2023
87ceae0
refactor: remove comments
krogla Feb 20, 2023
16b2269
refactor: fixes, comments
krogla Feb 21, 2023
0674111
refactor: tests, events
krogla Feb 21, 2023
a82063a
fix: summary deposited counter
krogla Feb 21, 2023
c85c106
fix: tests, update summary method rename
krogla Feb 21, 2023
9afe1b2
chore: comments
krogla Feb 21, 2023
539a0fa
refactor: sig keys lib
krogla Feb 20, 2023
4a0261c
feat: signing keys lib refactor
krogla Feb 21, 2023
87ada8e
test: fix
krogla Feb 21, 2023
05899df
test: fixes
krogla Feb 21, 2023
9cb4e83
Merge branch 'feature/nor-optimize' of github.com:lidofinance/lido-da…
krogla Feb 21, 2023
4c776cc
chore: abi upd
krogla Feb 21, 2023
adb09e9
Merge pull request #623 from lidofinance/feature/nor-optimize
TheDZhon Feb 21, 2023
17d3526
staking router: fix struct name and docs layout
skozin Feb 20, 2023
5795960
staking module interface: improve fn naming consistency
skozin Feb 20, 2023
a82916e
staking router, acct oracle: fix rewards distribution for modules wit…
skozin Feb 20, 2023
f979709
tests: fix an assertion message
skozin Feb 20, 2023
85c6a6b
test: update rewards related scenario tests
bulbozaur Feb 21, 2023
ee0af12
staking router: fix: check the reported exited/stuck validators data
skozin Feb 21, 2023
88b7cfa
staking router: add basic tests for exited/stuck validators reporting
skozin Feb 21, 2023
f0eb9f8
Merge pull request #644 from lidofinance/fix/module-rewards-distribution
TheDZhon Feb 21, 2023
fcfad6c
test: fix fails on coverage run
folkyatina Feb 21, 2023
2f3efae
chore: abi
folkyatina Feb 21, 2023
d73a951
feat: add NFTDescriptor as an onchain way of generating metadata for …
ujenjt Feb 21, 2023
896aa7d
Merge pull request #646 from lidofinance/feature/nft-descriptor
TheDZhon Feb 21, 2023
b4604dc
abi: bump NFT abis
TheDZhon Feb 21, 2023
ff49079
fix: comments and docs 📚
ujenjt Feb 21, 2023
c161475
Merge pull request #647 from lidofinance/feature/nft-descriptor
TheDZhon Feb 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ cli/vendor

# OS relative
.DS_Store

# foundry artifacts
foundry/cache
foundry/out
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "foundry/lib/forge-std"]
path = foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.3.0
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ The contract also works as a wrapper that accepts stETH tokens and mints wstETH
* docker
* node.js v12
* (optional) Lerna
* (optional) Foundry

### Installing Aragon & other deps

Expand Down Expand Up @@ -239,6 +240,14 @@ so full branch coverage will never be reported until

[solidity-coverage#219]: https://github.com/sc-forks/solidity-coverage/issues/269

Run fuzzing tests with foundry:

```bash
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge test
```

## Deploying

We have several ways to deploy lido smart-contracts and run DAO locally, you can find documents here:
Expand Down
160 changes: 67 additions & 93 deletions contracts/0.4.24/Lido.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface IStakingRouter {
uint256 _maxDepositsCount,
uint256 _stakingModuleId,
bytes _depositCalldata
) external payable returns (uint256);
) external payable;

function getStakingRewardsDistribution()
external
Expand All @@ -101,6 +101,11 @@ interface IStakingRouter {
function getTotalFeeE4Precision() external view returns (uint16 totalFee);

function getStakingFeeAggregateDistributionE4Precision() external view returns (uint16 modulesFee, uint16 treasuryFee);

function getStakingModuleMaxDepositsCount(uint256 _stakingModuleId, uint256 _depositableEther)
external
view
returns (uint256);
}

interface IWithdrawalQueue {
Expand Down Expand Up @@ -160,7 +165,8 @@ contract Lido is Versioned, StETHPermit, AragonApp {

uint256 private constant DEPOSIT_SIZE = 32 ether;
uint256 public constant TOTAL_BASIS_POINTS = 10000;
/// @dev special value for the last finalizable withdrawal request id
/// @dev special value to not finalize withdrawal requests
/// see the `_lastFinalizableRequestId` arg for `handleOracleReport()`
uint256 private constant DONT_FINALIZE_WITHDRAWALS = 0;

/// @dev storage slot position for the Lido protocol contracts locator
Expand Down Expand Up @@ -244,18 +250,25 @@ contract Lido is Versioned, StETHPermit, AragonApp {
// The `amount` of ether was sent to the deposit_contract.deposit function
event Unbuffered(uint256 amount);

// The amount of ETH sent from StakingRouter contract to Lido contract when deposit called
event StakingRouterDepositRemainderReceived(uint256 amount);

/**
* @dev As AragonApp, Lido contract must be initialized with following variables:
* NB: by default, staking and the whole Lido pool are in paused state
*
* The contract's balance must be non-zero to allow initial holder bootstrap.
*
* @param _lidoLocator lido locator contract
* @param _eip712StETH eip712 helper contract for StETH
*/
function initialize(address _lidoLocator, address _eip712StETH)
public onlyInit
public
payable
onlyInit
{
uint256 amount = _bootstrapInitialHolder();
BUFFERED_ETHER_POSITION.setStorageUint256(amount);

emit Submitted(INITIAL_TOKEN_HOLDER, amount, 0);

_initialize_v2(_lidoLocator, _eip712StETH);
initialized();
}
Expand Down Expand Up @@ -284,15 +297,19 @@ contract Lido is Versioned, StETHPermit, AragonApp {
* @notice A function to finalize upgrade to v2 (from v1). Can be called only once
* @dev Value "1" in CONTRACT_VERSION_POSITION is skipped due to change in numbering
*
* The initial protocol token holder must exist.
*
* For more details see https://github.com/lidofinance/lido-improvement-proposals/blob/develop/LIPS/lip-10.md
*/
function finalizeUpgrade_v2(address _lidoLocator, address _eip712StETH) external {
require(hasInitialized(), "NOT_INITIALIZED");
_checkContractVersion(0);
require(hasInitialized(), "NOT_INITIALIZED");

require(_lidoLocator != address(0), "LIDO_LOCATOR_ZERO_ADDRESS");
require(_eip712StETH != address(0), "EIP712_STETH_ZERO_ADDRESS");

require(_sharesOf(INITIAL_TOKEN_HOLDER) != 0, "INITIAL_HOLDER_EXISTS");

_initialize_v2(_lidoLocator, _eip712StETH);
}

Expand Down Expand Up @@ -432,7 +449,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
* accepts payments of any size. Submitted Ethers are stored in Buffer until someone calls
* deposit() and pushes them to the Ethereum Deposit contract.
*/
// solhint-disable-next-line
// solhint-disable-next-line no-complex-fallback
function() external payable {
// protection against accidental submissions by calling non-existent function
require(msg.data.length == 0, "NON_EMPTY_DATA");
Expand Down Expand Up @@ -472,17 +489,6 @@ contract Lido is Versioned, StETHPermit, AragonApp {
emit WithdrawalsReceived(msg.value);
}

/**
* @notice A payable function for staking router deposits remainder. Can be called only by `StakingRouter`
* @dev We need a dedicated function because funds received by the default payable function
* are treated as a user deposit
*/
function receiveStakingRouterDepositRemainder() external payable {
require(msg.sender == getLidoLocator().stakingRouter());

emit StakingRouterDepositRemainderReceived(msg.value);
}

/**
* @notice Stop pool routine operations
*/
Expand Down Expand Up @@ -550,10 +556,9 @@ contract Lido is Versioned, StETHPermit, AragonApp {
* @param _lastFinalizableRequestId right boundary of requestId range if equals 0, no requests should be finalized
* @param _simulatedShareRate share rate that was simulated by oracle when the report data created (1e27 precision)
*
* NB: `_simulatedShareRate` should be calculated by the Oracle daemon
* invoking the method with static call and passing `_lastFinalizableRequestId` == `_simulatedShareRate` == 0
* plugging the returned values to the following formula:
* `_simulatedShareRate = (postTotalPooledEther * 1e27) / postTotalShares`
* NB: `_simulatedShareRate` should be calculated off-chain by calling the method with `eth_call` JSON-RPC API
* while passing `_lastFinalizableRequestId` == `_simulatedShareRate` == 0, and plugging the returned values
* to the following formula: `_simulatedShareRate = (postTotalPooledEther * 1e27) / postTotalShares`
*
* @return postTotalPooledEther amount of ether in the protocol after report
* @return postTotalShares amount of shares in the protocol after report
Expand Down Expand Up @@ -677,14 +682,10 @@ contract Lido is Versioned, StETHPermit, AragonApp {
* @dev Returns depositable ether amount.
* Takes into account unfinalized stETH required by WithdrawalQueue
*/
function getDepositableEther() public view returns (uint256 depositableEth) {
uint256 bufferedEth = _getBufferedEther();
function getDepositableEther() public view returns (uint256) {
uint256 bufferedEther = _getBufferedEther();
uint256 withdrawalReserve = IWithdrawalQueue(getLidoLocator().withdrawalQueue()).unfinalizedStETH();

if (bufferedEth > withdrawalReserve) {
bufferedEth -= withdrawalReserve;
depositableEth = bufferedEth.div(DEPOSIT_SIZE).mul(DEPOSIT_SIZE);
}
return bufferedEther > withdrawalReserve ? bufferedEther - withdrawalReserve : 0;
}

/**
Expand All @@ -697,36 +698,29 @@ contract Lido is Versioned, StETHPermit, AragonApp {
ILidoLocator locator = getLidoLocator();

require(msg.sender == locator.depositSecurityModule(), "APP_AUTH_DSM_FAILED");
require(_stakingModuleId <= uint24(-1), "STAKING_MODULE_ID_TOO_LARGE");
require(canDeposit(), "CAN_NOT_DEPOSIT");

uint256 depositableEth = getDepositableEther();

if (depositableEth > 0) {
/// available ether amount for deposits (multiple of 32eth)
depositableEth = Math256.min(depositableEth, _maxDepositsCount.mul(DEPOSIT_SIZE));

uint256 unaccountedEth = _getUnaccountedEther();
/// @dev transfer ether to SR and make deposit at the same time
/// @notice allow zero value of depositableEth, in this case SR will simply transfer the unaccounted ether to Lido contract
uint256 depositsCount = IStakingRouter(locator.stakingRouter()).deposit.value(depositableEth)(
_maxDepositsCount,
_stakingModuleId,
_depositCalldata
);

uint256 depositedAmount = depositsCount.mul(DEPOSIT_SIZE);
assert(depositedAmount <= depositableEth);

if (depositsCount > 0) {
uint256 newDepositedValidators = DEPOSITED_VALIDATORS_POSITION.getStorageUint256().add(depositsCount);
DEPOSITED_VALIDATORS_POSITION.setStorageUint256(newDepositedValidators);
emit DepositedValidatorsChanged(newDepositedValidators);

_markAsUnbuffered(depositedAmount);
assert(_getUnaccountedEther() == unaccountedEth);
}
}
IStakingRouter stakingRouter = IStakingRouter(locator.stakingRouter());
uint256 depositsCount = Math256.min(
_maxDepositsCount,
stakingRouter.getStakingModuleMaxDepositsCount(_stakingModuleId, getDepositableEther())
);
if (depositsCount == 0) return;

uint256 depositsValue = depositsCount.mul(DEPOSIT_SIZE);
/// @dev firstly update the local state of the contract to prevent a reentrancy attack,
/// even if the StakingRouter is a trusted contract.
BUFFERED_ETHER_POSITION.setStorageUint256(_getBufferedEther().sub(depositsValue));
emit Unbuffered(depositsValue);

uint256 newDepositedValidators = DEPOSITED_VALIDATORS_POSITION.getStorageUint256().add(depositsCount);
DEPOSITED_VALIDATORS_POSITION.setStorageUint256(newDepositedValidators);
emit DepositedValidatorsChanged(newDepositedValidators);

/// @dev transfer ether to StakingRouter and make a deposit at the same time. All the ether
/// sent to StakingRouter is counted as deposited. If StakingRouter can't deposit all
/// passed ether it MUST revert the whole transaction (never happens in normal circumstances)
stakingRouter.deposit.value(depositsValue)(depositsCount, _stakingModuleId, _depositCalldata);
}

/// DEPRECATED PUBLIC METHODS
Expand Down Expand Up @@ -937,14 +931,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
STAKING_STATE_POSITION.setStorageStakeLimitStruct(stakeLimitData.updatePrevStakeLimit(currentStakeLimit - msg.value));
}

uint256 sharesAmount;
if (_getTotalPooledEther() != 0 && _getTotalShares() != 0) {
sharesAmount = getSharesByPooledEth(msg.value);
} else {
// totalPooledEther is 0: for first-ever deposit
// assume that shares correspond to Ether 1-to-1
sharesAmount = msg.value;
}
uint256 sharesAmount = getSharesByPooledEth(msg.value);

_mintShares(msg.sender, sharesAmount);

Expand Down Expand Up @@ -1095,30 +1082,13 @@ contract Lido is Versioned, StETHPermit, AragonApp {
_emitTransferAfterMintingShares(treasury, treasuryReward);
}

/**
* @dev Records a deposit to the deposit_contract.deposit function
* @param _amount Total amount deposited to the Consensus Layer side
*/
function _markAsUnbuffered(uint256 _amount) internal {
BUFFERED_ETHER_POSITION.setStorageUint256(_getBufferedEther().sub(_amount));

emit Unbuffered(_amount);
}

/**
* @dev Gets the amount of Ether temporary buffered on this contract balance
*/
function _getBufferedEther() internal view returns (uint256) {
return BUFFERED_ETHER_POSITION.getStorageUint256();
}

/**
* @dev Gets unaccounted (excess) Ether on this contract balance
*/
function _getUnaccountedEther() internal view returns (uint256) {
return address(this).balance.sub(_getBufferedEther());
}

/// @dev Calculates and returns the total base balance (multiple of 32) of validators in transient state,
/// i.e. submitted to the official Deposit contract but not yet visible in the CL state.
/// @return transient balance in wei (1e-18 Ether)
Expand All @@ -1127,7 +1097,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
uint256 clValidators = CL_VALIDATORS_POSITION.getStorageUint256();
// clValidators can never be less than deposited ones.
assert(depositedValidators >= clValidators);
return depositedValidators.sub(clValidators).mul(DEPOSIT_SIZE);
return (depositedValidators - clValidators).mul(DEPOSIT_SIZE);
}

/**
Expand Down Expand Up @@ -1203,7 +1173,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
* (i.e., postpone the extra rewards to be applied during the next rounds)
* 5. Invoke finalization of the withdrawal requests
* 6. Distribute protocol fee (treasury & node operators)
* 7. Burn excess shares (withdrawn stETH at least)
* 7. Burn excess shares within the allowed limit (can postpone some shares to be burnt later)
* 8. Complete token rebase by informing observers (emit an event and call the external receivers if any)
* 9. Sanity check for the provided simulated share rate
*/
Expand Down Expand Up @@ -1288,8 +1258,9 @@ contract Lido is Versioned, StETHPermit, AragonApp {
);

// Step 7.
// Burn excess shares (withdrawn stETH at least)
uint256 burntWithdrawalQueueShares = _burnSharesLimited(
// Burn excess shares within the allowed limit (can postpone some shares to be burnt later)
// Return actually burnt shares of the current report's finalized withdrawal requests to use in sanity checks
uint256 burntCurrentWithdrawalShares = _burnSharesLimited(
IBurner(_contracts.burner),
_contracts.withdrawalQueue,
reportContext.sharesToBurnFromWithdrawalQueue,
Expand All @@ -1313,7 +1284,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
postTotalPooledEther,
postTotalShares,
reportContext.etherToLockOnWithdrawalQueue,
burntWithdrawalQueueShares,
burntCurrentWithdrawalShares,
_reportedData.simulatedShareRate
);
}
Expand Down Expand Up @@ -1377,17 +1348,20 @@ contract Lido is Versioned, StETHPermit, AragonApp {
/*
* @dev Perform burning of `stETH` shares via the dedicated `Burner` contract.
*
* NB: some of the burning amount can be postponed for the next reports
* if positive token rebase smoothened.
* NB: some of the burning amount can be postponed for the next reports if positive token rebase smoothened.
* It's possible that underlying shares of the current oracle report's finalized withdrawals won't be burnt
* completely in a single oracle report round due to the provided `_sharesToBurnLimit` limit
*
* @return burnt shares from withdrawals queue (when some requests finalized)
* @return shares actually burnt for the current oracle report's finalized withdrawals
* these shares are assigned to be burnt most recently, so the amount can be calculated deducting
* `postponedSharesToBurn` shares (if any) after the burn commitment & execution
*/
function _burnSharesLimited(
IBurner _burner,
address _withdrawalQueue,
uint256 _sharesToBurnFromWithdrawalQueue,
uint256 _sharesToBurnLimit
) internal returns (uint256 burntWithdrawalsShares) {
) internal returns (uint256 burntCurrentWithdrawalShares) {
if (_sharesToBurnFromWithdrawalQueue > 0) {
_burner.requestBurnShares(_withdrawalQueue, _sharesToBurnFromWithdrawalQueue);
}
Expand All @@ -1403,7 +1377,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
(uint256 coverShares, uint256 nonCoverShares) = _burner.getSharesRequestedToBurn();
uint256 postponedSharesToBurn = coverShares.add(nonCoverShares);

burntWithdrawalsShares =
burntCurrentWithdrawalShares =
postponedSharesToBurn < _sharesToBurnFromWithdrawalQueue ?
_sharesToBurnFromWithdrawalQueue - postponedSharesToBurn : 0;
}
Expand Down