Skip to content

Commit

Permalink
Remove the setupEVMEnabled flag from BootstrapParams
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Mar 26, 2024
1 parent bcab800 commit d95792c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 46 deletions.
46 changes: 18 additions & 28 deletions fvm/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ type BootstrapParams struct {
minimumStorageReservation cadence.UFix64
storagePerFlow cadence.UFix64
restrictedAccountCreationEnabled cadence.Bool
setupEVMEnabled cadence.Bool

// versionFreezePeriod is the number of blocks in the future where the version
// changes are frozen. The Node version beacon manages the freeze period,
Expand Down Expand Up @@ -212,13 +211,6 @@ func WithRestrictedAccountCreationEnabled(enabled cadence.Bool) BootstrapProcedu
}
}

func WithSetupEVMEnabled(enabled cadence.Bool) BootstrapProcedureOption {
return func(bp *BootstrapProcedure) *BootstrapProcedure {
bp.setupEVMEnabled = enabled
return bp
}
}

func WithRestrictedContractDeployment(restricted *bool) BootstrapProcedureOption {
return func(bp *BootstrapProcedure) *BootstrapProcedure {
bp.restrictedContractDeployment = restricted
Expand Down Expand Up @@ -807,26 +799,24 @@ func (b *bootstrapExecutor) setStakingAllowlist(
}

func (b *bootstrapExecutor) setupEVM(serviceAddress, fungibleTokenAddress, flowTokenAddress flow.Address) {
if b.setupEVMEnabled {
// account for storage
// we dont need to deploy anything to this account, but it needs to exist
// so that we can store the EVM state on it
evmAcc := b.createAccount(nil)
b.setupStorageForAccount(evmAcc, serviceAddress, fungibleTokenAddress, flowTokenAddress)

// deploy the EVM contract to the service account
tx := blueprints.DeployContractTransaction(
serviceAddress,
stdlib.ContractCode(flowTokenAddress),
stdlib.ContractName,
)
// WithEVMEnabled should only be used after we create an account for storage
txError, err := b.invokeMetaTransaction(
NewContextFromParent(b.ctx, WithEVMEnabled(true)),
Transaction(tx, 0),
)
panicOnMetaInvokeErrf("failed to deploy EVM contract: %s", txError, err)
}
// account for storage
// we dont need to deploy anything to this account, but it needs to exist
// so that we can store the EVM state on it
evmAcc := b.createAccount(nil)
b.setupStorageForAccount(evmAcc, serviceAddress, fungibleTokenAddress, flowTokenAddress)

// deploy the EVM contract to the service account
tx := blueprints.DeployContractTransaction(
serviceAddress,
stdlib.ContractCode(flowTokenAddress),
stdlib.ContractName,
)
// WithEVMEnabled should only be used after we create an account for storage
txError, err := b.invokeMetaTransaction(
NewContextFromParent(b.ctx, WithEVMEnabled(true)),
Transaction(tx, 0),
)
panicOnMetaInvokeErrf("failed to deploy EVM contract: %s", txError, err)
}

func (b *bootstrapExecutor) registerNodes(service, fungibleToken, flowToken flow.Address) {
Expand Down
1 change: 0 additions & 1 deletion fvm/evm/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,6 @@ func RunWithNewEnvironment(

baseBootstrapOpts := []fvm.BootstrapProcedureOption{
fvm.WithInitialTokenSupply(unittest.GenesisTokenSupply),
fvm.WithSetupEVMEnabled(true),
}

executionSnapshot, _, err := vm.Run(
Expand Down
1 change: 0 additions & 1 deletion fvm/fvm_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ func NewBasicBlockExecutor(tb testing.TB, chain flow.Chain, logger zerolog.Logge
fvm.WithMinimumStorageReservation(fvm.DefaultMinimumStorageReservation),
fvm.WithTransactionFee(fvm.DefaultTransactionFees),
fvm.WithStorageMBPerFLOW(fvm.DefaultStorageMBPerFLOW),
fvm.WithSetupEVMEnabled(true),
)
require.NoError(tb, err)

Expand Down
12 changes: 3 additions & 9 deletions fvm/fvm_blockcontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,6 @@ func TestBlockContext_ExecuteTransaction_StorageLimit(t *testing.T) {
fvm.WithAccountCreationFee(fvm.DefaultAccountCreationFee),
fvm.WithMinimumStorageReservation(fvm.DefaultMinimumStorageReservation),
fvm.WithStorageMBPerFLOW(fvm.DefaultStorageMBPerFLOW),
// The evm account has a storage exception, and if we don't bootstrap with evm,
// the first created account will have that address.
fvm.WithSetupEVMEnabled(true),
}

t.Run("Storing too much data fails", newVMTest().withBootstrapProcedureOptions(bootstrapOptions...).
Expand Down Expand Up @@ -1637,8 +1634,8 @@ func TestBlockContext_GetAccount(t *testing.T) {
}

addressGen := chain.NewAddressGenerator()
// skip the addresses of 4 reserved accounts
for i := 0; i < 4; i++ {
// skip the addresses of 5 reserved accounts
for i := 0; i < 5; i++ {
_, err := addressGen.NextAddress()
require.NoError(t, err)
}
Expand Down Expand Up @@ -1817,7 +1814,7 @@ func TestBlockContext_ExecuteTransaction_CreateAccount_WithMonotonicAddresses(t
address := flow.ConvertAddress(
data.(cadence.Event).Fields[0].(cadence.Address))

require.Equal(t, flow.HexToAddress("05"), address)
require.Equal(t, flow.HexToAddress("06"), address)
}

func TestBlockContext_ExecuteTransaction_FailingTransactions(t *testing.T) {
Expand Down Expand Up @@ -1862,9 +1859,6 @@ func TestBlockContext_ExecuteTransaction_FailingTransactions(t *testing.T) {
fvm.WithAccountCreationFee(fvm.DefaultAccountCreationFee),
fvm.WithStorageMBPerFLOW(fvm.DefaultStorageMBPerFLOW),
fvm.WithExecutionMemoryLimit(math.MaxUint64),
// The evm account has a storage exception, and if we don't bootstrap with evm,
// the first created account will have that address.
fvm.WithSetupEVMEnabled(true),
).run(
func(t *testing.T, vm fvm.VM, chain flow.Chain, ctx fvm.Context, snapshotTree snapshot.SnapshotTree) {
ctx.LimitAccountStorage = true // this test requires storage limits to be enforced
Expand Down
6 changes: 0 additions & 6 deletions fvm/fvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3062,7 +3062,6 @@ func TestTransientNetworkCoreContractAddresses(t *testing.T) {

func TestEVM(t *testing.T) {
t.Run("successful transaction", newVMTest().
withBootstrapProcedureOptions(fvm.WithSetupEVMEnabled(true)).
withContextOptions(
fvm.WithEVMEnabled(true),
fvm.WithCadenceLogging(true),
Expand Down Expand Up @@ -3121,7 +3120,6 @@ func TestEVM(t *testing.T) {

// this test makes sure the execution error is correctly handled and returned as a correct type
t.Run("execution reverted", newVMTest().
withBootstrapProcedureOptions(fvm.WithSetupEVMEnabled(true)).
withContextOptions(
fvm.WithChain(flow.Emulator.Chain()),
fvm.WithEVMEnabled(true),
Expand Down Expand Up @@ -3161,7 +3159,6 @@ func TestEVM(t *testing.T) {
// this test makes sure the EVM error is correctly returned as an error and has a correct type
// we have implemented a snapshot wrapper to return an error from the EVM
t.Run("internal evm error handling", newVMTest().
withBootstrapProcedureOptions(fvm.WithSetupEVMEnabled(true)).
withContextOptions(
fvm.WithChain(flow.Emulator.Chain()),
fvm.WithEVMEnabled(true),
Expand Down Expand Up @@ -3218,9 +3215,6 @@ func TestEVM(t *testing.T) {
)

t.Run("deploy contract code", newVMTest().
withBootstrapProcedureOptions(
fvm.WithSetupEVMEnabled(true),
).
withContextOptions(
// default is testnet, but testnet has a special EVM storage contract location
// so we have to use emulator here so that the EVM storage contract is deployed
Expand Down
1 change: 0 additions & 1 deletion integration/benchmark/load/load_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func bootstrapVM(t *testing.T, chain flow.Chain) (*fvm.VirtualMachine, fvm.Conte
fvm.WithMinimumStorageReservation(fvm.DefaultMinimumStorageReservation),
fvm.WithTransactionFee(fvm.DefaultTransactionFees),
fvm.WithStorageMBPerFLOW(fvm.DefaultStorageMBPerFLOW),
fvm.WithSetupEVMEnabled(true),
}

executionSnapshot, _, err := vm.Run(
Expand Down

0 comments on commit d95792c

Please sign in to comment.