Skip to content

Commit a77f141

Browse files
authored
chore(gas-oracle): remove unused code (#1644)
1 parent 5b62692 commit a77f141

File tree

7 files changed

+8
-69
lines changed

7 files changed

+8
-69
lines changed

common/types/db.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ const (
276276
SenderTypeFinalizeBatch
277277
// SenderTypeL1GasOracle indicates a sender from L2 responsible for updating L1 gas prices.
278278
SenderTypeL1GasOracle
279-
// SenderTypeL2GasOracle indicates a sender from L1 responsible for updating L2 gas prices.
280-
SenderTypeL2GasOracle
279+
// SenderTypeL2GasOracleDeprecated indicates a sender from L1 responsible for updating L2 gas prices, which is deprecated.
280+
SenderTypeL2GasOracleDeprecated
281281
)
282282

283283
// String returns a string representation of the SenderType.
@@ -289,8 +289,8 @@ func (t SenderType) String() string {
289289
return "SenderTypeFinalizeBatch"
290290
case SenderTypeL1GasOracle:
291291
return "SenderTypeL1GasOracle"
292-
case SenderTypeL2GasOracle:
293-
return "SenderTypeL2GasOracle"
292+
case SenderTypeL2GasOracleDeprecated:
293+
return "SenderTypeL2GasOracleDeprecated"
294294
default:
295295
return fmt.Sprintf("Unknown SenderType (%d)", int32(t))
296296
}

common/types/db_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ func TestSenderType(t *testing.T) {
173173
"SenderTypeL1GasOracle",
174174
},
175175
{
176-
"SenderTypeL2GasOracle",
177-
SenderTypeL2GasOracle,
178-
"SenderTypeL2GasOracle",
176+
"SenderTypeL2GasOracleDeprecated",
177+
SenderTypeL2GasOracleDeprecated,
178+
"SenderTypeL2GasOracleDeprecated",
179179
},
180180
{
181181
"Invalid Value",

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.5.3"
8+
var tag = "v4.5.4"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

rollup/internal/controller/relayer/l2_relayer.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -930,22 +930,6 @@ func (r *Layer2Relayer) handleConfirmation(cfm *sender.Confirmation) {
930930
if err != nil {
931931
log.Warn("UpdateFinalizeTxHashAndRollupStatus failed", "confirmation", cfm, "err", err)
932932
}
933-
case types.SenderTypeL2GasOracle:
934-
batchHash := cfm.ContextID
935-
var status types.GasOracleStatus
936-
if cfm.IsSuccessful {
937-
status = types.GasOracleImported
938-
r.metrics.rollupL2UpdateGasOracleConfirmedTotal.Inc()
939-
} else {
940-
status = types.GasOracleImportedFailed
941-
r.metrics.rollupL2UpdateGasOracleConfirmedFailedTotal.Inc()
942-
log.Warn("UpdateGasOracleTxType transaction confirmed but failed in layer1", "confirmation", cfm)
943-
}
944-
945-
err := r.batchOrm.UpdateL2GasOracleStatusAndOracleTxHash(r.ctx, batchHash, status, cfm.TxHash.String())
946-
if err != nil {
947-
log.Warn("UpdateL2GasOracleStatusAndOracleTxHash failed", "confirmation", cfm, "err", err)
948-
}
949933
default:
950934
log.Warn("Unknown transaction type", "confirmation", cfm)
951935
}

rollup/internal/controller/relayer/l2_relayer_metrics.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ type l2RelayerMetrics struct {
1212
rollupL2RelayerProcessPendingBatchTotal prometheus.Counter
1313
rollupL2RelayerProcessPendingBatchSuccessTotal prometheus.Counter
1414
rollupL2RelayerProcessPendingBatchErrTooManyPendingBlobTxsTotal prometheus.Counter
15-
rollupL2RelayerGasPriceOraclerRunTotal prometheus.Counter
16-
rollupL2RelayerLastGasPrice prometheus.Gauge
1715
rollupL2BatchesCommittedConfirmedTotal prometheus.Counter
1816
rollupL2BatchesCommittedConfirmedFailedTotal prometheus.Counter
1917
rollupL2BatchesFinalizedConfirmedTotal prometheus.Counter
2018
rollupL2BatchesFinalizedConfirmedFailedTotal prometheus.Counter
21-
rollupL2UpdateGasOracleConfirmedTotal prometheus.Counter
22-
rollupL2UpdateGasOracleConfirmedFailedTotal prometheus.Counter
2319
rollupL2ChainMonitorLatestFailedCall prometheus.Counter
2420
rollupL2ChainMonitorLatestFailedBatchStatus prometheus.Counter
2521
rollupL2RelayerProcessPendingBundlesTotal prometheus.Counter
@@ -56,14 +52,6 @@ func initL2RelayerMetrics(reg prometheus.Registerer) *l2RelayerMetrics {
5652
Name: "rollup_layer2_process_pending_batch_err_too_many_pending_blob_txs_total",
5753
Help: "The total number of layer2 process pending batch failed on too many pending blob txs",
5854
}),
59-
rollupL2RelayerGasPriceOraclerRunTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{
60-
Name: "rollup_layer2_gas_price_oracler_total",
61-
Help: "The total number of layer2 gas price oracler run total",
62-
}),
63-
rollupL2RelayerLastGasPrice: promauto.With(reg).NewGauge(prometheus.GaugeOpts{
64-
Name: "rollup_layer2_gas_price_latest_gas_price",
65-
Help: "The latest gas price of rollup relayer l2",
66-
}),
6755
rollupL2BatchesCommittedConfirmedTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{
6856
Name: "rollup_layer2_process_committed_batches_confirmed_total",
6957
Help: "The total number of layer2 process committed batches confirmed total",
@@ -80,14 +68,6 @@ func initL2RelayerMetrics(reg prometheus.Registerer) *l2RelayerMetrics {
8068
Name: "rollup_layer2_process_finalized_batches_confirmed_failed_total",
8169
Help: "The total number of layer2 process finalized batches confirmed failed total",
8270
}),
83-
rollupL2UpdateGasOracleConfirmedTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{
84-
Name: "rollup_layer2_update_layer1_gas_oracle_confirmed_total",
85-
Help: "The total number of updating layer2 gas oracle confirmed",
86-
}),
87-
rollupL2UpdateGasOracleConfirmedFailedTotal: promauto.With(reg).NewCounter(prometheus.CounterOpts{
88-
Name: "rollup_layer2_update_layer1_gas_oracle_confirmed_failed_total",
89-
Help: "The total number of updating layer2 gas oracle confirmed failed",
90-
}),
9171
rollupL2ChainMonitorLatestFailedCall: promauto.With(reg).NewCounter(prometheus.CounterOpts{
9272
Name: "rollup_layer2_chain_monitor_latest_failed_batch_call",
9373
Help: "The total number of failed call chain_monitor api",

rollup/internal/orm/batch.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ type Batch struct {
5656
FinalizeTxHash string `json:"finalize_tx_hash" gorm:"column:finalize_tx_hash;default:NULL"`
5757
FinalizedAt *time.Time `json:"finalized_at" gorm:"column:finalized_at;default:NULL"`
5858

59-
// gas oracle
60-
OracleStatus int16 `json:"oracle_status" gorm:"column:oracle_status;default:1"`
61-
OracleTxHash string `json:"oracle_tx_hash" gorm:"column:oracle_tx_hash;default:NULL"`
62-
6359
// blob
6460
BlobDataProof []byte `json:"blob_data_proof" gorm:"column:blob_data_proof"`
6561
BlobSize uint64 `json:"blob_size" gorm:"column:blob_size"`
@@ -310,7 +306,6 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, codecVer
310306
ChunkProofsStatus: int16(types.ChunkProofsStatusPending),
311307
ProvingStatus: int16(types.ProvingTaskUnassigned),
312308
RollupStatus: int16(types.RollupPending),
313-
OracleStatus: int16(types.GasOraclePending),
314309
TotalL1CommitGas: metrics.L1CommitGas,
315310
TotalL1CommitCalldataSize: metrics.L1CommitCalldataSize,
316311
BlobDataProof: batchMeta.BatchBlobDataProof,
@@ -331,22 +326,6 @@ func (o *Batch) InsertBatch(ctx context.Context, batch *encoding.Batch, codecVer
331326
return &newBatch, nil
332327
}
333328

334-
// UpdateL2GasOracleStatusAndOracleTxHash updates the L2 gas oracle status and transaction hash for a batch.
335-
func (o *Batch) UpdateL2GasOracleStatusAndOracleTxHash(ctx context.Context, hash string, status types.GasOracleStatus, txHash string) error {
336-
updateFields := make(map[string]interface{})
337-
updateFields["oracle_status"] = int(status)
338-
updateFields["oracle_tx_hash"] = txHash
339-
340-
db := o.db.WithContext(ctx)
341-
db = db.Model(&Batch{})
342-
db = db.Where("hash", hash)
343-
344-
if err := db.Updates(updateFields).Error; err != nil {
345-
return fmt.Errorf("Batch.UpdateL2GasOracleStatusAndOracleTxHash error: %w, batch hash: %v, status: %v, txHash: %v", err, hash, status.String(), txHash)
346-
}
347-
return nil
348-
}
349-
350329
// UpdateProvingStatus updates the proving status of a batch.
351330
func (o *Batch) UpdateProvingStatus(ctx context.Context, hash string, status types.ProvingStatus, dbTX ...*gorm.DB) error {
352331
updateFields := make(map[string]interface{})

rollup/internal/orm/orm_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,12 @@ func TestBatchOrm(t *testing.T) {
300300
assert.NoError(t, err)
301301
err = batchOrm.UpdateRollupStatus(context.Background(), batchHash2, types.RollupFinalized)
302302
assert.NoError(t, err)
303-
err = batchOrm.UpdateL2GasOracleStatusAndOracleTxHash(context.Background(), batchHash2, types.GasOracleImported, "oracleTxHash")
304-
assert.NoError(t, err)
305303

306304
updatedBatch, err := batchOrm.GetLatestBatch(context.Background())
307305
assert.NoError(t, err)
308306
assert.NotNil(t, updatedBatch)
309307
assert.Equal(t, types.ProvingTaskVerified, types.ProvingStatus(updatedBatch.ProvingStatus))
310308
assert.Equal(t, types.RollupFinalized, types.RollupStatus(updatedBatch.RollupStatus))
311-
assert.Equal(t, types.GasOracleImported, types.GasOracleStatus(updatedBatch.OracleStatus))
312-
assert.Equal(t, "oracleTxHash", updatedBatch.OracleTxHash)
313309

314310
err = batchOrm.UpdateCommitTxHashAndRollupStatus(context.Background(), batchHash1, "commitTxHash", types.RollupCommitted)
315311
assert.NoError(t, err)

0 commit comments

Comments
 (0)