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

Rebasable Token #3

Open
wants to merge 202 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
202 commits
Select commit Hold shift + click to select a range
3256d9f
create new contract that represents stETH on L2
kovalgek Oct 10, 2023
e4b2cbd
add wrap/unwrap functions
kovalgek Oct 11, 2023
82038ea
add shares to rebasable token
kovalgek Oct 13, 2023
380caaa
add unit tests
kovalgek Oct 17, 2023
eab8718
add deposit flow for new rebasable token
kovalgek Nov 4, 2023
c3bc0db
add withdraw flow for rebasable token on optimism
kovalgek Nov 5, 2023
eb98d0b
send rate in data and time during deposit flow
kovalgek Nov 9, 2023
800e33f
add possibility to depost 0 tokens
kovalgek Nov 9, 2023
d9ac556
init structs
kovalgek Nov 9, 2023
ddb9ca3
add comments
kovalgek Dec 11, 2023
a73bcf4
add gas test
kovalgek Dec 11, 2023
6d37edc
update gas test
kovalgek Dec 12, 2023
8098fe1
fix tests
kovalgek Dec 16, 2023
3335339
add token rate oracle
kovalgek Dec 20, 2023
86037dc
add tests for new token, renaming
kovalgek Dec 24, 2023
86788b2
simplify oracle, remove warnings
kovalgek Dec 27, 2023
ddffe1f
update unit tests for token rate oracle
kovalgek Dec 28, 2023
7c79d2d
fix integration tests for rebasable token
kovalgek Jan 9, 2024
6174943
Merge branch 'main' into feature/add_stETH_token_to_optimism
kovalgek Jan 9, 2024
f0b891a
add test for push token rate method
kovalgek Jan 9, 2024
e314bb1
unused return values fix
kovalgek Jan 9, 2024
4b56ccf
fix deployment scripts for new oracle and token
kovalgek Jan 9, 2024
3b82da7
add hearbeat to oracle
kovalgek Jan 10, 2024
171db5a
pr fixes from first rount review: apply unstructured storage in token…
kovalgek Jan 22, 2024
76b4ff3
PR fixes: fix comments, rename interface, abstract wst
kovalgek Jan 29, 2024
7abf60f
use real implemnations of non rebasable token and oracle contracts in…
kovalgek Feb 2, 2024
707da9b
update unit tests for bridges
kovalgek Feb 8, 2024
1cb344a
fix evetns + formating
kovalgek Feb 13, 2024
f9463f0
Merge branch 'main' into feature/add_stETH_token_to_optimism
kovalgek Feb 29, 2024
3fd1e94
move token rate to the base contract
kovalgek Mar 6, 2024
66b2501
use inheritance for token rate in l1 bridge, fix e2e tests
kovalgek Mar 6, 2024
7badd9e
add rebasable token e2e tests
kovalgek Mar 6, 2024
72bc8f3
add bridging-to e2e tests for rebasable token
kovalgek Mar 6, 2024
83e292b
add token rate observer
kovalgek Mar 7, 2024
dbf2f92
add observers array
kovalgek Mar 14, 2024
47c50c6
add factory and tests
kovalgek Mar 18, 2024
7e45410
add unit tests for notifier
kovalgek Mar 19, 2024
55111b8
add token rate pusher
kovalgek Mar 22, 2024
d99a52f
update unit tests for token rate oracle
kovalgek Mar 22, 2024
fb3eb40
remove observer array
kovalgek Mar 22, 2024
b167ebd
fix token rate publicher and notifier unit tests
kovalgek Mar 22, 2024
55d2e3f
fix small comments from PR review
kovalgek Mar 22, 2024
13712ca
feat(steth): intermediate work on adding ERC-2612/EIP-1271 permit
arwer13 Mar 27, 2024
6a46704
update optimism sdk version to fix integration tests
kovalgek Mar 29, 2024
b9d5e56
update addresses to run e2e tests
kovalgek Mar 29, 2024
a3f4544
fix integration test
kovalgek Mar 29, 2024
e2c29e0
deployment scripts
kovalgek Apr 1, 2024
d28d53d
Merge branch 'feature/add_stETH_token_to_optimism' into feat/steth-pe…
arwer13 Apr 1, 2024
0d2df1d
add token rate oracle integration tests
kovalgek Apr 1, 2024
8dc246e
fix happy path test for permit for rebasable
arwer13 Apr 2, 2024
ba0b41e
test(rebasable permit): move the rest tests from core stethpermit.tes…
arwer13 Apr 2, 2024
18a1dc5
add e2e tests for oracle
kovalgek Apr 2, 2024
624219c
Merge pull request #74 from lidofinance/feat/steth-permit
kovalgek Apr 2, 2024
5f86091
remove increaseAllowance and decreaseAllowance from tokens
kovalgek Apr 3, 2024
cc868ef
change function names
kovalgek Apr 3, 2024
06d00c7
rename stETH to rebasable token in env
kovalgek Apr 3, 2024
0b22b0f
deploy all script, refactor other deploy scripts
kovalgek Apr 8, 2024
f563fab
add permit to non-rebasable token
kovalgek Apr 9, 2024
3332e30
add unit tests for non-rebasable token
kovalgek Apr 10, 2024
0545e33
PR fixes: fix comments, readme, rename bridges, notifier refactoring
kovalgek Apr 10, 2024
a55b5f0
use mapping for tokens in bridges
kovalgek Apr 15, 2024
f54eecd
fix bridge unit and integration tests, remove mapping in storing toke…
kovalgek Apr 15, 2024
bc1c56f
fix scripts
kovalgek Apr 15, 2024
b62fbee
PR fixes: add comments, rename constracts, more interfaces to contrac…
kovalgek Apr 15, 2024
f387de6
PR fixes: rename tokens, add sanity check to oracle update, add unit …
kovalgek Apr 16, 2024
171f19b
Merge branch 'main' into feature/rebasable_token
kovalgek Apr 17, 2024
06768b6
remove arbitrum leftovers after mergin
kovalgek Apr 17, 2024
5d26aab
update package lock
kovalgek Apr 17, 2024
e587c93
Merge branch 'main' into feature/rebasable_token
kovalgek Apr 17, 2024
6a5257d
fix: Make storage-layout up to date
TheDZhon Apr 17, 2024
b1963d3
Merge pull request #8 from lidofinance/update-storage-layout-feature/…
TheDZhon Apr 17, 2024
ea6fcd7
fix: update npm locks
TheDZhon Apr 17, 2024
0ef8c86
use unstrucured storage in PermitExtension, add initializers to permi…
kovalgek Apr 17, 2024
e2cf92f
remove OZ 4.9
kovalgek Apr 17, 2024
fa0fc29
remove unused contract
kovalgek Apr 17, 2024
429aa7e
refactor bridges
kovalgek Apr 17, 2024
68066b9
remove unused function
kovalgek Apr 17, 2024
84ed665
set default value in config example
kovalgek Apr 17, 2024
58fb55f
use unstructured storage in token rate oracle
kovalgek Apr 17, 2024
4ac5b44
add transferShares and transferSharesFrom to rebasable token, unit tests
kovalgek Apr 18, 2024
1cf4329
add Versioned contract
kovalgek Apr 21, 2024
16b6484
disable initializers
kovalgek Apr 21, 2024
b6dd6a2
disable initializers for bridges
kovalgek Apr 21, 2024
f310a3e
rename variables
kovalgek Apr 21, 2024
1b8cd59
fix tests
kovalgek Apr 21, 2024
0e222ec
change filters for updating token rate
kovalgek Apr 21, 2024
4d16767
fix initilization
kovalgek Apr 22, 2024
fad1a4e
fix token rate oracle according to feedback
kovalgek Apr 22, 2024
3f2ef87
fix token rate uptading conditions, add tests for initializer
kovalgek Apr 22, 2024
c10f864
update scripts and tests
kovalgek Apr 23, 2024
8518ca1
fix: Make storage-layout up to date
TheDZhon Apr 23, 2024
c3e8b9e
small fixes and init tests
kovalgek Apr 23, 2024
f2ff45e
Merge pull request #9 from lidofinance/update-storage-layout-feature/…
TheDZhon Apr 23, 2024
792071c
update comments, change functions order, emit additional event when b…
kovalgek Apr 24, 2024
695fa42
add integration tests for zero and 1wei amount of token
kovalgek Apr 24, 2024
689a194
fix critical: mint wstETH and wrap to stETH during stETH deposit and …
kovalgek Apr 29, 2024
737f969
update tests for wrap/unwrap on L2 during deposit/withdrwal
kovalgek Apr 29, 2024
ad309de
refactor and add new integration tests for non rebasable token
kovalgek Apr 29, 2024
e4d45cc
refactor _mintTokens, add new method for rebasable token that can unw…
kovalgek May 1, 2024
ccb3410
remove approval before withdrawal in tests, add new tests for bridgeU…
kovalgek May 1, 2024
b552925
remove bridgeMintShares and bridgeBurnShares methods and rename inter…
kovalgek May 1, 2024
88cf382
remove tests for bridgeBurnShares and bridgeMintShares
kovalgek May 1, 2024
d49322a
add bridgeWrap, setup infinite allowance l2 bridge for bridged token,…
kovalgek May 2, 2024
e965a88
add tests for bridgeWrap
kovalgek May 2, 2024
a3abe91
rename interface
kovalgek May 2, 2024
d2bc0a1
fix comments in few contracts
kovalgek May 2, 2024
9d6f66c
Merge pull request #10 from lidofinance/feature/rebasable_token_fix_w…
kovalgek May 2, 2024
205cd67
add unwrapShares method to rebasable roken, add tests
kovalgek May 8, 2024
b68c9a5
check name and symbol for emptyness during initialization, tests
kovalgek May 8, 2024
752bb46
add comment for CEXes
kovalgek May 8, 2024
f00015b
check maxAllowedTokenRateDeviationPerDay in oracle
kovalgek May 8, 2024
af27454
optimisations: skip token rate range if value the same, improve remov…
kovalgek May 9, 2024
ccaa023
small improvements: unnecessary spaces, add comments, remove unused f…
kovalgek May 9, 2024
6795332
setup token rate oracle decimals in rebasable token constructor
kovalgek May 9, 2024
560a382
upgrade comment
kovalgek May 9, 2024
47c729d
check if bridge is zero address
kovalgek May 9, 2024
a5a3da5
check time and rate in init, fix rate deviation calculation, tests
kovalgek May 10, 2024
eba565f
change rate and time restrictions during init
kovalgek May 10, 2024
2f895fa
additional test to prove that it is imposible to init afer upgrade
kovalgek May 11, 2024
be90d6b
check that withdrawTo doesn't allow to withdraw to stETH on L1 address
kovalgek May 11, 2024
b497031
remove bottom limit of l2 blocktime in oracle init
kovalgek May 12, 2024
4b301e8
fix comments, error names, refactor token rate oracle and l2bridge
kovalgek May 15, 2024
d48ce20
remove token rate from event about wrong l1 time
kovalgek May 15, 2024
5c48830
update comment
kovalgek May 16, 2024
34ac185
use min/max functions
kovalgek May 16, 2024
64c8b98
don't allow to call initialize on prev deployed contract
kovalgek May 16, 2024
c95fdad
draft: change rate reporting approach
TheDZhon May 16, 2024
d4a19da
Merge branch 'feature/rebasable_token_mixbytes_audit_fixes' into draf…
kovalgek May 16, 2024
7019875
split l1 bridge and token pusher connection to be able to deploy orac…
kovalgek May 20, 2024
c2d3650
fix tests
kovalgek May 20, 2024
e55068e
refactor scripts
kovalgek May 20, 2024
a9e4df1
add tests for large amount of tokens
kovalgek May 22, 2024
6c5f357
add logs to scipts
kovalgek May 22, 2024
e6888cc
emit correct amount of token during unwrap and bridgeUnwrap
kovalgek May 22, 2024
5ea0159
emit correct events, fix comment, remove unsued code
kovalgek May 22, 2024
e137a55
fix: change event name for rate timestamp update
TheDZhon May 22, 2024
2830a6d
Merge pull request #12 from lidofinance/draft/change-rate-reporting
TheDZhon May 22, 2024
7369c2e
additional checks in constructors
kovalgek May 23, 2024
6d653c6
Merge branch 'feature/rebasable_token_mixbytes_audit_fixes' into feat…
kovalgek May 23, 2024
e2ec2b4
add new permit method with signature
kovalgek May 23, 2024
d69127f
Merge pull request #13 from lidofinance/feature/ackee_fixes
TheDZhon May 24, 2024
8958868
remove unused library
kovalgek May 27, 2024
5022c96
revert approve event changes
kovalgek May 27, 2024
074dee0
draft
kovalgek May 27, 2024
5ce9749
update pause/unpause logic
kovalgek May 27, 2024
6ddbdb5
update comments, add external methods
kovalgek May 28, 2024
ee950e4
add additional checks
kovalgek May 28, 2024
c4c14f1
fix tests
kovalgek May 28, 2024
48f3106
return instead of revert when updates are paused
kovalgek May 28, 2024
5bc7a43
add tests, small improvements in pause
kovalgek May 29, 2024
e54f586
rename constants, add comments, don't allow often rate updates
kovalgek May 30, 2024
a1f2587
add tests for double pause/unpause
kovalgek May 30, 2024
be9775f
Merge pull request #14 from lidofinance/feature/pause_token_rate
kovalgek May 31, 2024
b68fbaf
fix comments, small refactoring, rename events, constants
kovalgek May 31, 2024
a479315
Merge pull request #11 from lidofinance/feature/rebasable_token_mixby…
kovalgek May 31, 2024
6fba907
check admin address during initialization in bridges, fix indentation…
kovalgek Jun 6, 2024
a31049a
Merge pull request #15 from lidofinance/feature/ackee_fixes_1_1
kovalgek Jun 6, 2024
baf9859
update upgrade/deploy scripts
kovalgek Jun 11, 2024
12333ef
add permission to handle toekn rate report by token rate notifier
kovalgek Jun 14, 2024
3542881
fix test
kovalgek Jun 16, 2024
95fd5b7
additional check for l1 time during resuming
kovalgek Jun 17, 2024
40f0e78
rename constant
kovalgek Jun 18, 2024
1f8bdf8
rename constants, remove unused code
kovalgek Jun 18, 2024
8f19e11
Merge pull request #16 from lidofinance/feature/second_round_audit_re…
kovalgek Jun 18, 2024
61f2cbc
balance check script
loga4 Jun 27, 2024
67fc4c8
fix integration tests, refactor scripts
kovalgek Jun 30, 2024
659d574
fix push token integration test
kovalgek Jul 3, 2024
1654e92
Merge pull request #20 from lidofinance/feature/fix_integration_tests
kovalgek Jul 3, 2024
50f3358
remove acceptance tests
kovalgek Jul 3, 2024
57e61ea
fix test for test coverage
kovalgek Jul 3, 2024
7da0c78
setup notifier and token rater oracle after deployment
kovalgek Jul 5, 2024
7f834a5
remove new line
kovalgek Jul 5, 2024
3aad26c
Merge pull request #21 from lidofinance/feature/improve_scripts
kovalgek Jul 7, 2024
b9dc7e2
fix e2e tests, reorganize test forlder
kovalgek Jul 8, 2024
d083cca
Merge pull request #22 from lidofinance/feature/fix_e2e_tets
kovalgek Jul 17, 2024
c10ff1a
add crosschain relayer utility
kovalgek Jul 18, 2024
1cdc1d9
chore: fix check deposits script and add debug do deposits script
arwer13 Jul 26, 2024
8856ca2
fix cross-chain-relayer
kovalgek Jul 26, 2024
9b7c07b
Merge pull request #24 from lidofinance/feature/add_crosschain_relayer
arwer13 Aug 2, 2024
780c0af
Merge pull request #19 from lidofinance/check_balances
arwer13 Aug 2, 2024
638b1af
rename envs, add comments, imrpove deploy scripts
kovalgek Aug 21, 2024
821f49d
change gov executor in env example
kovalgek Aug 21, 2024
c14070f
Merge pull request #25 from lidofinance/feature/improve_deploy_scripts
kovalgek Aug 21, 2024
516ba26
use deployer as admin when deploy token rate oracle, improve deploy logs
kovalgek Aug 22, 2024
60b10d7
Merge pull request #26 from lidofinance/feature/improve_deploy_scripts2
kovalgek Aug 27, 2024
0810bb7
add bytecode verificator with config
kovalgek Aug 27, 2024
78516b6
Merge pull request #27 from lidofinance/feature/bytecode_verificator
arwer13 Aug 28, 2024
1e643c8
fix scripts for fork upgrade rehersal
kovalgek Sep 12, 2024
2f9e8de
fix rebasable token integration tests
kovalgek Sep 19, 2024
12b842a
new package lock
kovalgek Sep 23, 2024
7b6e5ad
fix: Make storage-layout up to date
kovalgek Sep 23, 2024
fdc79e5
fix: ci runners node version
tamtamchik Sep 23, 2024
956e879
Merge branch 'feature/rebasable_token' into feature/rebasable_token_ci
tamtamchik Sep 23, 2024
a561beb
ci: add trigger on push and PR
tamtamchik Sep 23, 2024
440c7c0
ci: use only PR, no need to check every push
tamtamchik Sep 23, 2024
fe8478f
chore: formatting
tamtamchik Sep 23, 2024
bfd6840
Merge pull request #34 from lidofinance/feature/rebasable_token_ci
tamtamchik Sep 23, 2024
2a8ef3e
update address for ci bytecode verification
kovalgek Sep 23, 2024
71b5cf2
Merge pull request #33 from lidofinance/update-storage-layout-feature…
TheDZhon Sep 23, 2024
32dc66a
Merge pull request #35 from lidofinance/feature/new_adresses_for_byte…
TheDZhon Sep 23, 2024
a05c70a
use envs in on-fly deposits check script
kovalgek Sep 23, 2024
b5e3656
fix steth bridging integraion tests. use shares to check ballances
kovalgek Sep 25, 2024
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 4

