Skip to content

Commit 002d8ab

Browse files
authored
Deprecate gas language for compute (#915)
* Deprecate gas flags * Change error message * Logging changes --------- Co-authored-by: Chase Fleming <1666730+chasefleming@users.noreply.github.com>
1 parent 970b346 commit 002d8ab

5 files changed

Lines changed: 39 additions & 15 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ values.
6565
| `--storage-per-flow` | `FLOW_STORAGEMBPERFLOW` | | Specify size of the storage in MB for each FLOW in account balance. Default value from the flow-go |
6666
| `--min-account-balance` | `FLOW_MINIMUMACCOUNTBALANCE` | | Specify minimum balance the account must have. Default value from the flow-go |
6767
| `--transaction-fees` | `FLOW_TRANSACTIONFEESENABLED` | `false` | Enable variable transaction fees and execution effort metering <br> as described in [Variable Transaction Fees: Execution Effort](https://github.com/onflow/flow/pull/753) FLIP |
68-
| `--transaction-max-gas-limit` | `FLOW_TRANSACTIONMAXGASLIMIT` | `9999` | Maximum [gas limit for transactions](https://docs.onflow.org/flow-go-sdk/building-transactions/#gas-limit) |
69-
| `--script-gas-limit` | `FLOW_SCRIPTGASLIMIT` | `100000` | Specify gas limit for script execution |
68+
| `--transaction-max-compute-limit` | `FLOW_TRANSACTIONMAXCOMPUTELIMIT` | `9999` | Maximum [compute limit for transactions](https://docs.onflow.org/flow-go-sdk/building-transactions/#gas-limit) |
69+
| `--script-compute-limit` | `FLOW_SCRIPTCOMPUTELIMIT` | `100000` | Specify compute limit for script execution |
70+
| ~~`--transaction-max-gas-limit`~~ | ~~`FLOW_TRANSACTIONMAXGASLIMIT`~~ | `9999` | **Deprecated:** Use `--transaction-max-compute-limit` instead |
71+
| ~~`--script-gas-limit`~~ | ~~`FLOW_SCRIPTGASLIMIT`~~ | `100000` | **Deprecated:** Use `--script-compute-limit` instead |
7072
| `--coverage-reporting` | `FLOW_COVERAGEREPORTING` | `false` | Enable Cadence code coverage reporting |
7173
| `--contract-removal` | `FLOW_CONTRACTREMOVAL` | `true` | Allow removal of already deployed contracts, used for updating during development |
7274
| `--skip-tx-validation` | `FLOW_SKIPTRANSACTIONVALIDATION` | `false` | Skip verification of transaction signatures and sequence numbers |

cmd/emulator/start/start.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ type Config struct {
6464
StorageMBPerFLOW string `flag:"storage-per-flow" info:"the MB amount of storage capacity an account has per 1 FLOW token it has. e.g. '100.0'. The default is taken from the current version of flow-go"`
6565
MinimumAccountBalance string `flag:"min-account-balance" info:"The minimum account balance of an account. This is also the cost of creating one account. e.g. '0.001'. The default is taken from the current version of flow-go"`
6666
TransactionFeesEnabled bool `default:"false" flag:"transaction-fees" info:"enable transaction fees"`
67-
TransactionMaxGasLimit int `default:"9999" flag:"transaction-max-gas-limit" info:"maximum gas limit for transactions"`
68-
ScriptGasLimit int `default:"100000" flag:"script-gas-limit" info:"gas limit for scripts"`
67+
TransactionMaxGasLimit int `default:"9999" flag:"transaction-max-gas-limit" info:"(deprecated) use --transaction-max-compute-limit"`
68+
ScriptGasLimit int `default:"100000" flag:"script-gas-limit" info:"(deprecated) use --script-compute-limit"`
69+
TransactionMaxComputeLimit int `default:"9999" flag:"transaction-max-compute-limit" info:"maximum compute limit for transactions"`
70+
ScriptComputeLimit int `default:"100000" flag:"script-compute-limit" info:"compute limit for scripts"`
6971
Contracts bool `default:"false" flag:"contracts" info:"deploy common contracts when emulator starts"`
7072
ContractRemovalEnabled bool `default:"true" flag:"contract-removal" info:"allow removal of already deployed contracts, used for updating during development"`
7173
SkipTxValidation bool `default:"false" flag:"skip-tx-validation" info:"skip verification of transaction signatures and sequence numbers"`
@@ -162,6 +164,20 @@ func Cmd(config StartConfig) *cobra.Command {
162164
conf.ForkHeight = conf.StartBlockHeight
163165
}
164166

167+
// Gas/Compute terminology deprecation
168+
if cmd.PersistentFlags().Changed("transaction-max-gas-limit") {
169+
logger.Warn().Msg("❗ --transaction-max-gas-limit is deprecated; use --transaction-max-compute-limit")
170+
if !cmd.PersistentFlags().Changed("transaction-max-compute-limit") {
171+
conf.TransactionMaxComputeLimit = conf.TransactionMaxGasLimit
172+
}
173+
}
174+
if cmd.PersistentFlags().Changed("script-gas-limit") {
175+
logger.Warn().Msg("❗ --script-gas-limit is deprecated; use --script-compute-limit")
176+
if !cmd.PersistentFlags().Changed("script-compute-limit") {
177+
conf.ScriptComputeLimit = conf.ScriptGasLimit
178+
}
179+
}
180+
165181
// In non-fork mode, fork-only flags are invalid
166182
if conf.ForkHost == "" && (conf.StartBlockHeight > 0 || conf.ForkHeight > 0) {
167183
Exit(1, "❗ --fork-height requires --fork-host")
@@ -210,8 +226,8 @@ func Cmd(config StartConfig) *cobra.Command {
210226
Snapshot: conf.Snapshot,
211227
DBPath: conf.DBPath,
212228
GenesisTokenSupply: parseCadenceUFix64(conf.TokenSupply, "token-supply"),
213-
TransactionMaxGasLimit: uint64(conf.TransactionMaxGasLimit),
214-
ScriptGasLimit: uint64(conf.ScriptGasLimit),
229+
TransactionMaxGasLimit: uint64(conf.TransactionMaxComputeLimit),
230+
ScriptGasLimit: uint64(conf.ScriptComputeLimit),
215231
TransactionExpiry: uint(conf.TransactionExpiry),
216232
StorageLimitEnabled: conf.StorageLimitEnabled,
217233
StorageMBPerFLOW: storageMBPerFLOW,
@@ -274,6 +290,10 @@ func Cmd(config StartConfig) *cobra.Command {
274290
_ = cmd.PersistentFlags().MarkDeprecated("rpc-host", "use --fork-host")
275291
_ = cmd.PersistentFlags().MarkHidden("start-block-height")
276292
_ = cmd.PersistentFlags().MarkDeprecated("start-block-height", "use --fork-height")
293+
_ = cmd.PersistentFlags().MarkHidden("transaction-max-gas-limit")
294+
_ = cmd.PersistentFlags().MarkDeprecated("transaction-max-gas-limit", "use --transaction-max-compute-limit")
295+
_ = cmd.PersistentFlags().MarkHidden("script-gas-limit")
296+
_ = cmd.PersistentFlags().MarkDeprecated("script-gas-limit", "use --script-compute-limit")
277297

278298
return cmd
279299
}

docs/overview.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ values.
6565
| `--storage-per-flow` | `FLOW_STORAGEMBPERFLOW` | | Specify size of the storage in MB for each FLOW in account balance. Default value from the flow-go |
6666
| `--min-account-balance` | `FLOW_MINIMUMACCOUNTBALANCE` | | Specify minimum balance the account must have. Default value from the flow-go |
6767
| `--transaction-fees` | `FLOW_TRANSACTIONFEESENABLED` | `false` | Enable variable transaction fees and execution effort metering <br> as described in [Variable Transaction Fees: Execution Effort](https://github.com/onflow/flow/pull/753) FLIP |
68-
| `--transaction-max-gas-limit` | `FLOW_TRANSACTIONMAXGASLIMIT` | `9999` | Maximum [gas limit for transactions](https://docs.onflow.org/flow-go-sdk/building-transactions/#gas-limit) |
69-
| `--script-gas-limit` | `FLOW_SCRIPTGASLIMIT` | `100000` | Specify gas limit for script execution |
68+
| `--transaction-max-compute-limit` | `FLOW_TRANSACTIONMAXCOMPUTELIMIT` | `9999` | Maximum [compute limit for transactions](https://docs.onflow.org/flow-go-sdk/building-transactions/#gas-limit) |
69+
| `--script-compute-limit` | `FLOW_SCRIPTCOMPUTELIMIT` | `100000` | Specify compute limit for script execution |
70+
| ~~`--transaction-max-gas-limit`~~ | ~~`FLOW_TRANSACTIONMAXGASLIMIT`~~ | `9999` | **Deprecated:** Use `--transaction-max-compute-limit` instead |
71+
| ~~`--script-gas-limit`~~ | ~~`FLOW_SCRIPTGASLIMIT`~~ | `100000` | **Deprecated:** Use `--script-compute-limit` instead |
7072
| `--with-contracts` | `FLOW_WITHCONTRACTS` | `false` | Deploy common contracts when emulator starts |
7173
| `--coverage-reporting` | `FLOW_COVERAGEREPORTING` | `false` | Enable Cadence code coverage reporting |
7274
| `--skip-transaction-validation` | `FLOW_SKIPTRANSACTIONVALIDATION` | `false` | Skip verification of transaction signatures and sequence numbers |

types/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ type InvalidTransactionGasLimitError struct {
181181
func (e *InvalidTransactionGasLimitError) isTransactionValidationError() {}
182182

183183
func (e *InvalidTransactionGasLimitError) Error() string {
184-
return fmt.Sprintf("transaction gas limit (%d) exceeds the maximum gas limit (%d)", e.Actual, e.Maximum)
184+
return fmt.Sprintf("transaction compute limit (%d) exceeds the maximum compute limit (%d)", e.Actual, e.Maximum)
185185
}
186186

187187
// An InvalidStateVersionError indicates that a state version hash provided is invalid.

utils/logging.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ func PrintScriptResult(logger *zerolog.Logger, result *types.ScriptResult) {
3232
if result.Succeeded() {
3333
logger.Debug().
3434
Str("scriptID", result.ScriptID.String()).
35-
Uint64("computationUsed", result.ComputationUsed).
35+
Uint64("computeUnitsUsed", result.ComputationUsed).
3636
Uint64("memoryEstimate", result.MemoryEstimate).
3737
Msg("⭐ Script executed")
3838
} else {
3939
logger.Warn().
4040
Str("scriptID", result.ScriptID.String()).
41-
Uint64("computationUsed", result.ComputationUsed).
41+
Uint64("computeUnitsUsed", result.ComputationUsed).
4242
Uint64("memoryEstimate", result.MemoryEstimate).
4343
Msg("❗ Script reverted")
4444
}
@@ -56,13 +56,13 @@ func PrintTransactionResult(logger *zerolog.Logger, result *types.TransactionRes
5656
if result.Succeeded() {
5757
logger.Debug().
5858
Str("txID", result.TransactionID.String()).
59-
Uint64("computationUsed", result.ComputationUsed).
59+
Uint64("computeUnitsUsed", result.ComputationUsed).
6060
Uint64("memoryEstimate", result.MemoryEstimate).
6161
Msg("⭐ Transaction executed")
6262
} else {
6363
logger.Warn().
6464
Str("txID", result.TransactionID.String()).
65-
Uint64("computationUsed", result.ComputationUsed).
65+
Uint64("computeUnitsUsed", result.ComputationUsed).
6666
Uint64("memoryEstimate", result.MemoryEstimate).
6767
Msg("❗ Transaction reverted")
6868
}
@@ -95,15 +95,15 @@ func PrintScheduledTransactionResult(logger *zerolog.Logger, result *types.Trans
9595
logger.Debug().
9696
Str("systemTxId", result.TransactionID.String()).
9797
Str("scheduledTxId", scheduledTxID).
98-
Uint64("computationUsed", result.ComputationUsed).
98+
Uint64("computeUnitsUsed", result.ComputationUsed).
9999
Uint64("memoryEstimate", result.MemoryEstimate).
100100
Str("kind", "scheduled").
101101
Msg("⏱️ Scheduled transaction executed")
102102
} else {
103103
logger.Warn().
104104
Str("systemTxId", result.TransactionID.String()).
105105
Str("scheduledTxId", scheduledTxID).
106-
Uint64("computationUsed", result.ComputationUsed).
106+
Uint64("computeUnitsUsed", result.ComputationUsed).
107107
Uint64("memoryEstimate", result.MemoryEstimate).
108108
Str("kind", "scheduled").
109109
Msg("❗ Scheduled transaction reverted")

0 commit comments

Comments
 (0)