Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,41 +727,12 @@ func (vm *VM) initializeChain(lastAcceptedHash common.Hash) error {
// Set the gas parameters for the tx pool to the minimum gas price for the
// latest upgrade.
vm.txPool.SetGasTip(big.NewInt(0))
vm.setMinFeeAtEtna()
vm.txPool.SetMinFee(big.NewInt(params.EtnaMinBaseFee))

vm.eth.Start()
return vm.initChainState(vm.blockChain.LastAcceptedBlock())
}

// TODO: remove this after Etna is activated
func (vm *VM) setMinFeeAtEtna() {
now := vm.clock.Time()
if vm.chainConfig.EtnaTimestamp == nil {
// If Etna is not set, set the min fee according to the latest upgrade
vm.txPool.SetMinFee(big.NewInt(params.ApricotPhase4MinBaseFee))
return
} else if vm.chainConfig.IsEtna(uint64(now.Unix())) {
// If Etna is activated, set the min fee to the Etna min fee
vm.txPool.SetMinFee(big.NewInt(params.EtnaMinBaseFee))
return
}

vm.txPool.SetMinFee(big.NewInt(params.ApricotPhase4MinBaseFee))
vm.shutdownWg.Add(1)
go func() {
defer vm.shutdownWg.Done()

wait := utils.Uint64ToTime(vm.chainConfig.EtnaTimestamp).Sub(now)
t := time.NewTimer(wait)
select {
case <-t.C: // Wait for Etna to be activated
vm.txPool.SetMinFee(big.NewInt(params.EtnaMinBaseFee))
case <-vm.shutdownChan:
}
t.Stop()
}()
}

// initializeStateSyncClient initializes the client for performing state sync.
// If state sync is disabled, this function will wipe any ongoing summary from
// disk to ensure that we do not continue syncing from an invalid snapshot.
Expand Down
28 changes: 0 additions & 28 deletions plugin/evm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ var (
return &cpy
}

activateEtna = func(cfg *params.ChainConfig, etnaTime uint64) *params.ChainConfig {
cpy := *cfg
cpy.EtnaTimestamp = &etnaTime
return &cpy
}

genesisJSONApricotPhase0 = genesisJSON(params.TestLaunchConfig)
genesisJSONApricotPhase1 = genesisJSON(params.TestApricotPhase1Config)
genesisJSONApricotPhase2 = genesisJSON(params.TestApricotPhase2Config)
Expand Down Expand Up @@ -3987,25 +3981,3 @@ func TestNoBlobsAllowed(t *testing.T) {
err = vmBlock.Verify(ctx)
require.ErrorContains(err, "blobs not enabled on avalanche networks")
}

func TestMinFeeSetAtEtna(t *testing.T) {
require := require.New(t)
now := time.Now()
etnaTime := uint64(now.Add(1 * time.Second).Unix())

genesis := genesisJSON(
activateEtna(params.TestEtnaChainConfig, etnaTime),
)
clock := mockable.Clock{}
clock.Set(now)

_, vm, _, _, _ := GenesisVMWithClock(t, false, genesis, "", "", clock)
initial := vm.txPool.MinFee()
require.Equal(params.ApricotPhase4MinBaseFee, initial.Int64())

require.Eventually(
func() bool { return params.EtnaMinBaseFee == vm.txPool.MinFee().Int64() },
5*time.Second,
1*time.Second,
)
}
Loading