[*.{js,yml,json,cjs}]
indent_size = 2
max_line_length = 120
38 changes: 36 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,39 @@ ETHERSCAN_API_KEY_OPT=
# Bridge/Gateway Deployment
# ############################

# Address of the token to deploy the bridge/gateway for
# Address of the token on L1 to deploy the bridge/gateway for
TOKEN=

# Address of the rebasable token on L1 to deploy the bridge/gateway for
REBASABLE_TOKEN=

# Address of token rate pusher. Required to config TokenRateOracle.
L1_OP_STACK_TOKEN_RATE_PUSHER=

# Gas limit required to complete pushing token rate on L2.
# Default is: 300_000.
# This value was calculated by formula:
# l2GasLimit = (gas cost of L2Bridge.finalizeDeposit() + OptimismPortal.minimumGasLimit(depositData.length)) * 1.5
L2_GAS_LIMIT_FOR_PUSHING_TOKEN_RATE=300000

# A time period when token rate can be considered outdated.
TOKEN_RATE_OUTDATED_DELAY=86400 # default is 86400 (24 hours)

# Address of L1 token bridge proxy.
L1_TOKEN_BRIDGE=

# Address of L2 token bridge proxy.
L2_TOKEN_BRIDGE=

# Address of the non-rebasable token proxy on L2.
L2_TOKEN=

