-
Notifications
You must be signed in to change notification settings - Fork 3.9k
isthmus: operator fee #12166
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
Merged
Merged
isthmus: operator fee #12166
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
ec1f65a
feat: update IL1Block and info
leruaa 7ee2f7b
feat: update SystemConfig
leruaa 4661c21
feat: add operator fee vault
leruaa 7bf29ea
feat: handle transactions at Istmus activation
leruaa c17d6b8
feat: update GasPriceOracle
leruaa 92c569d
feat: update deployment
leruaa e04c261
chore: update snapshots and semvers
leruaa 39792e0
fix: GasPriceOracle nits
leruaa f7da141
fix: operator fee scalars ordering
leruaa 199fa59
fix: handle feedbacks
leruaa f1bcf76
feat: remove operator fee vault constructor arguments
leruaa df39131
chore: update e2e TestFees to handle operator fee
leruaa 4c2f410
chore: update snapshots
leruaa 5534e8c
fix: remove operator fee vault parameters on deployment
leruaa 8c19988
feat: handle overflow for operator fee in GasPriceOracle
leruaa 76bd899
chore: fee test
leruaa 4d09580
chore: add e2e test to ensure operator fee doesn't ends up minting or…
leruaa a56fa9b
fix: tests
leruaa 83cf6a2
chore: use operator fee OP Geth branch for CI
leruaa f1c4965
fix: tests
leruaa 96f21db
fix(op-node): ordering of network upgrade txs
refcell 766a1dd
fix: semver lock
refcell 0708f50
fix: sys config interop
refcell 5f92c81
fix: semver lock
refcell a538cd6
fix: arithmetic return args
refcell 5ea33cd
fix: semver lock
refcell 5c0ef79
update system config interop
refcell 65fc270
fix: sys config interop semver lock
refcell ff654d9
fix: trailing newline
refcell 770f4f9
chore: update tag
leruaa 466ba16
fix: point to Isthmus by default
leruaa d949d2c
fix: TestParseL1InfoDepositTxData
leruaa 50087c0
Update test to catch Alice balance underflow
teddyknox 033674b
fix: Test_Operator_Fee_Constistency
leruaa 48d238b
chore: update tag
leruaa 73bbfb7
fix: operator fee are nil in receipts if both are 0
leruaa bebef00
chore: set the correct op-geth tag
leruaa 600b80a
fix: handle sebastianst feedbacks
leruaa a08951c
fix: another round of feedbacks
leruaa ea03200
nit: useless cast
leruaa a6745a1
chore: remove beta in contract versions
leruaa 640be76
chore: more comments on contract versions
leruaa dbb6c36
fix semgrep
mslipper 77a53b9
preinstall compilers
mslipper d1d8b2a
schema
mslipper 205c5f1
indent
mslipper 129523f
add yes pipe
mslipper 9bcb3a6
ignore yes code
mslipper 27e1c59
try echo
mslipper 4486a1c
try wiping out the svm dir
mslipper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| package proofs | ||
|
|
||
| import ( | ||
| "math/big" | ||
| "testing" | ||
|
|
||
| actionsHelpers "github.com/ethereum-optimism/optimism/op-e2e/actions/helpers" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/actions/proofs/helpers" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/bindings" | ||
| "github.com/ethereum-optimism/optimism/op-program/client/claim" | ||
| "github.com/ethereum-optimism/optimism/op-service/predeploys" | ||
| "github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func Test_Operator_Fee_Constistency(gt *testing.T) { | ||
sebastianst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const testOperatorFeeScalar = uint32(20000) | ||
| const testOperatorFeeConstant = uint64(500) | ||
|
|
||
| runIsthmusDerivationTest := func(gt *testing.T, testCfg *helpers.TestCfg[any]) { | ||
| t := actionsHelpers.NewDefaultTesting(gt) | ||
|
|
||
| env := helpers.NewL2FaultProofEnv(t, testCfg, helpers.NewTestParams(), helpers.NewBatcherCfg()) | ||
|
|
||
| balanceAt := func(a common.Address) *big.Int { | ||
| t.Helper() | ||
| bal, err := env.Engine.EthClient().BalanceAt(t.Ctx(), a, nil) | ||
| require.NoError(t, err) | ||
| return bal | ||
| } | ||
|
|
||
| t.Logf("L2 Genesis Time: %d, IsthmusTime: %d ", env.Sequencer.RollupCfg.Genesis.L2Time, *env.Sequencer.RollupCfg.IsthmusTime) | ||
|
|
||
| sysCfgContract, err := bindings.NewSystemConfig(env.Sd.RollupCfg.L1SystemConfigAddress, env.Miner.EthClient()) | ||
| require.NoError(t, err) | ||
|
|
||
| sysCfgOwner, err := bind.NewKeyedTransactorWithChainID(env.Dp.Secrets.Deployer, env.Sd.RollupCfg.L1ChainID) | ||
| require.NoError(t, err) | ||
|
|
||
| // Update the operator fee parameters | ||
| _, err = sysCfgContract.SetOperatorFeeScalars(sysCfgOwner, testOperatorFeeScalar, testOperatorFeeConstant) | ||
| require.NoError(t, err) | ||
|
|
||
| env.Miner.ActL1StartBlock(12)(t) | ||
| env.Miner.ActL1IncludeTx(env.Dp.Addresses.Deployer)(t) | ||
| env.Miner.ActL1EndBlock(t) | ||
|
|
||
| // sequence L2 blocks, and submit with new batcher | ||
| env.Sequencer.ActL1HeadSignal(t) | ||
| env.Sequencer.ActBuildToL1Head(t) | ||
| env.Batcher.ActSubmitAll(t) | ||
| env.Miner.ActL1StartBlock(12)(t) | ||
| env.Miner.ActL1EndBlock(t) | ||
|
|
||
| aliceInitialBalance := balanceAt(env.Alice.Address()) | ||
| operatorFeeVaultInitialBalance := balanceAt(predeploys.OperatorFeeVaultAddr) | ||
|
|
||
| require.Equal(t, operatorFeeVaultInitialBalance.Sign(), 0) | ||
|
|
||
| env.Sequencer.ActL2StartBlock(t) | ||
| // Send an L2 tx | ||
| env.Alice.L2.ActResetTxOpts(t) | ||
| env.Alice.L2.ActSetTxToAddr(&env.Dp.Addresses.Bob) | ||
| env.Alice.L2.ActMakeTx(t) | ||
| env.Engine.ActL2IncludeTx(env.Alice.Address())(t) | ||
| env.Sequencer.ActL2EndBlock(t) | ||
|
|
||
| receipt := env.Alice.L2.LastTxReceipt(t) | ||
|
|
||
| // Check that the operator fee was applied | ||
| require.Equal(t, testOperatorFeeScalar, uint32(*receipt.OperatorFeeScalar)) | ||
| require.Equal(t, testOperatorFeeConstant, *receipt.OperatorFeeConstant) | ||
|
|
||
| l1FeeVaultBalance := balanceAt(predeploys.L1FeeVaultAddr) | ||
| baseFeeVaultBalance := balanceAt(predeploys.BaseFeeVaultAddr) | ||
| sequencerFeeVaultBalance := balanceAt(predeploys.SequencerFeeVaultAddr) | ||
| operatorFeeVaultFinalBalance := balanceAt(predeploys.OperatorFeeVaultAddr) | ||
| aliceFinalBalance := balanceAt(env.Alice.Address()) | ||
|
|
||
| require.True(t, aliceFinalBalance.Cmp(aliceInitialBalance) < 0, "Alice's balance should decrease") | ||
|
|
||
| // Check that the operator fee sent to the vault is correct | ||
| require.Equal(t, | ||
| new(big.Int).Add( | ||
| new(big.Int).Div( | ||
| new(big.Int).Mul( | ||
| new(big.Int).SetUint64(receipt.GasUsed), | ||
| new(big.Int).SetUint64(uint64(testOperatorFeeScalar)), | ||
| ), | ||
| new(big.Int).SetUint64(1e6), | ||
| ), | ||
| new(big.Int).SetUint64(testOperatorFeeConstant), | ||
| ), | ||
| operatorFeeVaultFinalBalance, | ||
| ) | ||
|
|
||
| // Check that no Ether has been minted or burned | ||
| // All vault balances are 0 at the beginning of the test | ||
| finalTotalBalance := new(big.Int).Add( | ||
| aliceFinalBalance, | ||
| new(big.Int).Add( | ||
| new(big.Int).Add(l1FeeVaultBalance, sequencerFeeVaultBalance), | ||
| new(big.Int).Add(operatorFeeVaultFinalBalance, baseFeeVaultBalance), | ||
| ), | ||
| ) | ||
|
|
||
| require.Equal(t, aliceInitialBalance, finalTotalBalance) | ||
|
|
||
| l2SafeHead := env.Sequencer.L2Safe() | ||
|
|
||
| env.RunFaultProofProgram(t, l2SafeHead.Number, testCfg.CheckResult, testCfg.InputParams...) | ||
| } | ||
|
|
||
| matrix := helpers.NewMatrix[any]() | ||
| defer matrix.Run(gt) | ||
|
|
||
| matrix.AddTestCase( | ||
| "HonestClaim-OperatorFeeConstistency", | ||
| nil, | ||
| helpers.NewForkMatrix(helpers.Isthmus), | ||
| runIsthmusDerivationTest, | ||
| helpers.ExpectNoError(), | ||
| ) | ||
|
|
||
| matrix.AddTestCase( | ||
| "JunkClaim-OperatorFeeConstistency", | ||
| nil, | ||
| helpers.NewForkMatrix(helpers.Isthmus), | ||
| runIsthmusDerivationTest, | ||
| helpers.ExpectError(claim.ErrClaimNotValid), | ||
| helpers.WithL2Claim(common.HexToHash("0xdeadbeef")), | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.