Skip to content

Commit 7c4cb3a

Browse files
fakedev9999leruaageoknee
authored
jovian: operator fee fix (#764)
* fix!: multiply operatorFeeScalar by 100 instead of dividing by 1e6 * chore: move under jovian specs * fix: handle feedbacks * feat: add upgrade tx specs * fix: typo * fix: lints * lint --------- Co-authored-by: leruaa <aurelien.catinon@gmail.com> Co-authored-by: geoknee <georgeknee@googlemail.com>
1 parent b946da5 commit 7c4cb3a

File tree

4 files changed

+147
-0
lines changed

4 files changed

+147
-0
lines changed

specs/protocol/jovian/derivation.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
- [Network Upgrade Transactions](#network-upgrade-transactions)
99
- [L1Block Deployment](#l1block-deployment)
1010
- [L1Block Proxy Update](#l1block-proxy-update)
11+
- [GasPriceOracle Deployment](#gaspriceoracle-deployment)
12+
- [GasPriceOracle Proxy Update](#gaspriceoracle-proxy-update)
13+
- [GasPriceOracle Enable Jovian](#gaspriceoracle-enable-jovian)
1114

1215
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1316

@@ -125,3 +128,117 @@ Verify `sourceHash`:
125128
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Jovian: L1Block Proxy Update"))
126129
# 0x08447273a4fbce97bc8c515f97ac74efc461f6a4001553712f31ebc11288bad2
127130
```
131+
132+
### GasPriceOracle Deployment
133+
<!-- Generated with: ./scripts/run_gen_predeploy_docs.sh --optimism-repo-path ../optimism
134+
--fork-name Jovian --contract-name GasPriceOracle --from-address 0x4210000000000000000000000000000000000006
135+
--from-address-nonce 0 --git-commit-hash 134edb32991f408a3354caf3de8a68145437cfc9
136+
--eth-rpc-url https://optimism.rpc.subquery.network/public
137+
--proxy-address 0x420000000000000000000000000000000000000F --copy-contract-bytecode true -->
138+
139+
The `GasPriceOracle` contract is deployed.
140+
141+
A deposit transaction is derived with the following attributes:
142+
143+
- `from`: `0x4210000000000000000000000000000000000006`
144+
- `to`: `null`
145+
- `mint`: `0`
146+
- `value`: `0`
147+
- `nonce`: `0`
148+
- `gasLimit`: `1756783`
149+
- `data`: `0x0x608060405234801561001057600080...` ([full bytecode](../../../specs/static/bytecode/jovian-gas-price-oracle-deployment.txt))
150+
- `sourceHash`: `0xd939cca6eca7bd0ee0c7e89f7e5b5cf7bf6f7afe7b6966bb45dfb95344b31545`,
151+
computed with the "Upgrade-deposited" type, with `intent = "Jovian: GasPriceOracle Deployment"`
152+
153+
This results in the Jovian GasPriceOracle contract being deployed to
154+
`0x3Ba4007f5C922FBb33C454B41ea7a1f11E83df2C`, to verify:
155+
156+
```bash
157+
cast compute-address --nonce=0 0x4210000000000000000000000000000000000006
158+
Computed Address: 0x3Ba4007f5C922FBb33C454B41ea7a1f11E83df2C
159+
```
160+
161+
Verify `sourceHash`:
162+
163+
```bash
164+
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Jovian: GasPriceOracle Deployment"))
165+
# 0xd939cca6eca7bd0ee0c7e89f7e5b5cf7bf6f7afe7b6966bb45dfb95344b31545
166+
```
167+
168+
Verify `data`:
169+
170+
```bash
171+
git checkout 134edb32991f408a3354caf3de8a68145437cfc9
172+
make build-contracts
173+
jq -r ".bytecode.object" packages/contracts-bedrock/forge-artifacts/GasPriceOracle.sol/GasPriceOracle.json
174+
```
175+
176+
This transaction MUST deploy a contract with the following code hash
177+
`0xa7fd95526766fc3ba40ed64aa1b55ad051cb2930df64e11c4a848b81d3a8deaf`.
178+
179+
To verify the code hash:
180+
181+
```bash
182+
git checkout 134edb32991f408a3354caf3de8a68145437cfc9
183+
make build-contracts
184+
cast k $(jq -r ".deployedBytecode.object" packages/contracts-bedrock/forge-artifacts/GasPriceOracle.sol/GasPriceOracle.json)
185+
```
186+
187+
### GasPriceOracle Proxy Update
188+
189+
This transaction updates the GasPriceOracle Proxy ERC-1967
190+
implementation slot to point to the new GasPriceOracle deployment.
191+
192+
A deposit transaction is derived with the following attributes:
193+
194+
- `from`: `0x0000000000000000000000000000000000000000`
195+
- `to`: `0x420000000000000000000000000000000000000F` (GasPriceOracle Proxy)
196+
- `mint`: `0`
197+
- `value`: `0`
198+
- `gasLimit`: `50,000`
199+
- `data`: `0x3659cfe60000000000000000000000003ba4007f5c922fbb33c454b41ea7a1f11e83df2c`
200+
- `sourceHash`: `0x46b597e2d8346ed7749b46734074361e0b41a0ab9af7afda5bb4e367e072bcb8`
201+
computed with the "Upgrade-deposited" type, with `intent = "Jovian: GasPriceOracle Proxy Update"`
202+
203+
Verify data:
204+
205+
```bash
206+
cast concat-hex $(cast sig "upgradeTo(address)") $(cast abi-encode "upgradeTo(address)" 0x3Ba4007f5C922FBb33C454B41ea7a1f11E83df2C)
207+
# 0x3659cfe60000000000000000000000003ba4007f5c922fbb33c454b41ea7a1f11e83df2c
208+
```
209+
210+
Verify `sourceHash`:
211+
212+
```bash
213+
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Jovian: GasPriceOracle Proxy Update"))
214+
# 0x46b597e2d8346ed7749b46734074361e0b41a0ab9af7afda5bb4e367e072bcb8
215+
```
216+
217+
### GasPriceOracle Enable Jovian
218+
219+
This transaction informs the GasPriceOracle to start using the Jovian operator fee formula.
220+
221+
A deposit transaction is derived with the following attributes:
222+
223+
- `from`: `0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001` (Depositer Account)
224+
- `to`: `0x420000000000000000000000000000000000000F` (Gas Price Oracle Proxy)
225+
- `mint`: `0`
226+
- `value`: `0`
227+
- `gasLimit`: `90,000`
228+
- `data`: `0xb3d72079`
229+
- `sourceHash`: `0xe836db6a959371756f8941be3e962d000f7e12a32e49e2c9ca42ba177a92716c`,
230+
computed with the "Upgrade-deposited" type, with `intent = "Jovian: Gas Price Oracle Set Jovian"`
231+
232+
Verify data:
233+
234+
```bash
235+
cast sig "setJovian()"
236+
# 0xb3d72079
237+
```
238+
239+
Verify `sourceHash`:
240+
241+
```bash
242+
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Jovian: Gas Price Oracle Set Jovian"))
243+
# 0xe836db6a959371756f8941be3e962d000f7e12a32e49e2c9ca42ba177a92716c
244+
```

specs/protocol/jovian/exec-engine.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
- [DA Footprint Block Limit](#da-footprint-block-limit)
1212
- [Scalar loading](#scalar-loading)
1313
- [Rationale](#rationale-1)
14+
- [Operator Fee](#operator-fee)
15+
- [Fee Formula Update](#fee-formula-update)
16+
- [Maximum value](#maximum-value)
1417

1518
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1619

@@ -148,3 +151,28 @@ throttling: a mechanism which artificially constricts block building. This can c
148151
unnecessary losses for chain operators and a negative user experience (transaction inclusion delays, priority fee
149152
auctions). So hard-limiting a block's DA footprint in a way that also influences the base fee mitigates the
150153
aforementioned problems of policy-based solutions.
154+
155+
## Operator Fee
156+
157+
### Fee Formula Update
158+
159+
Jovian updates the operator fee calculation so that higher fees may be charged.
160+
Starting at the Jovian activation, the operator fee MUST be computed as:
161+
162+
$$
163+
\text{operatorFee} = (\text{gas} \times \text{operatorFeeScalar} \times 100) + \text{operatorFeeConstant}
164+
$$
165+
166+
The effective per-gas scalar applied is therefore `100 * operatorFeeScalar`. Otherwise, the data types and operator fee
167+
semantics described in the [Isthmus spec](../isthmus/exec-engine.md#operator-fee) continue to apply.
168+
169+
### Maximum value
170+
171+
With the new formula, the operator fee's maximum value has 103 bits:
172+
173+
$$
174+
\text{operatorFee}_{\text{max}} = (\text{uint64}_{\text{max}} \times \text{uint32}_{\text{max}} \times 100) +
175+
\text{uint64}_{\text{max}} \approx 7.924660923989131 \times 10^{30}
176+
$$
177+
178+
Implementations that use `uint256` for intermediate arithmetic do not need additional overflow checks.

specs/protocol/jovian/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This document is not finalized and should be considered experimental.
1616

1717
- [Minimum Base Fee](./exec-engine.md#minimum-base-fee)
1818
- [DA Footprint Limit](./exec-engine.md#da-footprint-limit)
19+
- [Operator Fee](./exec-engine.md#operator-fee)
1920

2021
## Consensus Layer
2122

0 commit comments

Comments
 (0)