@@ -79,7 +79,7 @@ describe('[Utils/Parse]', () => {
79
79
80
80
it ( 'should correctly parse deposit contract address' , async ( ) => {
81
81
// clone json out to not have side effects
82
- const customData = postMergeHardforkData
82
+ const customData = JSON . parse ( JSON . stringify ( postMergeHardforkData ) )
83
83
Object . assign ( customData . config , {
84
84
depositContractAddress : '0x4242424242424242424242424242424242424242' ,
85
85
} )
@@ -122,4 +122,137 @@ describe('[Utils/Parse]', () => {
122
122
- 1 ,
123
123
)
124
124
} )
125
+
126
+ it ( 'should assign correct blob schedule' , ( ) => {
127
+ // clone json out to not have side effects
128
+ const customData = JSON . parse ( JSON . stringify ( postMergeHardforkData ) )
129
+ const customConfigData = {
130
+ chainId : 3151908 ,
131
+ homesteadBlock : 0 ,
132
+ eip150Block : 0 ,
133
+ eip155Block : 0 ,
134
+ eip158Block : 0 ,
135
+ byzantiumBlock : 0 ,
136
+ constantinopleBlock : 0 ,
137
+ petersburgBlock : 0 ,
138
+ istanbulBlock : 0 ,
139
+ berlinBlock : 0 ,
140
+ londonBlock : 0 ,
141
+ mergeNetsplitBlock : 0 ,
142
+ depositContractAddress : '0x4242424242424242424242424242424242424242' ,
143
+ terminalTotalDifficulty : 0 ,
144
+ terminalTotalDifficultyPassed : true ,
145
+ shanghaiTime : 0 ,
146
+ cancunTime : 0 ,
147
+ blobSchedule : {
148
+ prague : {
149
+ target : 61 ,
150
+ max : 91 ,
151
+ baseFeeUpdateFraction : 13338477 ,
152
+ } ,
153
+ } ,
154
+ pragueTime : 1736942378 ,
155
+ }
156
+ Object . assign ( customData . config , customConfigData )
157
+
158
+ const common = createCommonFromGethGenesis ( customData , {
159
+ chain : 'customChain' ,
160
+ } )
161
+ const paramsTx = {
162
+ 4844 : {
163
+ blobCommitmentVersionKzg : 1 , // The number indicated a versioned hash is a KZG commitment
164
+ blobGasPerBlob : 131072 , // The base fee for blob gas per blob
165
+ maxBlobGasPerBlock : 786432 , // The max blob gas allowable per block
166
+ blobGasPriceUpdateFraction : 3338477 ,
167
+ targetBlobGasPerBlock : 393216 ,
168
+ } ,
169
+ 7691 : {
170
+ maxBlobGasPerBlock : 1179648 , // The max blob gas allowable per block
171
+ } ,
172
+ }
173
+ common . updateParams ( paramsTx )
174
+
175
+ const blobGasPerBlob = common . param ( 'blobGasPerBlob' )
176
+
177
+ const testCases = [
178
+ // should be picked from eip params
179
+ [ Hardfork . Cancun , blobGasPerBlob * BigInt ( 3 ) , blobGasPerBlob * BigInt ( 6 ) , 3338477n ] ,
180
+ // from the genesis blobschedule
181
+ [
182
+ Hardfork . Prague ,
183
+ blobGasPerBlob * BigInt ( customConfigData . blobSchedule . prague . target ) ,
184
+ blobGasPerBlob * BigInt ( customConfigData . blobSchedule . prague . max ) ,
185
+ 13338477 ,
186
+ ] ,
187
+ ]
188
+ for ( const [ testHf , testTarget , testMax , testUpdateFraction ] of testCases ) {
189
+ common . setHardfork ( testHf as Hardfork )
190
+
191
+ const targetBlobGasPerBlock = common . param ( 'targetBlobGasPerBlock' )
192
+ const maxBlobGasPerBlock = common . param ( 'maxBlobGasPerBlock' )
193
+ const blobGasPriceUpdateFraction = common . param ( 'blobGasPriceUpdateFraction' )
194
+
195
+ assert . equal ( targetBlobGasPerBlock , testTarget , 'target blob gas should match' )
196
+ assert . equal ( maxBlobGasPerBlock , testMax , 'max blob gas should match' )
197
+ assert . equal ( blobGasPriceUpdateFraction , testUpdateFraction , 'update fraction should match' )
198
+ }
199
+ } )
200
+
201
+ it ( 'should throw on invalid blob schedules' , ( ) => {
202
+ const customData = JSON . parse ( JSON . stringify ( postMergeHardforkData ) )
203
+ const customConfigData = {
204
+ chainId : 3151908 ,
205
+ homesteadBlock : 0 ,
206
+ eip150Block : 0 ,
207
+ eip155Block : 0 ,
208
+ eip158Block : 0 ,
209
+ byzantiumBlock : 0 ,
210
+ constantinopleBlock : 0 ,
211
+ petersburgBlock : 0 ,
212
+ istanbulBlock : 0 ,
213
+ berlinBlock : 0 ,
214
+ londonBlock : 0 ,
215
+ mergeNetsplitBlock : 0 ,
216
+ depositContractAddress : '0x4242424242424242424242424242424242424242' ,
217
+ terminalTotalDifficulty : 0 ,
218
+ terminalTotalDifficultyPassed : true ,
219
+ shanghaiTime : 0 ,
220
+ cancunTime : 0 ,
221
+ pragueTime : 1736942378 ,
222
+ blobSchedule : undefined ,
223
+ }
224
+ Object . assign ( customData . config , customConfigData )
225
+ const invalidBlobSchedules = [
226
+ {
227
+ prague : {
228
+ max : 91 ,
229
+ baseFeeUpdateFraction : 13338477 ,
230
+ } ,
231
+ } ,
232
+ {
233
+ prague : {
234
+ target : 61 ,
235
+ baseFeeUpdateFraction : 13338477 ,
236
+ } ,
237
+ } ,
238
+ {
239
+ prague : {
240
+ target : 61 ,
241
+ max : 91 ,
242
+ } ,
243
+ } ,
244
+ {
245
+ unknownHardfork : {
246
+ target : 61 ,
247
+ max : 91 ,
248
+ baseFeeUpdateFraction : 13338477 ,
249
+ } ,
250
+ } ,
251
+ ]
252
+
253
+ for ( const schedule of invalidBlobSchedules ) {
254
+ customData . config . blobSchedule = schedule
255
+ assert . throws ( ( ) => createCommonFromGethGenesis ( customData , { } ) )
256
+ }
257
+ } )
125
258
} )
0 commit comments