From e8c2f9d8498e94195493074e8b2137c4ef70d766 Mon Sep 17 00:00:00 2001 From: healthykim Date: Sat, 5 Jul 2025 13:17:48 +0200 Subject: [PATCH] feat: add config parameter --- eth/catalyst/api.go | 13 +++++++++---- miner/miner.go | 2 +- miner/prediction.go | 10 ++++------ params/config.go | 4 ++++ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index d681c5e798..b6ecc64dee 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -410,9 +410,15 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl // todo(healthykim) window / max value configuration // todo(healthykim) blob ID calculation logic -func (api *ConsensusAPI) NotifyPrediction(headBlockRoot common.Hash) (engine.PredictionResponse, error) { - max := uint(10) - window := uint(2) +func (api *ConsensusAPI) NotifyPrediction(headBlockRoot common.Hash, clMaxPredictionSize uint8) (engine.PredictionResponse, error) { + max := clMaxPredictionSize + if api.config().MaxPredictionSize != nil && max > *api.config().MaxPredictionSize { + max = *api.config().MaxPredictionSize + } + window := uint8(2) + if api.config().PredictionWindow != nil { + window = *api.config().PredictionWindow + } timestamp := uint64(time.Now().Unix()) random := rand.Int() buf := make([]byte, 8) @@ -612,7 +618,6 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo func (api *ConsensusAPI) GetBlobsToStage(id engine.PredictionID) ([]*engine.BlobPredictionToStage, error) { prediction := api.predictions.get(id) - log.Info("Finding prediction result for ", "id=", id) if prediction == nil { log.Error("There is no prediction with given id", "prediction id", id) diff --git a/miner/miner.go b/miner/miner.go index b852563fa8..60b30c3007 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -140,7 +140,7 @@ func (miner *Miner) BuildPayload(args *BuildPayloadArgs, witness bool) (*Payload } // BuildPayload builds the payload according to the provided parameters. -func (miner *Miner) PredictBlobTxs(blobId engine.PredictionID, max uint, window uint, timestamp uint64) (*BlobPrediction, error) { +func (miner *Miner) PredictBlobTxs(blobId engine.PredictionID, max uint8, window uint8, timestamp uint64) (*BlobPrediction, error) { return miner.predictBlobs(blobId, max, window, timestamp) } diff --git a/miner/prediction.go b/miner/prediction.go index c6e50af7c3..0dbf2b1dc1 100644 --- a/miner/prediction.go +++ b/miner/prediction.go @@ -67,7 +67,7 @@ func (prediction *BlobPrediction) Convert() []*engine.BlobPredictionToStage { // header: For gas fee calculation // [Main Difference from fillTransactions] // - No prio/normal transaction -func (miner *Miner) fillBlobs(blobId engine.PredictionID, max uint, W uint, timestamp uint64) ([]*types.Transaction, error) { +func (miner *Miner) fillBlobs(blobId engine.PredictionID, max uint8, W uint8, timestamp uint64) ([]*types.Transaction, error) { miner.confMu.RLock() tip := miner.config.GasPrice miner.confMu.RUnlock() @@ -117,7 +117,6 @@ func (miner *Miner) fillBlobs(blobId engine.PredictionID, max uint, W uint, time if len(pendingBlobTxs) > 0 { // Refer to newTransactionsByPriceAndNonce - // signer는 사용하지 않음 / 원래는 commitTransaction 넘겨주는용이지만 여기서는 무시 signer := types.MakeSigner(miner.chainConfig, parent.Number, parent.Time) blobTxs := newTransactionsByPriceAndNonce(signer, pendingBlobTxs, predictedBaseFee) for { @@ -140,7 +139,7 @@ func (miner *Miner) fillBlobs(blobId engine.PredictionID, max uint, W uint, time return res, nil } -func (miner *Miner) predictBlobs(blobId engine.PredictionID, max uint, W uint, timestamp uint64) (*BlobPrediction, error) { +func (miner *Miner) predictBlobs(blobId engine.PredictionID, max uint8, W uint8, timestamp uint64) (*BlobPrediction, error) { prediction := &BlobPrediction{ id: blobId, transaction: make([]*types.Transaction, 0, max), @@ -163,12 +162,11 @@ func (miner *Miner) predictBlobs(blobId engine.PredictionID, max uint, W uint, t prediction.lock.Lock() prediction.transaction = res prediction.lock.Unlock() - log.Info("Prediction result", "res", prediction) } else { - log.Info("Error while generating prediction", "id", prediction.id, "err", err) + log.Error("Error while generating prediction", "id", prediction.id, "err", err) } timer.Reset(miner.config.Recommit) - case <-prediction.stop: + case <-prediction.stop: //todo(healthykim) where log.Info("Stopping work on prediction", "id", prediction.id, "reason", "delivery") return case <-endTimer.C: diff --git a/params/config.go b/params/config.go index a64ee78bec..9d28c6a5a6 100644 --- a/params/config.go +++ b/params/config.go @@ -435,6 +435,10 @@ type ChainConfig struct { // those cases. EnableVerkleAtGenesis bool `json:"enableVerkleAtGenesis,omitempty"` + // Cell staging params + PredictionWindow *uint8 `json:"predictionWindow,omitempty"` + MaxPredictionSize *uint8 `json:"maxPredictionSize,omitempty"` + // Various consensus engines Ethash *EthashConfig `json:"ethash,omitempty"` Clique *CliqueConfig `json:"clique,omitempty"`