feat: add config parameter

This commit is contained in:
healthykim 2025-07-05 13:17:48 +02:00
parent a544ca1ec1
commit e8c2f9d849
4 changed files with 18 additions and 11 deletions

View file

@ -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)

View file

@ -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)
}

View file

@ -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:

View file

@ -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"`