# Address of token rate oracle on L2
L2_TOKEN_RATE_ORACLE=

# Address of bridge executor.
GOV_BRIDGE_EXECUTOR=

# Name of the network environments used by deployment scripts.
# Might be one of: "mainnet", "sepolia".
NETWORK=mainnet
Expand Down Expand Up @@ -61,6 +91,10 @@ L2_WITHDRAWALS_DISABLERS=[]
TESTING_OPT_NETWORK=
TESTING_OPT_L1_TOKEN=0xaF8a2F0aE374b03376155BF745A3421Dac711C12
TESTING_OPT_L2_TOKEN=0xAED5F9aaF167923D34174b8E636aaF040A11f6F7
TESTING_OPT_L1_TOKEN_RATE_NOTIFIER=0x554f2C7D58522c050d38Ebea4FF072ED7C4e61cb
TESTING_OPT_L1_REBASABLE_TOKEN=0xB82381A3fBD3FaFA77B3a7bE693342618240067b
TESTING_OPT_L2_REBASABLE_TOKEN=0x6696Cb7bb602FC744254Ad9E07EfC474FBF78857
TESTING_OPT_L2_TOKEN_RATE_ORACLE=0x8ea513d1e5Be31fb5FC2f2971897594720de9E70
TESTING_OPT_L1_ERC20_TOKEN_BRIDGE=0x243b661276670bD17399C488E7287ea4D416115b
TESTING_OPT_L2_ERC20_TOKEN_BRIDGE=0x447CD1794d209Ac4E6B4097B34658bc00C4d0a51

