aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6.18k stars 3.65k forks source link

[Bug] Remove unused flags from `aptos move build-publish-payload` #10748

Open gregnazario opened 1 year ago

gregnazario commented 1 year ago

There's a ton of transaction submission flags in this command, though it doesn't submit a transaction. We should clean this up.

aptos move build-publish-payload --help
Build a publication transaction payload and store it in a JSON output file

Usage: aptos move build-publish-payload [OPTIONS] --json-output-file <JSON_OUTPUT_FILE>

Options:
      --override-size-check
          Whether to override the check for maximal size of published data

      --included-artifacts <INCLUDED_ARTIFACTS>
          Artifacts to be generated when building the package

          Which artifacts to include in the package. This can be one of `none`, `sparse`, and `all`. `none` is the most compact form and does not allow to reconstruct a source package from chain; `sparse` is the minimal set of artifacts needed to reconstruct a source package; `all` includes all available artifacts. The choice of included artifacts heavily influences the size and therefore gas cost of publishing: `none` is the size of bytecode alone; `sparse` is roughly 2 times as much; and `all` 3-4 as much.

          [default: sparse]
          [possible values: none, sparse, all]

      --dev
          Enables dev mode, which uses all dev-addresses and dev-dependencies

          Dev mode allows for changing dependencies and addresses to the preset [dev-addresses] and [dev-dependencies] fields.  This works both inside and out of tests for using preset values.

          Currently, it also additionally pulls in all test compilation artifacts

      --package-dir <PACKAGE_DIR>
          Path to a move package (the folder with a Move.toml file)

      --output-dir <OUTPUT_DIR>
          Path to save the compiled move package

          Defaults to `<package_dir>/build`

      --named-addresses <NAMED_ADDRESSES>
          Named addresses for the move binary

          Example: alice=0x1234, bob=0x5678

          Note: This will fail if there are duplicates in the Move.toml file remove those first.

          [default: ]

      --skip-fetch-latest-git-deps
          Skip pulling the latest git dependencies

          If you don't have a network connection, the compiler may fail due to no ability to pull git dependencies.  This will allow overriding this for local development.

      --bytecode-version <BYTECODE_VERSION>
          Specify the version of the bytecode the compiler is going to emit

      --compiler-version <COMPILER_VERSION>
          Specify the version of the compiler

          [possible values: v1, v2]

      --skip-attribute-checks
          Do not complain about unknown attributes in Move code

      --check-test-code
          Do apply extended checks for Aptos (e.g. `#[view]` attribute) also on test code. NOTE: this behavior will become the default in the future. See https://github.com/aptos-labs/aptos-core/issues/10335

          [env: APTOS_CHECK_TEST_CODE=]

      --sender-account <SENDER_ACCOUNT>
          Sender account address

          This allows you to override the account address from the derived account address in the event that the authentication key was rotated or for a resource account

      --private-key-file <PRIVATE_KEY_FILE>
          Signing Ed25519 private key file path

          Encoded with type from `--encoding` Mutually exclusive with `--private-key`

      --private-key <PRIVATE_KEY>
          Signing Ed25519 private key

          Encoded with type from `--encoding` Mutually exclusive with `--private-key-file`

      --encoding <ENCODING>
          Encoding of data as one of [base64, bcs, hex]

          [default: hex]

      --profile <PROFILE>
          Profile to use from the CLI config

          This will be used to override associated settings such as the REST URL, the Faucet URL, and the private key arguments.

          Defaults to "default"

      --url <URL>
          URL to a fullnode on the network

          Defaults to the URL in the `default` profile

      --connection-timeout-secs <CONNECTION_TIMEOUT_SECS>
          Connection timeout in seconds, used for the REST endpoint of the fullnode

          [default: 30]

      --gas-unit-price <GAS_UNIT_PRICE>
          Gas multiplier per unit of gas

          The amount of Octas (10^-8 APT) used for a transaction is equal to (gas unit price * gas used).  The gas_unit_price can be used as a multiplier for the amount of Octas willing to be paid for a transaction.  This will prioritize the transaction with a higher gas unit price.

          Without a value, it will determine the price based on the current estimated price

      --max-gas <MAX_GAS>
          Maximum amount of gas units to be used to send this transaction

          The maximum amount of gas units willing to pay for the transaction. This is the (max gas in Octas / gas unit price).

          For example if I wanted to pay a maximum of 100 Octas, I may have the max gas set to 100 if the gas unit price is 1.  If I want it to have a gas unit price of 2, the max gas would need to be 50 to still only have a maximum price of 100 Octas.

          Without a value, it will determine the price based on simulating the current transaction

      --expiration-secs <EXPIRATION_SECS>
          Number of seconds to expire the transaction

          This is the number of seconds from the current local computer time.

          [default: 30]

      --assume-yes
          Assume yes for all yes/no prompts

      --assume-no
          Assume no for all yes/no prompts

      --profile-gas
          If this option is set, simulate the transaction locally using the debugger and generate flamegraphs that reflect the gas usage

      --json-output-file <JSON_OUTPUT_FILE>
          JSON output file to write publication transaction to

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version
cylim commented 9 months ago

@gregnazario

let save_file = SaveFile {
    output_file: self.json_output_file,
    prompt_options: self.publish_package.txn_options.prompt_options,
};

ref: https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos/src/move_tool/mod.rs#L839-L841

My first thoughts was to have a BuildPackageBase removing the txn_options which can re-use in other part, but then I realized the buildPublishPayload is using prompt_options from txn_options. I guess it should be safe to remove and make it as a separated flag?

gregnazario commented 9 months ago

@gregnazario

let save_file = SaveFile {
    output_file: self.json_output_file,
    prompt_options: self.publish_package.txn_options.prompt_options,
};

ref: https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos/src/move_tool/mod.rs#L839-L841

My first thoughts was to have a BuildPackageBase removing the txn_options which can re-use in other part, but then I realized the buildPublishPayload is using prompt_options from txn_options. I guess it should be safe to remove and make it as a separated flag?

prompt_options are needed for named addresses, but this can be added separately from txn_options and remove txn_options