-
Notifications
You must be signed in to change notification settings - Fork 4
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
OptimismPortal2 set initial _balance
through StorageSetter pattern
#254
Conversation
op-e2e/celo/src/chain.js
Outdated
@@ -1,8 +1,8 @@ | |||
import { chainConfig } from 'viem/op-stack' | |||
import { defineChain } from 'viem' | |||
import { chainConfig } from "viem/op-stack"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the switch from single to double quotes here? The other js files in this dir seem to all be using single quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - this was mainly due to my editor doing automatic formats on save.
I now added a .prettierrc.toml
config and formatted all files consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the tab width of 4 is not working out here, there are now about 7k lines of changed code, I think 2 is probably the right value, or whatever doesn't reformat any of the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, let's move out the re-formatting to a separate PR if needed.
uint256 initialBalance = 0; | ||
customGasTokenAddress = cfg.customGasTokenAddress(); | ||
IERC20 token = IERC20(customGasTokenAddress); | ||
initialBalance = token.balanceOf(optimismPortalProxy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the balance of the optimismPortalProxy set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is set within the Deploy.s.sol
script:
Our Celo L1 Token contract takes the Portal address as an initializer argument:
optimism/packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Lines 1693 to 1697 in 981f87f
_upgradeAndCallViaSafe({ | |
_proxy: payable(customGasTokenProxyAddress), | |
_implementation: customGasTokenAddress, | |
_innerCallData: abi.encodeCall(CeloTokenL1.initialize, (portalProxyAddress)) | |
}); |
And then mints the whole market cap to the provided addresses balance:
optimism/packages/contracts-bedrock/src/celo/CeloTokenL1.sol
Lines 8 to 14 in 981f87f
uint256 constant TOTAL_MARKET_CAP = 1000000000e18; // 1 billion CELO | |
contract CeloTokenL1 is ERC20Upgradeable { | |
function initialize(address portalProxyAddress) public initializer { | |
__ERC20_init(NAME, SYMBOL); | |
_mint(portalProxyAddress, TOTAL_MARKET_CAP); | |
} |
op-e2e/celo/src/withdraw.js
Outdated
|
||
const l2GasPayment = | ||
receipt.gasUsed * receipt.effectiveGasPrice + receipt.l1Fee | ||
const l2GasPayment = receipt.gasUsed * receipt.effectiveGasPrice; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we want to keep the l1Fee
, just have it 0
everywhere, maybe doesn't make sense to remove it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but it seems this is not yet reflected in the code. This means that receipt values do not align with deducted values.
This should only happen when the blobbasefeeScalar
and basefeeScalar
are not set to 0.
I opened an issue for it, I don't know if we were aware of this behavior already.
A hot-fix to make the test pass would be to set the blobbasefeeScalar
and basefeeScalar
values to 0 in the devnet deploy-config - currently the default values are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is in op-geth and we didn't update the dependency yet. I'll probably do it as part of the optimism repo rebase.
981f87f
to
e68c0e3
Compare
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/[email protected] |
So I added the However the I checked the https://go.dev/play/p/8PN2lhQ-QGE This is the same value that I could observe in the transaction receipts. For now I don't know what's wrong here, but this is likely something that happens in the payload building in the L2 node. I suggest we postpone fixing the tests for now and review this PR mainly for the changes to the @pahor167 , could you have a look at this part of the PR? |
op-e2e/celo/package.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does your editor change the indentation or did npm change in this respect? If it's your editor, please avoid the additional diff (for this and the other json files).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it is probably prettier
. We should avoid having npm and prettier fight over the formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think npm doesn't have auto-formatting included. Before, the code probably has been formatted by an editor's global settings of prettier or the LanguageServer.
The problem with the diff was the tab-width setting in prettier - I changed it to 2, which seem to have been the setting the code has been formatted with previously. This got rid of most of the diff.
I added the npm run format
script that calls prettier in write mode with the checked in prettier config file.
Like that we can have an opinionated formatter for the e2e tests from now on and avoid larger formatting diffs in the future. Maybe we can include this in a pre-commit config or CI run as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for comparison the formatting instructions in our op-geth e2e tests: https://github.com/celo-org/op-geth/blob/celo8/e2e_test/js-tests/Makefile
We could adjust them to be the same (same formatter, same config and called int the same way), but we can do that later.
8762b47
to
72e56e4
Compare
Fixes #239 The custom gas-token feature adaptation for the fault-proof system using the `OptimismPortal2` contract has been merged recently upstream. We are using the custom-gas-token feature and additionally require a modification of the OptimismPortal's `_balance` value to be set to the entire allocation of Celo on the L2 - meaning that all L1 token is initially locked in the bridge and only usable on the L2. Those changes are now adapted also to the `OptimismPortal2`, which was a requirement to make our custom-gas-token pre-locked balance feature work in conjunction with fault-proofs.
Co-authored-by: Valentin Rodygin <[email protected]>
72e56e4
to
7009efb
Compare
commands[2] = string.concat("[[ -f ", filePath, " ]] && echo \"present\""); | ||
commands[2] = string.concat("[[ -f ", filePath, ' ]] && echo "present"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an unnecessary change. Did you do it intentionally or did an autoformatter do this?
…254) * OptimismPortal2 set initial `_balance` through StorageSetter pattern Fixes #239 The custom gas-token feature adaptation for the fault-proof system using the `OptimismPortal2` contract has been merged recently upstream. We are using the custom-gas-token feature and additionally require a modification of the OptimismPortal's `_balance` value to be set to the entire allocation of Celo on the L2 - meaning that all L1 token is initially locked in the bridge and only usable on the L2. Those changes are now adapted also to the `OptimismPortal2`, which was a requirement to make our custom-gas-token pre-locked balance feature work in conjunction with fault-proofs. * Adapt withdraw e2e-tests to work with fault-proofs * Use prettier for formatting e2e tests * Fix typo Co-authored-by: Valentin Rodygin <[email protected]> * Set L1-fee scalars to zero in devnet --------- Co-authored-by: Valentin Rodygin <[email protected]>
…254) * OptimismPortal2 set initial `_balance` through StorageSetter pattern Fixes #239 The custom gas-token feature adaptation for the fault-proof system using the `OptimismPortal2` contract has been merged recently upstream. We are using the custom-gas-token feature and additionally require a modification of the OptimismPortal's `_balance` value to be set to the entire allocation of Celo on the L2 - meaning that all L1 token is initially locked in the bridge and only usable on the L2. Those changes are now adapted also to the `OptimismPortal2`, which was a requirement to make our custom-gas-token pre-locked balance feature work in conjunction with fault-proofs. * Adapt withdraw e2e-tests to work with fault-proofs * Use prettier for formatting e2e tests * Fix typo Co-authored-by: Valentin Rodygin <[email protected]> * Set L1-fee scalars to zero in devnet --------- Co-authored-by: Valentin Rodygin <[email protected]>
…254) * OptimismPortal2 set initial `_balance` through StorageSetter pattern Fixes #239 The custom gas-token feature adaptation for the fault-proof system using the `OptimismPortal2` contract has been merged recently upstream. We are using the custom-gas-token feature and additionally require a modification of the OptimismPortal's `_balance` value to be set to the entire allocation of Celo on the L2 - meaning that all L1 token is initially locked in the bridge and only usable on the L2. Those changes are now adapted also to the `OptimismPortal2`, which was a requirement to make our custom-gas-token pre-locked balance feature work in conjunction with fault-proofs. * Adapt withdraw e2e-tests to work with fault-proofs * Use prettier for formatting e2e tests * Fix typo Co-authored-by: Valentin Rodygin <[email protected]> * Set L1-fee scalars to zero in devnet --------- Co-authored-by: Valentin Rodygin <[email protected]>
…254) * OptimismPortal2 set initial `_balance` through StorageSetter pattern Fixes #239 The custom gas-token feature adaptation for the fault-proof system using the `OptimismPortal2` contract has been merged recently upstream. We are using the custom-gas-token feature and additionally require a modification of the OptimismPortal's `_balance` value to be set to the entire allocation of Celo on the L2 - meaning that all L1 token is initially locked in the bridge and only usable on the L2. Those changes are now adapted also to the `OptimismPortal2`, which was a requirement to make our custom-gas-token pre-locked balance feature work in conjunction with fault-proofs. * Adapt withdraw e2e-tests to work with fault-proofs * Use prettier for formatting e2e tests * Fix typo Co-authored-by: Valentin Rodygin <[email protected]> * Set L1-fee scalars to zero in devnet --------- Co-authored-by: Valentin Rodygin <[email protected]>
Fixes #239
The custom gas-token feature adaptation for the fault-proof system using the
OptimismPortal2
contract has been merged recently upstream.We are using the custom-gas-token feature and additionally require a modification of the OptimismPortal's
_balance
value to be set to the entire allocation of Celo on the L2 - meaning that all L1 token is initially locked in the bridge and only usable on the L2.Those changes are now adapted also to the
OptimismPortal2
, which was a requirement to make our custom-gas-token pre-locked balance feature work in conjunction with fault-proofs.