@@ -127,3 +127,56 @@ func TestFakeExponential(t *testing.T) {
127
127
}
128
128
}
129
129
}
130
+
131
+ func TestCalcExcessBlobGasEIP7918 (t * testing.T ) {
132
+ // TODO: replace with a test config that has Osaka enabled.
133
+ c := * params .MainnetChainConfig
134
+ cfg := & c
135
+ cfg .OsakaTime = new (uint64 )
136
+ pragueSchedule := * cfg .BlobScheduleConfig .Prague
137
+ cfg .BlobScheduleConfig .Osaka = & pragueSchedule
138
+
139
+ var (
140
+ targetBlobs = targetBlobsPerBlock (cfg , * cfg .CancunTime )
141
+ blobGasPerBlob = uint64 (params .BlobTxBlobGasPerBlob )
142
+ blobGasTarget = uint64 (targetBlobs ) * blobGasPerBlob
143
+ )
144
+
145
+ makeHeader := func (
146
+ parentExcess uint64 ,
147
+ parentBaseFee uint64 ,
148
+ blobsUsed int ,
149
+ ) * types.Header {
150
+ blobGasUsed := uint64 (blobsUsed ) * blobGasPerBlob
151
+ return & types.Header {
152
+ BaseFee : big .NewInt (int64 (parentBaseFee )),
153
+ ExcessBlobGas : & parentExcess ,
154
+ BlobGasUsed : & blobGasUsed ,
155
+ }
156
+ }
157
+
158
+ tests := []struct {
159
+ name string
160
+ header * types.Header
161
+ wantExcessGas uint64
162
+ }{
163
+ {
164
+ name : "BelowReservePrice" ,
165
+ header : makeHeader (0 , 1_000_000_000 , targetBlobs ),
166
+ wantExcessGas : blobGasTarget * 3 / 9 ,
167
+ },
168
+ {
169
+ name : "AboveReservePrice" ,
170
+ header : makeHeader (0 , 1 , targetBlobs ),
171
+ wantExcessGas : 0 ,
172
+ },
173
+ }
174
+
175
+ for _ , tc := range tests {
176
+ got := CalcExcessBlobGas (cfg , tc .header , * cfg .CancunTime )
177
+ if got != tc .wantExcessGas {
178
+ t .Fatalf ("%s: excess-blob-gas mismatch – have %d, want %d" ,
179
+ tc .name , got , tc .wantExcessGas )
180
+ }
181
+ }
182
+ }
0 commit comments