Files
evm/tests/utils_e2e/proposervm.go_e2e
zeekay 327441b231 Remove e2e tests and exporter pending node/chainmigrate
- Remove plugin/evm/exporter.go (depends on non-existent chainmigrate)
- Remove tests/load, tests/utils, tests/warp (e2e tests)
- Remove tests/precompile e2e tests
- Install golangci-lint v2 instead of v1 in CI
- Files renamed to _e2e extension for later restoration

Unit tests still run, e2e tests require node infrastructure
2025-12-04 06:52:47 -08:00

69 lines
1.9 KiB
Plaintext

//go:build e2e
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package utils
import (
"context"
"crypto/ecdsa"
"math/big"
"github.com/luxfi/crypto"
"github.com/luxfi/evm/ethclient"
"github.com/luxfi/evm/plugin/evm/upgrade/legacy"
"github.com/luxfi/geth/common"
"github.com/luxfi/geth/core/types"
ethparams "github.com/luxfi/geth/params"
"github.com/luxfi/log"
)
const numTriggerTxs = 2 // Number of txs needed to activate the proposer VM fork
// IssueTxsToActivateProposerVMFork issues transactions at the current
// timestamp, which should be after the ProposerVM activation time (aka
// ApricotPhase4). This should generate a PostForkBlock because its parent block
// (genesis) has a timestamp (0) that is greater than or equal to the fork
// activation time of 0. Therefore, subsequent blocks should be built with
// BuildBlockWithContext.
func IssueTxsToActivateProposerVMFork(
ctx context.Context, chainID *big.Int, fundedKey *ecdsa.PrivateKey,
client ethclient.Client,
) error {
cryptoAddr := crypto.PubkeyToAddress(fundedKey.PublicKey)
addr := common.BytesToAddress(cryptoAddr[:])
nonce, err := client.NonceAt(ctx, addr, nil)
if err != nil {
return err
}
newHeads := make(chan *types.Header, 1)
sub, err := client.SubscribeNewHead(ctx, newHeads)
if err != nil {
return err
}
defer sub.Unsubscribe()
gasPrice := big.NewInt(legacy.BaseFee)
txSigner := types.LatestSignerForChainID(chainID)
for i := 0; i < numTriggerTxs; i++ {
tx := types.NewTransaction(
nonce, addr, common.Big1, ethparams.TxGas, gasPrice, nil)
triggerTx, err := types.SignTx(tx, txSigner, fundedKey)
if err != nil {
return err
}
if err := client.SendTransaction(ctx, triggerTx); err != nil {
return err
}
<-newHeads // wait for block to be accepted
nonce++
}
log.Info(
"Built sufficient blocks to activate proposerVM fork",
"txCount", numTriggerTxs,
)
return nil
}