Expand All @@ -78,4 +112,4 @@ TESTING_OPT_GOV_BRIDGE_EXECUTOR=
# ############################

TESTING_PRIVATE_KEY=
TESTING_OPT_LDO_HOLDER_PRIVATE_KEY=
TESTING_OPT_LDO_HOLDER_PRIVATE_KEY=
3 changes: 3 additions & 0 deletions .env.wsteth.opt_mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ ETHERSCAN_API_KEY_OPT=
# Address of the token to deploy the bridge/gateway for
TOKEN=0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0

# Address of the rebasable token to deploy the bridge/gateway for
REBASABLE_TOKEN=

# Name of the network environments used by deployment scripts.
# Might be one of: "mainnet", "sepolia".
NETWORK=mainnet
Expand Down
74 changes: 68 additions & 6 deletions .storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@
| balanceOf | mapping(address => uint256) | 1 | 0 | 32 | contracts/token/ERC20Bridged.sol:ERC20Bridged |
| allowance | mapping(address => mapping(address => uint256)) | 2 | 0 | 32 | contracts/token/ERC20Bridged.sol:ERC20Bridged |

=======================
➡ ERC20BridgedPermit
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|------------------|-------------------------------------------------|------|--------|-------|-----------------------------------------------------------|
| totalSupply | uint256 | 0 | 0 | 32 | contracts/token/ERC20BridgedPermit.sol:ERC20BridgedPermit |
| balanceOf | mapping(address => uint256) | 1 | 0 | 32 | contracts/token/ERC20BridgedPermit.sol:ERC20BridgedPermit |
| allowance | mapping(address => mapping(address => uint256)) | 2 | 0 | 32 | contracts/token/ERC20BridgedPermit.sol:ERC20BridgedPermit |
| _nameFallback | string | 3 | 0 | 32 | contracts/token/ERC20BridgedPermit.sol:ERC20BridgedPermit |
| _versionFallback | string | 4 | 0 | 32 | contracts/token/ERC20BridgedPermit.sol:ERC20BridgedPermit |
| noncesByAddress | mapping(address => uint256) | 5 | 0 | 32 | contracts/token/ERC20BridgedPermit.sol:ERC20BridgedPermit |

=======================
➡ ERC20Core
=======================
Expand All @@ -51,24 +64,73 @@
|------|------|------|--------|-------|----------|

=======================
L1ERC20TokenBridge
ERC20RebasableBridged
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|--------|---------------------------------------------------|------|--------|-------|--------------------------------------------------------------|
| _roles | mapping(bytes32 => struct AccessControl.RoleData) | 0 | 0 | 32 | contracts/optimism/L1ERC20TokenBridge.sol:L1ERC20TokenBridge |
| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

=======================
➡ ERC20RebasableBridgedPermit
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|------------------|-----------------------------|------|--------|-------|-----------------------------------------------------------------------------|
| _nameFallback | string | 0 | 0 | 32 | contracts/token/ERC20RebasableBridgedPermit.sol:ERC20RebasableBridgedPermit |
| _versionFallback | string | 1 | 0 | 32 | contracts/token/ERC20RebasableBridgedPermit.sol:ERC20RebasableBridgedPermit |
| noncesByAddress | mapping(address => uint256) | 2 | 0 | 32 | contracts/token/ERC20RebasableBridgedPermit.sol:ERC20RebasableBridgedPermit |

=======================
L2ERC20TokenBridge
L1LidoTokensBridge
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|--------|---------------------------------------------------|------|--------|-------|--------------------------------------------------------------|
| _roles | mapping(bytes32 => struct AccessControl.RoleData) | 0 | 0 | 32 | contracts/optimism/L2ERC20TokenBridge.sol:L2ERC20TokenBridge |
| _roles | mapping(bytes32 => struct AccessControl.RoleData) | 0 | 0 | 32 | contracts/optimism/L1LidoTokensBridge.sol:L1LidoTokensBridge |

