Skip to content

Commit

Permalink
delay initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush committed Sep 30, 2024
1 parent a149479 commit a5656b3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type Miner struct {

func New(eth Backend, config *Config, chainConfig *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, clock *mockable.Clock) *Miner {
return &Miner{
worker: newWorker(config, chainConfig, engine, eth, mux, true),
worker: newWorker(config, chainConfig, engine, eth, mux, false),
clock: clock,
}
}
Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func (w *worker) pendingBlockAndReceipts() (*types.Block, types.Receipts) {

// start sets the running status as 1 and triggers new work submitting.
func (w *worker) start() {
w.running.Store(true)
// w.running.Store(true)
w.startCh <- struct{}{}
}

Expand Down
2 changes: 2 additions & 0 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,8 @@ func (vm *VM) initBlockBuilding() error {
ctx, cancel := context.WithCancel(context.TODO())
vm.cancel = cancel

vm.miner.Start()

ethTxGossipMarshaller := GossipEthTxMarshaller{}
ethTxGossipClient := vm.Network.NewClient(p2p.TxGossipHandlerID, p2p.WithValidatorSampling(vm.validators))
ethTxGossipMetrics, err := gossip.NewMetrics(vm.sdkMetrics, ethTxGossipNamespace)
Expand Down
8 changes: 5 additions & 3 deletions plugin/evm/vm_warp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
_ "embed"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
commonEng "github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block"
"github.com/ava-labs/avalanchego/snow/validators"
Expand Down Expand Up @@ -402,7 +403,7 @@ func testWarpVMTransaction(t *testing.T, unsignedMessage *avalancheWarp.Unsigned

func TestReceiveWarpMessage(t *testing.T) {
require := require.New(t)
issuer, vm, _, _, _ := GenesisVM(t, true, genesisJSONDurango, "", "")
issuer, vm, _, _, _ := GenesisVM(t, false, genesisJSONDurango, "", "")

defer func() {
require.NoError(vm.Shutdown(context.Background()))
Expand All @@ -425,15 +426,16 @@ func TestReceiveWarpMessage(t *testing.T) {
)

// Stop the miner to change the upgrade config to avoid a data race
vm.miner.Stop()
vm.chainConfig.UpgradeConfig = params.UpgradeConfig{
PrecompileUpgrades: []params.PrecompileUpgrade{
{Config: enableConfig},
{Config: disableConfig},
{Config: reEnableConfig},
},
}
vm.miner.Start()
// Bootstrapping after changing the upgrade config to avoid a data race in the miner
require.NoError(vm.SetState(context.Background(), snow.Bootstrapping))
require.NoError(vm.SetState(context.Background(), snow.NormalOp))

type test struct {
name string
Expand Down

0 comments on commit a5656b3

Please sign in to comment.