diff --git a/eventcheck/epochcheck/epoch_check.go b/eventcheck/epochcheck/epoch_check.go index a4b51d7f7..4614ab8a0 100644 --- a/eventcheck/epochcheck/epoch_check.go +++ b/eventcheck/epochcheck/epoch_check.go @@ -72,6 +72,8 @@ func CalcGasPowerUsed(e inter.EventPayloadI, rules opera.Rules) uint64 { } func (v *Checker) checkGas(e inter.EventPayloadI, rules opera.Rules) error { + // do not check gas + return nil if e.GasPowerUsed() > rules.Economy.Gas.MaxEventGas { return ErrTooBigGasUsed } diff --git a/gossip/emitter/control.go b/gossip/emitter/control.go index c19518bff..545af4ddb 100644 --- a/gossip/emitter/control.go +++ b/gossip/emitter/control.go @@ -132,7 +132,7 @@ func (em *Emitter) isAllowedToEmit(e inter.EventI, eTxs bool, metric ancestor.Me factor := float64(e.GasPowerLeft().Min()) / float64(threshold) adjustedEmitInterval := time.Duration(maxT - (maxT-minT)*factor) if passedTime < adjustedEmitInterval { - return false + return true } } } @@ -156,7 +156,7 @@ func (em *Emitter) isAllowedToEmit(e inter.EventI, eTxs bool, metric ancestor.Me if adjustedPassedIdleTime < em.intervals.Confirming && !em.idle() && !eTxs { - return false + return true } } // only allow top validators diff --git a/gossip/emitter/hooks.go b/gossip/emitter/hooks.go index 974cc3ddd..ed10814fe 100644 --- a/gossip/emitter/hooks.go +++ b/gossip/emitter/hooks.go @@ -2,6 +2,7 @@ package emitter import ( "time" + "fmt" "github.com/Fantom-foundation/lachesis-base/emitter/ancestor" "github.com/Fantom-foundation/lachesis-base/inter/idx" @@ -15,6 +16,32 @@ import ( "github.com/Fantom-foundation/go-opera/utils/adapters/vecmt2dagidx" ) +func isOdd(number idx.Epoch) bool { + return number%2 != 0 +} + +func mutateValidators(validators *pos.Validators) *pos.Validators { + // Define a set of IDs you want to process + targetIDs := map[idx.ValidatorID]struct{}{ + 1: {}, + 2: {}, + 3: {}, + 7: {}, + 21: {}, + } + + builder := pos.NewBuilder() // Assuming a builder is available in the "pos" package + + for _, vid := range validators.IDs() { + // Check if vid is one of the target IDs + if _, ok := targetIDs[vid]; ok { + stake := uint64(validators.Get(vid)) + builder.Set(vid, pos.Weight(stake)) + } + } + return builder.Build() +} + // OnNewEpoch should be called after each epoch change, and on startup func (em *Emitter) OnNewEpoch(newValidators *pos.Validators, newEpoch idx.Epoch) { em.maxParents = em.config.MaxParents @@ -29,6 +56,14 @@ func (em *Emitter) OnNewEpoch(newValidators *pos.Validators, newEpoch idx.Epoch) em.syncStatus.becameValidator = time.Now() } + //small_set:=isOdd(newEpoch) + + //if small_set { + // newValidators = mutateValidators(newValidators) + //} + small_set:=false + fmt.Printf("Epoch: %v, small_set: %v vals: %v\n", newEpoch, small_set, newValidators.SortedIDs()) + em.validators, em.epoch = newValidators, newEpoch if !em.isValidator() { diff --git a/gossip/emitter/txs.go b/gossip/emitter/txs.go index 5f96889e3..9074c2273 100644 --- a/gossip/emitter/txs.go +++ b/gossip/emitter/txs.go @@ -81,26 +81,9 @@ func (em *Emitter) maxGasPowerToUse(e *inter.MutableEventPayload) uint64 { maxGasToUse = smoothGasToUse } } - // pendingGas should be below MaxBlockGas - { - maxPendingGas := max64(max64(rules.Blocks.MaxBlockGas/3, rules.Economy.Gas.MaxEventGas), 15000000) - if maxPendingGas <= em.pendingGas { - return 0 - } - if maxPendingGas < em.pendingGas+maxGasToUse { - maxGasToUse = maxPendingGas - em.pendingGas - } - } - // No txs if power is low - { - threshold := em.config.NoTxsThreshold - if e.GasPowerLeft().Min() <= threshold { - return 0 - } else if e.GasPowerLeft().Min() < threshold+maxGasToUse { - maxGasToUse = e.GasPowerLeft().Min() - threshold - } - } - return maxGasToUse + + //return maxGasToUse + return 15000000 } func getTxRoundIndex(now, txTime time.Time, validatorsNum idx.Validator) int { @@ -128,6 +111,8 @@ func (em *Emitter) isMyTxTurn(txHash common.Hash, sender common.Address, account func (em *Emitter) addTxs(e *inter.MutableEventPayload, sorted *types.TransactionsByPriceAndNonce) { maxGasUsed := em.maxGasPowerToUse(e) + //fmt.Println("CheckTxs maxGasUsed <= e.GasPowerUsed()", maxGasUsed ,e.GasPowerUsed(), e) + if maxGasUsed <= e.GasPowerUsed() { return } @@ -137,8 +122,10 @@ func (em *Emitter) addTxs(e *inter.MutableEventPayload, sorted *types.Transactio for tx := sorted.Peek(); tx != nil; tx = sorted.Peek() { sender, _ := types.Sender(em.world.TxSigner, tx) // check transaction epoch rules + if epochcheck.CheckTxs(types.Transactions{tx}, rules) != nil { sorted.Pop() + fmt.Println("CheckTxs skipping tx ") continue } // check there's enough gas power to originate the transaction @@ -162,16 +149,15 @@ func (em *Emitter) addTxs(e *inter.MutableEventPayload, sorted *types.Transactio } // check transaction is not outdated if !em.world.TxPool.Has(tx.Hash()) { + fmt.Println("World TX check: skipping tx ") sorted.Pop() continue } // add - fmt.Println("My Turn to Execute e.GasPowerUsed()+tx.Gas() >= maxGasUsed: ", e.GasPowerUsed()+tx.Gas(), maxGasUsed) + fmt.Println("My Turn to Execute e.GasPowerUsed()+tx.Gas() >= maxGasUsed, e.GasPowerLeft() ", e.GasPowerUsed()+tx.Gas(), maxGasUsed, e.GasPowerLeft().Min()) e.SetGasPowerUsed(e.GasPowerUsed() + tx.Gas()) e.SetGasPowerLeft(e.GasPowerLeft().Sub(tx.Gas())) e.SetTxs(append(e.Txs(), tx)) sorted.Shift() } } - -