=======================
➡ L2ERC20ExtendedTokensBridge
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|--------|---------------------------------------------------|------|--------|-------|--------------------------------------------------------------------------------|
| _roles | mapping(bytes32 => struct AccessControl.RoleData) | 0 | 0 | 32 | contracts/optimism/L2ERC20ExtendedTokensBridge.sol:L2ERC20ExtendedTokensBridge |

=======================
➡ OpStackTokenRatePusher
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

=======================
➡ OssifiableProxy
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

=======================
➡ RebasableAndNonRebasableTokens
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|------|------|------|--------|-------|----------|

=======================
➡ TokenRateNotifier
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|-----------|-----------|------|--------|-------|--------------------------------------------------------|
| _owner | address | 0 | 0 | 20 | contracts/lido/TokenRateNotifier.sol:TokenRateNotifier |
| observers | address[] | 1 | 0 | 32 | contracts/lido/TokenRateNotifier.sol:TokenRateNotifier |

=======================
➡ TokenRateOracle
=======================

| Name | Type | Slot | Offset | Bytes | Contract |
|-----------------|---------|------|--------|-------|--------------------------------------------------------|
| tokenRate | uint256 | 0 | 0 | 32 | contracts/optimism/TokenRateOracle.sol:TokenRateOracle |
| rateL1Timestamp | uint256 | 1 | 0 | 32 | contracts/optimism/TokenRateOracle.sol:TokenRateOracle |
18 changes: 16 additions & 2 deletions README.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ let's document proxy and non-proxy deployments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ ⚠️ ⚠️

