feat(l2): track locked balance in L2 integration test #1582
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The total amount of tokens present in the L2 has to match the balance of the
CommonBridge
contract at all times.Description
There are some things to consider:
CommonBridge
→ emits anevent
.l1_watcher
will "read" the event and will create a transaction on the L2.1.
This transaction, which is aPrivilegedL2
transaction and works the same as anEIP1559
when it comes to gas calculations, implies that some fees are sent to thecoinbase_address
. At the moment, the depositPrivilegedL2
transactions are created by an L2 rich account, we may change this in the future. Moreover, the gas used on the L2 by the deposit has to come from the L1.coinbase_address
, we can withdraw them if we want to, the burned fees are unrecoverable. Taken this into account, the total locked value should equal theCommonBridge
balance minus the burned fees, without taking into account the L2'srich_accounts
.With such introduction, this PR aims to add some calculations inside the L2 integration test. The idea is to keep track of the fees and the
CommonBridge
balance. The final output of the test is:and if we do
TOTAL Locked L2 value with recoverable fees: 899999978091880316160
+BURNED FEES L2: 21908119683840
we get theCommon Bridge Locked Balance: 900000000000000000000
as expected.The test subtracts the fees that comes from the first deposit (
1.
).Closes #1043