Skip to content

Commit

Permalink
Remove completely the create_coa.cdc transaction as it is not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Nov 26, 2024
1 parent 01bb8e7 commit 0a5973e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 116 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ start-local:
--coa-address=f8d6e0586b0a20c7 \
--coa-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--coa-resource-create=true \
--gas-price=0 \
--log-writer=console \
--profiler-enabled=true \
Expand All @@ -71,7 +70,6 @@ start-local-bin:
--coa-address=f8d6e0586b0a20c7 \
--coa-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
--coa-resource-create=true \
--gas-price=0 \
--log-writer=console \
--profiler-enabled=true \
Expand Down
1 change: 0 additions & 1 deletion cmd/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ func init() {
Cmd.Flags().StringVar(&key, "coa-key", "", "Private key value for the COA address used for submitting transactions")
Cmd.Flags().StringVar(&keyAlg, "coa-key-alg", "ECDSA_P256", "Private key algorithm for the COA private key, only effective if coa-key/coa-key-file is present. Available values (ECDSA_P256 / ECDSA_secp256k1 / BLS_BLS12_381), defaults to ECDSA_P256.")
Cmd.Flags().StringVar(&keysPath, "coa-key-file", "", "File path that contains JSON array of COA keys used in key-rotation mechanism, this is exclusive with coa-key flag.")
Cmd.Flags().BoolVar(&cfg.CreateCOAResource, "coa-resource-create", false, "Auto-create the COA resource in the Flow COA account provided if one doesn't exist")
Cmd.Flags().StringVar(&logLevel, "log-level", "debug", "Define verbosity of the log output ('debug', 'info', 'warn', 'error', 'fatal', 'panic')")
Cmd.Flags().StringVar(&logWriter, "log-writer", "stderr", "Log writer used for output ('stderr', 'console')")
Cmd.Flags().Float64Var(&cfg.StreamLimit, "stream-limit", 10, "Rate-limits the events sent to the client within one second")
Expand Down
3 changes: 0 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ type Config struct {
COAKeys []crypto.PrivateKey
// COACloudKMSKeys is a slice of all the keys and their versions that will be used in Cloud KMS key-rotation mechanism.
COACloudKMSKeys []flowGoKMS.Key
// CreateCOAResource indicates if the COA resource should be auto-created on
// startup if one doesn't exist in the COA Flow address account
CreateCOAResource bool
// GasPrice is a fixed gas price that will be used when submitting transactions.
GasPrice *big.Int
// InitCadenceHeight is used for initializing the database on a local emulator or a live network.
Expand Down
31 changes: 0 additions & 31 deletions services/requester/cadence/create_coa.cdc

This file was deleted.

21 changes: 0 additions & 21 deletions services/requester/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ var (
//go:embed cadence/run.cdc
runTxScript []byte

//go:embed cadence/create_coa.cdc
createCOAScript []byte

//go:embed cadence/get_latest_evm_height.cdc
getLatestEVMHeight []byte
)

const minFlowBalance = 2
const coaFundingBalance = minFlowBalance - 1
const blockGasLimit = 120_000_000

type Requester interface {
Expand Down Expand Up @@ -182,23 +178,6 @@ func NewEVM(
collector: collector,
}

// create COA on the account
if config.CreateCOAResource {
tx, err := evm.buildTransaction(
context.Background(),
replaceAddresses(createCOAScript, config.FlowNetworkID),
cadence.UFix64(coaFundingBalance),
)
if err != nil {
logger.Warn().Err(err).Msg("COA resource auto-creation failure")
return nil, fmt.Errorf("COA resource auto-creation failure: %w", err)
}
if err := evm.client.SendTransaction(context.Background(), *tx); err != nil {
logger.Warn().Err(err).Msg("failed to send COA resource auto-creation transaction")
return nil, fmt.Errorf("failed to send COA resource auto-creation transaction: %w", err)
}
}

return evm, nil
}

Expand Down
37 changes: 18 additions & 19 deletions tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,24 @@ func servicesSetup(t *testing.T) (emulator.Emulator, func()) {

// default config
cfg := &config.Config{
DatabaseDir: t.TempDir(),
AccessNodeHost: "localhost:3569", // emulator
RPCPort: 8545,
RPCHost: "127.0.0.1",
FlowNetworkID: "flow-emulator",
EVMNetworkID: evmTypes.FlowEVMPreviewNetChainID,
Coinbase: common.HexToAddress(coinbaseAddress),
COAAddress: service.Address,
COAKey: service.PrivateKey,
CreateCOAResource: false,
GasPrice: new(big.Int).SetUint64(150),
LogLevel: zerolog.DebugLevel,
LogWriter: testLogWriter(),
StreamTimeout: time.Second * 30,
StreamLimit: 10,
RateLimit: 500,
WSEnabled: true,
MetricsPort: 8443,
FilterExpiry: time.Second * 5,
DatabaseDir: t.TempDir(),
AccessNodeHost: "localhost:3569", // emulator
RPCPort: 8545,
RPCHost: "127.0.0.1",
FlowNetworkID: "flow-emulator",
EVMNetworkID: evmTypes.FlowEVMPreviewNetChainID,
Coinbase: common.HexToAddress(coinbaseAddress),
COAAddress: service.Address,
COAKey: service.PrivateKey,
GasPrice: new(big.Int).SetUint64(150),
LogLevel: zerolog.DebugLevel,
LogWriter: testLogWriter(),
StreamTimeout: time.Second * 30,
StreamLimit: 10,
RateLimit: 500,
WSEnabled: true,
MetricsPort: 8443,
FilterExpiry: time.Second * 5,
}

bootstrapDone := make(chan struct{})
Expand Down
75 changes: 36 additions & 39 deletions tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,18 @@ func Test_ConcurrentTransactionSubmission(t *testing.T) {
require.NoError(t, err)

cfg := &config.Config{
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
RPCHost: "127.0.0.1",
FlowNetworkID: "flow-emulator",
EVMNetworkID: types.FlowEVMPreviewNetChainID,
Coinbase: eoaTestAccount,
COAAddress: *createdAddr,
COAKeys: keys,
CreateCOAResource: true,
GasPrice: new(big.Int).SetUint64(0),
LogLevel: zerolog.DebugLevel,
LogWriter: testLogWriter(),
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
RPCHost: "127.0.0.1",
FlowNetworkID: "flow-emulator",
EVMNetworkID: types.FlowEVMPreviewNetChainID,
Coinbase: eoaTestAccount,
COAAddress: *createdAddr,
COAKeys: keys,
GasPrice: new(big.Int).SetUint64(0),
LogLevel: zerolog.DebugLevel,
LogWriter: testLogWriter(),
}

// todo change this test to use ingestion and emulator directly so we can completely remove
Expand Down Expand Up @@ -164,19 +163,18 @@ func Test_EthClientTest(t *testing.T) {
require.NoError(t, err)

cfg := &config.Config{
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
RPCHost: "127.0.0.1",
FlowNetworkID: "flow-emulator",
EVMNetworkID: types.FlowEVMPreviewNetChainID,
Coinbase: eoaTestAccount,
COAAddress: *createdAddr,
COAKeys: keys,
CreateCOAResource: true,
GasPrice: new(big.Int).SetUint64(150),
LogLevel: zerolog.DebugLevel,
LogWriter: testLogWriter(),
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
RPCHost: "127.0.0.1",
FlowNetworkID: "flow-emulator",
EVMNetworkID: types.FlowEVMPreviewNetChainID,
Coinbase: eoaTestAccount,
COAAddress: *createdAddr,
COAKeys: keys,
GasPrice: new(big.Int).SetUint64(150),
LogLevel: zerolog.DebugLevel,
LogWriter: testLogWriter(),
}

ready := make(chan struct{})
Expand Down Expand Up @@ -265,19 +263,18 @@ func Test_CloudKMSConcurrentTransactionSubmission(t *testing.T) {
require.NoError(t, err)

cfg := &config.Config{
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
RPCHost: "127.0.0.1",
FlowNetworkID: "flow-emulator",
EVMNetworkID: types.FlowEVMPreviewNetChainID,
Coinbase: eoaTestAccount,
COAAddress: *createdAddr,
COACloudKMSKeys: kmsKeys,
CreateCOAResource: true,
GasPrice: new(big.Int).SetUint64(0),
LogLevel: zerolog.DebugLevel,
LogWriter: testLogWriter(),
DatabaseDir: t.TempDir(),
AccessNodeHost: grpcHost,
RPCPort: 8545,
RPCHost: "127.0.0.1",
FlowNetworkID: "flow-emulator",
EVMNetworkID: types.FlowEVMPreviewNetChainID,
Coinbase: eoaTestAccount,
COAAddress: *createdAddr,
COACloudKMSKeys: kmsKeys,
GasPrice: new(big.Int).SetUint64(0),
LogLevel: zerolog.DebugLevel,
LogWriter: testLogWriter(),
}

// todo change this test to use ingestion and emulator directly so we can completely remove
Expand Down

0 comments on commit 0a5973e

Please sign in to comment.