We should discourage deployment stETH by default by newcomer networks because it would require maintaining the token rate oracle seamlessly

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This project contains the implementations of the L2 ERC20 token bridge for Optim
To retrieve more detailed info about the bridging process, see the specifications for certain chains:

- [Lido's Optimism Bridge](https://github.com/lidofinance/lido-l2/blob/main/contracts/optimism/README.md).
- [wstETH Bridging Guide](https://docs.lido.fi/token-guides/wsteth-bridging-guide/#r-5-bridging-l1-lido-dao-decisions)

## Project setup

Expand Down Expand Up @@ -41,7 +42,16 @@ Fill the newly created `.env` file with the required variables. See the [Project

The configuration of the deployment scripts happens via the ENV variables. The following variables are required:

- [`TOKEN`](#TOKEN) - address of the token to deploy a new bridge on the Ethereum chain.
- [`TOKEN`](#TOKEN) - address of the non-rebasable token to deploy a new bridge on the Ethereum chain.
- [`REBASABLE_TOKEN`] (#REBASABLE_TOKEN) - address of the rebasable token to deploy new bridge on the Ethereum chain.
- [`L1_OP_STACK_TOKEN_RATE_PUSHER`](#L1_OP_STACK_TOKEN_RATE_PUSHER) - address of token rate pusher. Required to config TokenRateOracle.
- [`L2_GAS_LIMIT_FOR_PUSHING_TOKEN_RATE`](#L2_GAS_LIMIT_FOR_PUSHING_TOKEN_RATE) - gas limit required to complete pushing token rate on L2.This value was calculated by formula: l2GasLimit = (gas cost of L2Bridge.finalizeDeposit() + OptimismPortal.minimumGasLimit(depositData.length)) * 1.5
- [`TOKEN_RATE_OUTDATED_DELAY`](#TOKEN_RATE_OUTDATED_DELAY) - a time period when token rate can be considered outdated. Default is 86400 (24 hours).
- [`L1_TOKEN_BRIDGE`](#L1_TOKEN_BRIDGE) - address of L1 token bridge.
- [`L2_TOKEN_BRIDGE`](#L2_TOKEN_BRIDGE) - address of L2 token bridge.
- [`L2_TOKEN`](#L2_TOKEN) - address of the non-rebasable token on L2.
- [`L2_TOKEN_RATE_ORACLE`](#L2_TOKEN_RATE_ORACLE) - address of token rate oracle on L2.
- [`GOV_BRIDGE_EXECUTOR`](#GOV_BRIDGE_EXECUTOR) - address of bridge executor.
- [`NETWORK`](#NETWORK) - name of the network environments used by deployment scripts. Allowed values: `mainnet`, `sepolia`.
- [`FORKING`](#FORKING) - run deployment in the forking network instead of real ones
- [`ETH_DEPLOYER_PRIVATE_KEY`](#ETH_DEPLOYER_PRIVATE_KEY) - The private key of the deployer account in the Ethereum network is used during the deployment process.
Expand Down Expand Up @@ -234,7 +244,11 @@ Below variables used in the Optimism bridge deployment process.

#### `TOKEN`

Address of the token to deploy a new bridge on the Ethereum chain.
Address of the existing non-rebasable token to deploy a new bridge for on the Ethereum chain.

#### `REBASABLE_TOKEN`

Address of the existing rebasable token to deploy new bridge for on the Ethereum chain.

#### `NETWORK`

Expand Down
8 changes: 4 additions & 4 deletions artifacts-opt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{
"artifactPath": "artifacts/contracts/proxy/OssifiableProxy.sol/OssifiableProxy.json",
"sourcePath": "contracts/proxy/OssifiableProxy.sol",
"name": "L2ERC20TokenBridge proxy",
"name": "L2ERC20ExtendedTokensBridge proxy",
"address": "0x8E01013243a96601a86eb3153F0d9Fa4fbFb6957"
},
{
"artifactPath": "artifacts/contracts/optimism/L2ERC20TokenBridge.sol/L2ERC20TokenBridge.json",
"sourcePath": "contracts/optimism/L2ERC20TokenBridge.sol",
"name": "L2ERC20TokenBridge",
"artifactPath": "artifacts/contracts/optimism/L2ERC20ExtendedTokensBridge.sol/L2ERC20ExtendedTokensBridge.json",
"sourcePath": "contracts/optimism/L2ERC20ExtendedTokensBridge.sol",
"name": "L2ERC20ExtendedTokensBridge",
"address": "0x23B96aDD54c479C6784Dd504670B5376B808f4C7",
"txHash": "0x5d69e9c6ec1d634f0d90812c2189c925993d1fffbc9b0b416fdc123e15407c56"
},
Expand Down
49 changes: 0 additions & 49 deletions contracts/BridgeableTokens.sol

This file was deleted.

10 changes: 8 additions & 2 deletions contracts/BridgingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// @param isDepositsEnabled Stores the state of the deposits
/// @param isWithdrawalsEnabled Stores the state of the withdrawals
struct State {
bool isInitialized;
bool isInitialized; /// @dev DEPRECATED since bridges have their own code for versioning.
kovalgek marked this conversation as resolved.
Show resolved Hide resolved
bool isDepositsEnabled;
bool isWithdrawalsEnabled;
}
Expand All @@ -34,7 +34,7 @@
/// @notice Initializes the contract to grant DEFAULT_ADMIN_ROLE to the admin_ address
/// @dev This method might be called only once
/// @param admin_ Address of the account to grant the DEFAULT_ADMIN_ROLE
function initialize(address admin_) external {
function _initialize(address admin_) internal {
State storage s = _loadState();
if (s.isInitialized) {
revert ErrorAlreadyInitialized();
Expand Down Expand Up @@ -97,10 +97,15 @@
emit WithdrawalsDisabled(msg.sender);
}

function _isBridgingManagerInitialized() internal view returns (bool) {
State storage s = _loadState();
return s.isInitialized;
}

/// @dev Returns the reference to the slot with State struct
function _loadState() private pure returns (State storage r) {
bytes32 slot = STATE_SLOT;
assembly {

Check warning on line 108 in contracts/BridgingManager.sol

View workflow job for this annotation

GitHub Actions / solhint

Avoid to use inline assembly. It is acceptable only in rare cases
r.slot := slot
}
}
Expand Down Expand Up @@ -132,4 +137,5 @@
error ErrorWithdrawalsEnabled();
error ErrorWithdrawalsDisabled();
error ErrorAlreadyInitialized();
error ErrorBridgingManagerWasInitialized();
}
44 changes: 44 additions & 0 deletions contracts/lib/DepositDataCodec.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

/// @author kovalgek
/// @notice encodes and decodes DepositData for crosschain transfering.
library DepositDataCodec {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's fuzz this lib, but later


uint8 internal constant RATE_FIELD_SIZE = 12;
uint8 internal constant TIMESTAMP_FIELD_SIZE = 5;

struct DepositData {
uint96 rate;
uint40 timestamp;
bytes data;
}

function encodeDepositData(DepositData memory depositData) internal pure returns (bytes memory) {
bytes memory data = bytes.concat(
abi.encodePacked(depositData.rate),
abi.encodePacked(depositData.timestamp),
abi.encodePacked(depositData.data)
);
return data;
}

function decodeDepositData(bytes calldata buffer) internal pure returns (DepositData memory) {

if (buffer.length < RATE_FIELD_SIZE + TIMESTAMP_FIELD_SIZE) {
revert ErrorDepositDataLength();
}

DepositData memory depositData = DepositData({
rate: uint96(bytes12(buffer[0:RATE_FIELD_SIZE])),
timestamp: uint40(bytes5(buffer[RATE_FIELD_SIZE:RATE_FIELD_SIZE + TIMESTAMP_FIELD_SIZE])),
data: buffer[RATE_FIELD_SIZE + TIMESTAMP_FIELD_SIZE:]
});

return depositData;
}

error ErrorDepositDataLength();
}
Loading
Loading