6
6
"math/big"
7
7
"testing"
8
8
9
+ "github.com/ethereum-optimism/optimism/op-service/predeploys"
9
10
"github.com/ethereum/go-ethereum/accounts/abi/bind"
10
11
"github.com/ethereum/go-ethereum/common"
11
12
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -15,15 +16,14 @@ import (
15
16
"github.com/stretchr/testify/require"
16
17
17
18
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
18
- "github.com/ethereum-optimism/optimism/op-bindings/predeploys"
19
19
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
20
20
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
21
21
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
22
22
"github.com/ethereum-optimism/optimism/op-service/testlog"
23
23
)
24
24
25
25
var (
26
- fjordGasPriceOracleCodeHash = common .HexToHash ("0x58e192326ee67ed52b7add91e4640024cbd1b21528a0ff1e1d21b7ca54e3ee62 " )
26
+ fjordGasPriceOracleCodeHash = common .HexToHash ("0xa88fa50a2745b15e6794247614b5298483070661adacb8d32d716434ed24c6b2 " )
27
27
// https://basescan.org/tx/0x8debb2fe54200183fb8baa3c6dbd8e6ec2e4f7a4add87416cd60336b8326d16a
28
28
txHex = "02f875822105819b8405709fb884057d460082e97f94273ca93a52b817294830ed7572aa591ccfa647fd80881249c58b0021fb3fc080a05bb08ccfd68f83392e446dac64d88a2d28e7072c06502dfabc4a77e77b5c7913a05878d53dd4ebba4f6367e572d524dffcabeec3abb1d8725ee3ac5dc32e1852e3"
29
29
)
@@ -32,16 +32,15 @@ func TestFjordNetworkUpgradeTransactions(gt *testing.T) {
32
32
t := NewDefaultTesting (gt )
33
33
dp := e2eutils .MakeDeployParams (t , defaultRollupTestParams )
34
34
genesisBlock := hexutil .Uint64 (0 )
35
- ecotoneOffset := hexutil .Uint64 (4 )
36
- fjordOffset := hexutil .Uint64 (8 )
35
+ fjordOffset := hexutil .Uint64 (2 )
37
36
38
37
dp .DeployConfig .L1CancunTimeOffset = & genesisBlock // can be removed once Cancun on L1 is the default
39
38
40
39
// Activate all forks at genesis, and schedule Fjord the block after
41
40
dp .DeployConfig .L2GenesisRegolithTimeOffset = & genesisBlock
42
41
dp .DeployConfig .L2GenesisCanyonTimeOffset = & genesisBlock
43
42
dp .DeployConfig .L2GenesisDeltaTimeOffset = & genesisBlock
44
- dp .DeployConfig .L2GenesisEcotoneTimeOffset = & ecotoneOffset
43
+ dp .DeployConfig .L2GenesisEcotoneTimeOffset = & genesisBlock
45
44
dp .DeployConfig .L2GenesisFjordTimeOffset = & fjordOffset
46
45
require .NoError (t , dp .DeployConfig .Check (), "must have valid config" )
47
46
@@ -50,10 +49,6 @@ func TestFjordNetworkUpgradeTransactions(gt *testing.T) {
50
49
_ , _ , _ , sequencer , engine , verifier , _ , _ := setupReorgTestActors (t , dp , sd , log )
51
50
ethCl := engine .EthClient ()
52
51
53
- // build a single block to move away from the genesis with 0-values in L1Block contract
54
- sequencer .ActL2StartBlock (t )
55
- sequencer .ActL2EndBlock (t )
56
-
57
52
// start op-nodes
58
53
sequencer .ActL2PipelineFull (t )
59
54
verifier .ActL2PipelineFull (t )
@@ -62,8 +57,6 @@ func TestFjordNetworkUpgradeTransactions(gt *testing.T) {
62
57
gasPriceOracle , err := bindings .NewGasPriceOracleCaller (predeploys .GasPriceOracleAddr , ethCl )
63
58
require .NoError (t , err )
64
59
65
- sequencer .ActBuildL2ToEcotone (t )
66
-
67
60
// Get current implementations addresses (by slot) for L1Block + GasPriceOracle
68
61
initialGasPriceOracleAddress , err := ethCl .StorageAt (context .Background (), predeploys .GasPriceOracleAddr , genesis .ImplementationSlot , nil )
69
62
require .NoError (t , err )
@@ -107,41 +100,31 @@ func TestFjordNetworkUpgradeTransactions(gt *testing.T) {
107
100
txData , err := hex .DecodeString (txHex )
108
101
require .NoError (t , err )
109
102
110
- l1GasUsed , err := gasPriceOracle .GetL1GasUsed (& bind.CallOpts {}, txData )
103
+ gpoL1GasUsed , err := gasPriceOracle .GetL1GasUsed (& bind.CallOpts {}, txData )
111
104
require .NoError (t , err )
112
- require .Equal (gt , uint64 (1_888 ), l1GasUsed .Uint64 ())
113
-
114
- fastLzSize := types .FlzCompressLen (txData )
105
+ require .Equal (gt , uint64 (1_888 ), gpoL1GasUsed .Uint64 ())
115
106
116
107
// Check that GetL1Fee takes into account fast LZ
117
- used , err := gasPriceOracle .GetL1Fee (& bind.CallOpts {}, txData )
108
+ gpoFee , err := gasPriceOracle .GetL1Fee (& bind.CallOpts {}, txData )
118
109
require .NoError (t , err )
119
110
120
- cost := fjordL1Cost (t , gasPriceOracle , int64 (fastLzSize ))
121
- require .Equal (t , cost .Uint64 (), used .Uint64 ())
111
+ gethFee := fjordL1Cost (t , gasPriceOracle , types.RollupCostData {
112
+ FastLzSize : uint64 (types .FlzCompressLen (txData ) + 68 ),
113
+ })
114
+ require .Equal (t , gethFee .Uint64 (), gpoFee .Uint64 ())
122
115
123
- // Check that L1FeeUppberBound works
116
+ // Check that L1FeeUpperBound works
124
117
upperBound , err := gasPriceOracle .GetL1FeeUpperBound (& bind.CallOpts {}, big .NewInt (int64 (len (txData ))))
125
118
require .NoError (t , err )
126
119
127
- flzUpperBound := len (txData ) + len (txData )/ 255 + 16
120
+ txLen := len (txData ) + 68
121
+ flzUpperBound := uint64 (txLen + txLen / 255 + 16 )
128
122
129
- upperBoundCost := fjordL1Cost (t , gasPriceOracle , int64 ( flzUpperBound ) )
123
+ upperBoundCost := fjordL1Cost (t , gasPriceOracle , types. RollupCostData { FastLzSize : flzUpperBound } )
130
124
require .Equal (t , upperBoundCost .Uint64 (), upperBound .Uint64 ())
131
125
}
132
126
133
- // The new cost function:
134
- // l1BaseFeeScaled = l1BaseFeeScalar * l1BaseFee * 16
135
- // l1BlobFeeScaled = l1BlobFeeScalar * l1BlobBaseFee
136
- // l1FeeScaled = l1BaseFeeScaled + l1BlobFeeScaled
137
- // ((intercept + fastlzCoef*max(fastlzLength, 100)) * l1FeeScaled) / 1e6
138
- func fjordL1Cost (
139
- t require.TestingT ,
140
- gasPriceOracle * bindings.GasPriceOracleCaller ,
141
- fastLzLength int64 ,
142
- ) * big.Int {
143
- fastLzLength = max (fastLzLength , types .MinTransactionSize .Int64 ())
144
-
127
+ func fjordL1Cost (t require.TestingT , gasPriceOracle * bindings.GasPriceOracleCaller , rollupCostData types.RollupCostData ) * big.Int {
145
128
baseFeeScalar , err := gasPriceOracle .BaseFeeScalar (nil )
146
129
require .NoError (t , err )
147
130
l1BaseFee , err := gasPriceOracle .L1BaseFee (nil )
@@ -151,16 +134,12 @@ func fjordL1Cost(
151
134
blobBaseFee , err := gasPriceOracle .BlobBaseFee (nil )
152
135
require .NoError (t , err )
153
136
154
- feeScaled := new (big.Int ).Mul (new (big.Int ).SetUint64 (uint64 (baseFeeScalar )), big .NewInt (16 ))
155
- feeScaled = new (big.Int ).Mul (feeScaled , l1BaseFee )
156
- feeScaled = new (big.Int ).Add (feeScaled , new (big.Int ).Mul (new (big.Int ).SetUint64 (uint64 (blobBaseFeeScalar )), blobBaseFee ))
157
-
158
- cost := new (big.Int ).Mul (types .L1CostFastlzCoef , new (big.Int ).SetInt64 (fastLzLength + 68 ))
159
- cost = new (big.Int ).Add (cost , types .L1CostIntercept )
160
- require .True (t , cost .Sign () >= 0 )
161
-
162
- cost = new (big.Int ).Mul (cost , feeScaled )
163
- cost = new (big.Int ).Div (cost , new (big.Int ).SetInt64 (int64 (1e12 )))
137
+ costFunc := types .NewL1CostFuncFjord (
138
+ l1BaseFee ,
139
+ blobBaseFee ,
140
+ new (big.Int ).SetUint64 (uint64 (baseFeeScalar )),
141
+ new (big.Int ).SetUint64 (uint64 (blobBaseFeeScalar )))
164
142
165
- return cost
143
+ fee , _ := costFunc (rollupCostData )
144
+ return fee
166
145
}
0 commit comments