mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
feat: add config parameter
This commit is contained in:
parent
a544ca1ec1
commit
e8c2f9d849
4 changed files with 18 additions and 11 deletions
|
|
@ -410,9 +410,15 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
|
||||||
|
|
||||||
// todo(healthykim) window / max value configuration
|
// todo(healthykim) window / max value configuration
|
||||||
// todo(healthykim) blob ID calculation logic
|
// todo(healthykim) blob ID calculation logic
|
||||||
func (api *ConsensusAPI) NotifyPrediction(headBlockRoot common.Hash) (engine.PredictionResponse, error) {
|
func (api *ConsensusAPI) NotifyPrediction(headBlockRoot common.Hash, clMaxPredictionSize uint8) (engine.PredictionResponse, error) {
|
||||||
max := uint(10)
|
max := clMaxPredictionSize
|
||||||
window := uint(2)
|
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())
|
timestamp := uint64(time.Now().Unix())
|
||||||
random := rand.Int()
|
random := rand.Int()
|
||||||
buf := make([]byte, 8)
|
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) {
|
func (api *ConsensusAPI) GetBlobsToStage(id engine.PredictionID) ([]*engine.BlobPredictionToStage, error) {
|
||||||
|
|
||||||
prediction := api.predictions.get(id)
|
prediction := api.predictions.get(id)
|
||||||
log.Info("Finding prediction result for ", "id=", id)
|
|
||||||
|
|
||||||
if prediction == nil {
|
if prediction == nil {
|
||||||
log.Error("There is no prediction with given id", "prediction id", id)
|
log.Error("There is no prediction with given id", "prediction id", id)
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ func (miner *Miner) BuildPayload(args *BuildPayloadArgs, witness bool) (*Payload
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildPayload builds the payload according to the provided parameters.
|
// 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)
|
return miner.predictBlobs(blobId, max, window, timestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func (prediction *BlobPrediction) Convert() []*engine.BlobPredictionToStage {
|
||||||
// header: For gas fee calculation
|
// header: For gas fee calculation
|
||||||
// [Main Difference from fillTransactions]
|
// [Main Difference from fillTransactions]
|
||||||
// - No prio/normal transaction
|
// - 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()
|
miner.confMu.RLock()
|
||||||
tip := miner.config.GasPrice
|
tip := miner.config.GasPrice
|
||||||
miner.confMu.RUnlock()
|
miner.confMu.RUnlock()
|
||||||
|
|
@ -117,7 +117,6 @@ func (miner *Miner) fillBlobs(blobId engine.PredictionID, max uint, W uint, time
|
||||||
|
|
||||||
if len(pendingBlobTxs) > 0 {
|
if len(pendingBlobTxs) > 0 {
|
||||||
// Refer to newTransactionsByPriceAndNonce
|
// Refer to newTransactionsByPriceAndNonce
|
||||||
// signer는 사용하지 않음 / 원래는 commitTransaction 넘겨주는용이지만 여기서는 무시
|
|
||||||
signer := types.MakeSigner(miner.chainConfig, parent.Number, parent.Time)
|
signer := types.MakeSigner(miner.chainConfig, parent.Number, parent.Time)
|
||||||
blobTxs := newTransactionsByPriceAndNonce(signer, pendingBlobTxs, predictedBaseFee)
|
blobTxs := newTransactionsByPriceAndNonce(signer, pendingBlobTxs, predictedBaseFee)
|
||||||
for {
|
for {
|
||||||
|
|
@ -140,7 +139,7 @@ func (miner *Miner) fillBlobs(blobId engine.PredictionID, max uint, W uint, time
|
||||||
return res, nil
|
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{
|
prediction := &BlobPrediction{
|
||||||
id: blobId,
|
id: blobId,
|
||||||
transaction: make([]*types.Transaction, 0, max),
|
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.lock.Lock()
|
||||||
prediction.transaction = res
|
prediction.transaction = res
|
||||||
prediction.lock.Unlock()
|
prediction.lock.Unlock()
|
||||||
log.Info("Prediction result", "res", prediction)
|
|
||||||
} else {
|
} 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)
|
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")
|
log.Info("Stopping work on prediction", "id", prediction.id, "reason", "delivery")
|
||||||
return
|
return
|
||||||
case <-endTimer.C:
|
case <-endTimer.C:
|
||||||
|
|
|
||||||
|
|
@ -435,6 +435,10 @@ type ChainConfig struct {
|
||||||
// those cases.
|
// those cases.
|
||||||
EnableVerkleAtGenesis bool `json:"enableVerkleAtGenesis,omitempty"`
|
EnableVerkleAtGenesis bool `json:"enableVerkleAtGenesis,omitempty"`
|
||||||
|
|
||||||
|
// Cell staging params
|
||||||
|
PredictionWindow *uint8 `json:"predictionWindow,omitempty"`
|
||||||
|
MaxPredictionSize *uint8 `json:"maxPredictionSize,omitempty"`
|
||||||
|
|
||||||
// Various consensus engines
|
// Various consensus engines
|
||||||
Ethash *EthashConfig `json:"ethash,omitempty"`
|
Ethash *EthashConfig `json:"ethash,omitempty"`
|
||||||
Clique *CliqueConfig `json:"clique,omitempty"`
|
Clique *CliqueConfig `json:"clique,omitempty"`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue