Skip to content

Commit b57e3e0

Browse files
authored
Merge pull request #674 from onflow/mpeter/fix-coa-creation-tx
Remove transaction for COA resource creation
2 parents ec3fd4b + 31ecd72 commit b57e3e0

File tree

9 files changed

+56
-125
lines changed

9 files changed

+56
-125
lines changed

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ start-local:
5454
--coa-address=f8d6e0586b0a20c7 \
5555
--coa-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
5656
--wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
57-
--coa-resource-create=true \
5857
--gas-price=0 \
5958
--log-writer=console \
6059
--profiler-enabled=true \
@@ -71,7 +70,6 @@ start-local-bin:
7170
--coa-address=f8d6e0586b0a20c7 \
7271
--coa-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
7372
--wallet-api-key=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21 \
74-
--coa-resource-create=true \
7573
--gas-price=0 \
7674
--log-writer=console \
7775
--profiler-enabled=true \

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ This will be improved soon.
8585
_In the example above we set `coa-address` value to the service account of the emulator, the same as `coa-key`.
8686
This account will by default be funded with Flow which is a requirement. For `coinbase` we can
8787
use whichever valid EVM address. It's not really useful when running locally besides collecting fees. We also allow for the
88-
`coa-resource-create` to auto-create resources needed on start-up on the `coa` account in order to operate the gateway.
8988
`gas-price` is set at 0 so we don't have to fund EOA accounts. We can set it higher but keep in mind you will then
9089
need funded accounts for interacting with EVM._
9190

@@ -132,7 +131,6 @@ Below is an example configuration for running against testnet, with an already c
132131
--flow-network-id=flow-testnet \
133132
--init-cadence-height=211176670 \
134133
--ws-enabled=true \
135-
--coa-resource-create=false \
136134
--coinbase=FACF71692421039876a5BB4F10EF7A439D8ef61E \
137135
--coa-address=0x62631c28c9fc5a91 \
138136
--coa-key=2892fba444f1d5787739708874e3b01160671924610411ac787ac1379d420f49 \
@@ -212,7 +210,6 @@ The application can be configured using the following flags at runtime:
212210
| `coa-address` | `""` | Flow address holding COA account for submitting transactions |
213211
| `coa-key` | `""` | Private key for the COA address used for transactions |
214212
| `coa-key-file` | `""` | Path to a JSON file of COA keys for key-rotation (exclusive with `coa-key` flag) |
215-
| `coa-resource-create` | `false` | Auto-create the COA resource if it doesn't exist in the Flow COA account |
216213
| `coa-cloud-kms-project-id` | `""` | Project ID for KMS keys (e.g. `flow-evm-gateway`) |
217214
| `coa-cloud-kms-location-id` | `""` | Location ID for KMS key ring (e.g. 'global') |
218215
| `coa-cloud-kms-key-ring-id` | `""` | Key ring ID for KMS keys (e.g. 'tx-signing') |

cmd/run/cmd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ func init() {
285285
Cmd.Flags().StringVar(&key, "coa-key", "", "Private key value for the COA address used for submitting transactions")
286286
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.")
287287
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.")
288-
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")
289288
Cmd.Flags().StringVar(&logLevel, "log-level", "debug", "Define verbosity of the log output ('debug', 'info', 'warn', 'error', 'fatal', 'panic')")
290289
Cmd.Flags().StringVar(&logWriter, "log-writer", "stderr", "Log writer used for output ('stderr', 'console')")
291290
Cmd.Flags().Float64Var(&cfg.StreamLimit, "stream-limit", 10, "Rate-limits the events sent to the client within one second")

config/config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ type Config struct {
5151
COAKeys []crypto.PrivateKey
5252
// COACloudKMSKeys is a slice of all the keys and their versions that will be used in Cloud KMS key-rotation mechanism.
5353
COACloudKMSKeys []flowGoKMS.Key
54-
// CreateCOAResource indicates if the COA resource should be auto-created on
55-
// startup if one doesn't exist in the COA Flow address account
56-
CreateCOAResource bool
5754
// GasPrice is a fixed gas price that will be used when submitting transactions.
5855
GasPrice *big.Int
5956
// InitCadenceHeight is used for initializing the database on a local emulator or a live network.

dev/run.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ FLOW_NETWORK_ID=flow-emulator
77
COINBASE=FACF71692421039876a5BB4F10EF7A439D8ef61E
88
COA_ADDRESS=f8d6e0586b0a20c7
99
COA_KEY=2619878f0e2ff438d17835c2a4561cb87b4d24d72d12ec34569acd0dd4af7c21
10-
COA_RESOURCE_CREATE=true
1110
GAS_PRICE=0
1211
RPC_HOST=0.0.0.0
1312
RPC_PORT=8545
1413

15-
/app/flow-evm-gateway/evm-gateway --flow-network-id=$FLOW_NETWORK_ID --coinbase=$COINBASE --coa-address=$COA_ADDRESS --coa-key=$COA_KEY --coa-resource-create=$COA_RESOURCE_CREATE --gas-price=$GAS_PRICE --rpc-host=$RPC_HOST --rpc-port=$RPC_PORT
16-
sleep 5
14+
/app/flow-evm-gateway/evm-gateway --flow-network-id=$FLOW_NETWORK_ID --coinbase=$COINBASE --coa-address=$COA_ADDRESS --coa-key=$COA_KEY --gas-price=$GAS_PRICE --rpc-host=$RPC_HOST --rpc-port=$RPC_PORT
15+
sleep 5

services/requester/cadence/create_coa.cdc

Lines changed: 0 additions & 31 deletions
This file was deleted.

services/requester/requester.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,11 @@ var (
3838
//go:embed cadence/run.cdc
3939
runTxScript []byte
4040

41-
//go:embed cadence/create_coa.cdc
42-
createCOAScript []byte
43-
4441
//go:embed cadence/get_latest_evm_height.cdc
4542
getLatestEVMHeight []byte
4643
)
4744

4845
const minFlowBalance = 2
49-
const coaFundingBalance = minFlowBalance - 1
5046
const blockGasLimit = 120_000_000
5147

5248
type Requester interface {
@@ -124,9 +120,6 @@ func NewEVM(
124120
collector metrics.Collector,
125121
) (*EVM, error) {
126122
logger = logger.With().Str("component", "requester").Logger()
127-
// check that the address stores already created COA resource in the "evm" storage path.
128-
// if it doesn't check if the auto-creation boolean is true and if so create it
129-
// otherwise fail. COA resource is required by the EVM requester to be able to submit transactions.
130123
address := config.COAAddress
131124
acc, err := client.GetAccount(context.Background(), address)
132125
if err != nil {
@@ -182,23 +175,6 @@ func NewEVM(
182175
collector: collector,
183176
}
184177

185-
// create COA on the account
186-
if config.CreateCOAResource {
187-
tx, err := evm.buildTransaction(
188-
context.Background(),
189-
replaceAddresses(createCOAScript, config.FlowNetworkID),
190-
cadence.UFix64(coaFundingBalance),
191-
)
192-
if err != nil {
193-
logger.Warn().Err(err).Msg("COA resource auto-creation failure")
194-
return nil, fmt.Errorf("COA resource auto-creation failure: %w", err)
195-
}
196-
if err := evm.client.SendTransaction(context.Background(), *tx); err != nil {
197-
logger.Warn().Err(err).Msg("failed to send COA resource auto-creation transaction")
198-
return nil, fmt.Errorf("failed to send COA resource auto-creation transaction: %w", err)
199-
}
200-
}
201-
202178
return evm, nil
203179
}
204180

tests/helpers.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,25 +138,24 @@ func servicesSetup(t *testing.T) (emulator.Emulator, func()) {
138138

139139
// default config
140140
cfg := &config.Config{
141-
DatabaseDir: t.TempDir(),
142-
AccessNodeHost: "localhost:3569", // emulator
143-
RPCPort: 8545,
144-
RPCHost: "127.0.0.1",
145-
FlowNetworkID: "flow-emulator",
146-
EVMNetworkID: evmTypes.FlowEVMPreviewNetChainID,
147-
Coinbase: common.HexToAddress(coinbaseAddress),
148-
COAAddress: service.Address,
149-
COAKey: service.PrivateKey,
150-
CreateCOAResource: false,
151-
GasPrice: new(big.Int).SetUint64(150),
152-
LogLevel: zerolog.DebugLevel,
153-
LogWriter: testLogWriter(),
154-
StreamTimeout: time.Second * 30,
155-
StreamLimit: 10,
156-
RateLimit: 500,
157-
WSEnabled: true,
158-
MetricsPort: 8443,
159-
FilterExpiry: time.Second * 5,
141+
DatabaseDir: t.TempDir(),
142+
AccessNodeHost: "localhost:3569", // emulator
143+
RPCPort: 8545,
144+
RPCHost: "127.0.0.1",
145+
FlowNetworkID: "flow-emulator",
146+
EVMNetworkID: evmTypes.FlowEVMPreviewNetChainID,
147+
Coinbase: common.HexToAddress(coinbaseAddress),
148+
COAAddress: service.Address,
149+
COAKey: service.PrivateKey,
150+
GasPrice: new(big.Int).SetUint64(150),
151+
LogLevel: zerolog.DebugLevel,
152+
LogWriter: testLogWriter(),
153+
StreamTimeout: time.Second * 30,
154+
StreamLimit: 10,
155+
RateLimit: 500,
156+
WSEnabled: true,
157+
MetricsPort: 8443,
158+
FilterExpiry: time.Second * 5,
160159
}
161160

162161
bootstrapDone := make(chan struct{})

tests/integration_test.go

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,18 @@ func Test_ConcurrentTransactionSubmission(t *testing.T) {
6060
require.NoError(t, err)
6161

6262
cfg := &config.Config{
63-
DatabaseDir: t.TempDir(),
64-
AccessNodeHost: grpcHost,
65-
RPCPort: 8545,
66-
RPCHost: "127.0.0.1",
67-
FlowNetworkID: "flow-emulator",
68-
EVMNetworkID: types.FlowEVMPreviewNetChainID,
69-
Coinbase: eoaTestAccount,
70-
COAAddress: *createdAddr,
71-
COAKeys: keys,
72-
CreateCOAResource: true,
73-
GasPrice: new(big.Int).SetUint64(0),
74-
LogLevel: zerolog.DebugLevel,
75-
LogWriter: testLogWriter(),
63+
DatabaseDir: t.TempDir(),
64+
AccessNodeHost: grpcHost,
65+
RPCPort: 8545,
66+
RPCHost: "127.0.0.1",
67+
FlowNetworkID: "flow-emulator",
68+
EVMNetworkID: types.FlowEVMPreviewNetChainID,
69+
Coinbase: eoaTestAccount,
70+
COAAddress: *createdAddr,
71+
COAKeys: keys,
72+
GasPrice: new(big.Int).SetUint64(0),
73+
LogLevel: zerolog.DebugLevel,
74+
LogWriter: testLogWriter(),
7675
}
7776

7877
// todo change this test to use ingestion and emulator directly so we can completely remove
@@ -166,19 +165,18 @@ func Test_EthClientTest(t *testing.T) {
166165
require.NoError(t, err)
167166

168167
cfg := &config.Config{
169-
DatabaseDir: t.TempDir(),
170-
AccessNodeHost: grpcHost,
171-
RPCPort: 8545,
172-
RPCHost: "127.0.0.1",
173-
FlowNetworkID: "flow-emulator",
174-
EVMNetworkID: types.FlowEVMPreviewNetChainID,
175-
Coinbase: eoaTestAccount,
176-
COAAddress: *createdAddr,
177-
COAKeys: keys,
178-
CreateCOAResource: true,
179-
GasPrice: new(big.Int).SetUint64(150),
180-
LogLevel: zerolog.DebugLevel,
181-
LogWriter: testLogWriter(),
168+
DatabaseDir: t.TempDir(),
169+
AccessNodeHost: grpcHost,
170+
RPCPort: 8545,
171+
RPCHost: "127.0.0.1",
172+
FlowNetworkID: "flow-emulator",
173+
EVMNetworkID: types.FlowEVMPreviewNetChainID,
174+
Coinbase: eoaTestAccount,
175+
COAAddress: *createdAddr,
176+
COAKeys: keys,
177+
GasPrice: new(big.Int).SetUint64(150),
178+
LogLevel: zerolog.DebugLevel,
179+
LogWriter: testLogWriter(),
182180
}
183181

184182
ready := make(chan struct{})
@@ -269,19 +267,18 @@ func Test_CloudKMSConcurrentTransactionSubmission(t *testing.T) {
269267
require.NoError(t, err)
270268

271269
cfg := &config.Config{
272-
DatabaseDir: t.TempDir(),
273-
AccessNodeHost: grpcHost,
274-
RPCPort: 8545,
275-
RPCHost: "127.0.0.1",
276-
FlowNetworkID: "flow-emulator",
277-
EVMNetworkID: types.FlowEVMPreviewNetChainID,
278-
Coinbase: eoaTestAccount,
279-
COAAddress: *createdAddr,
280-
COACloudKMSKeys: kmsKeys,
281-
CreateCOAResource: true,
282-
GasPrice: new(big.Int).SetUint64(0),
283-
LogLevel: zerolog.DebugLevel,
284-
LogWriter: testLogWriter(),
270+
DatabaseDir: t.TempDir(),
271+
AccessNodeHost: grpcHost,
272+
RPCPort: 8545,
273+
RPCHost: "127.0.0.1",
274+
FlowNetworkID: "flow-emulator",
275+
EVMNetworkID: types.FlowEVMPreviewNetChainID,
276+
Coinbase: eoaTestAccount,
277+
COAAddress: *createdAddr,
278+
COACloudKMSKeys: kmsKeys,
279+
GasPrice: new(big.Int).SetUint64(0),
280+
LogLevel: zerolog.DebugLevel,
281+
LogWriter: testLogWriter(),
285282
}
286283

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

0 commit comments

Comments
 (0)