aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[cli] Sign now execute later, basic Cold wallet

Open gregnazario opened this issue 3 years ago • 14 comments
trafficstars

Description

This lets you sign a transaction disconnected from the internet, and submit it later. Useful if you want to have a "cold" key, and disconnected from the internet, but still want to execute transactions.

Test Plan

With simulation

$ aptos account transfer --signed-transaction-path saved_txn --account testing --amount 500 --transaction-expiration-secs 500
Do you want to submit a transaction for a range of [55200 - 82800] Octas at a gas unit price of 100 Octas? [yes/no] >
yes
{
  "Result": {
    "transaction_hash": "0x1b5eb3b3d052571f07a0feca73610055aa6dbb0ae4c12ead1ae393fc205acdd5",
    "saved_transaction_path": "saved_txn"
  }
}

$ cat saved_txn 
B6DBF76636021A840C64DA0CA6AA94297B4EAD015F7398521F57347F6836489801000000000000000200000000000000000000000000000000000000000000000000000000000000010D6170746F735F6163636F756E74087472616E7366657200022001C434E9243F7EDC17AFCBA6144CED93198CF37CBCBE574B4D2D00F756FE92B908F4010000000000003C0300000000000064000000000000002ACB4963000000002200204C9FB933051300FABFB4515F924353D5272E5AFCAE927DE1138BFE813137F30A40CE5F131E0D68FD0B9BC52A20670A155B6A9B05F50300FB9933917315384BA724BF6E088FE8ED91F6B94D17B37283914DF7253D4C16E3927E492AD389AE36AE0E

$ aptos move run-signed-transaction --signed-transaction-path saved_txn
{
  "Result": {
    "transaction_hash": "0x1b5eb3b3d052571f07a0feca73610055aa6dbb0ae4c12ead1ae393fc205acdd5",
    "gas_used": 585,
    "gas_unit_price": 100,
    "sender": "b6dbf76636021a840c64da0ca6aa94297b4ead015f7398521f57347f68364898",
    "sequence_number": 1,
    "success": true,
    "timestamp_us": 1665780501649736,
    "version": 1618454,
    "vm_status": "Executed successfully"
  }
}

With no simulation

$ aptos account transfer --signed-transaction-path saved_txn --account testing --amo
unt 500 --transaction-expiration-secs 1000 --sequence-number 2 --max-gas 30000 --gas-unit-price 100
{
  "Result": {
    "transaction_hash": "0xa495843646a83ee80267467aca7fbb2e0c0944dfd60a81a98676d9b31ed4e53c",
    "saved_transaction_path": "saved_txn"
  }
}
$ aptos 
move run-signed-transaction --signed-transaction-path saved_txn
{
  "Result": {
    "transaction_hash": "0xa495843646a83ee80267467aca7fbb2e0c0944dfd60a81a98676d9b31ed4e53c",
    "gas_used": 585,
    "gas_unit_price": 100,
    "sender": "b6dbf76636021a840c64da0ca6aa94297b4ead015f7398521f57347f68364898",
    "sequence_number": 2,
    "success": true,
    "timestamp_us": 1665780926888643,
    "version": 1625649,
    "vm_status": "Executed successfully"
  }
}

With no network connection

$ curl https://fullnode.devnet.aptoslabs.com/v1
{"chain_id":34,"epoch":"13","ledger_version":"1633806","oldest_ledger_version":"0","ledger_timestamp":"1665781417161896","node_role":"full_node","oldest_block_height":"0","block_height":"645538","git_hash":"83641d3f083762f31700060e5e95fbb1cbc28bf0"}%                                                      
$ aptos account transfer --signed-transaction-path saved_txn --account testing --amount 500 --transaction-expiration-secs 1000 --sequence-number 3 --max-gas 30000 --gas-unit-price 100 --chain-id 34
{
  "Result": {
    "transaction_hash": "0x8a2654c1827d076e69c6ec2d5b4cfa9e0e31898229f7061762565aced0452654",
    "saved_transaction_path": "saved_txn"
  }
}
$ curl https://fullnode.devnet.aptoslabs.com/v1
curl: (6) Could not resolve host: fullnode.devnet.aptoslabs.com
$ aptos account transfer --signed-transaction-path saved_txn --account testing --amount 500 --transaction-expiration-secs 1000 --sequence-number 3 --max-gas 30000 --gas-unit-price 100 --chain-id 34
{
  "Result": {
    "transaction_hash": "0x3b20c27afb28e043873290f61dc07dff43f59cfa18a5b8f8fff787deaa5ea724",
    "saved_transaction_path": "saved_txn"
  }
}
$ curl https://fullnode.devnet.aptoslabs.com/v1
{"chain_id":34,"epoch":"13","ledger_version":"1634457","oldest_ledger_version":"0","ledger_timestamp":"1665781452427486","node_role":"full_node","oldest_block_height":"0","block_height":"645802","git_hash":"83641d3f083762f31700060e5e95fbb1cbc28bf0"}%                                                      
$ aptos move run-signed-transaction --signed-transaction-path saved_txn
{
  "Result": {
    "transaction_hash": "0x3b20c27afb28e043873290f61dc07dff43f59cfa18a5b8f8fff787deaa5ea724",
    "gas_used": 585,
    "gas_unit_price": 100,
    "sender": "b6dbf76636021a840c64da0ca6aa94297b4ead015f7398521f57347f68364898",
    "sequence_number": 3,
    "success": true,
    "timestamp_us": 1665781458178844,
    "version": 1634559,
    "vm_status": "Executed successfully"
  }
}

This change is Reviewable

gregnazario avatar Oct 14 '22 14:10 gregnazario

Forge is running suite land_blocking on 9b5a82908db6add2f821ebc1a348659846877149

github-actions[bot] avatar Oct 17 '22 03:10 github-actions[bot]

Forge is running suite compat on 843b204dce971d98449b82624f4f684c7a18b991 ==> 9b5a82908db6add2f821ebc1a348659846877149

github-actions[bot] avatar Oct 17 '22 03:10 github-actions[bot]

:x: Forge suite compat failure on 843b204dce971d98449b82624f4f684c7a18b991 ==> 9b5a82908db6add2f821ebc1a348659846877149

Forge test runner terminated:
Trailing Log Lines:
Error from server (BadRequest): container "genesis" in pod "genesis-aptos-genesis-eforge134-nh2jx" is waiting to start: trying and failing to pull image
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:81"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665977064-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:34:57.196734Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T03:25:11Z)), succeeded: None }"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:63"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665977064-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:35:07.203990Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T03:25:11Z)), succeeded: None }"}
Error from server (BadRequest): container "genesis" in pod "genesis-aptos-genesis-eforge134-nh2jx" is waiting to start: trying and failing to pull image
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:81"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665977064-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:35:07.270156Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T03:25:11Z)), succeeded: None }"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:280"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665977064-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:35:07.289560Z","message":"Deleting namespace forge-compat-pr-5040: Some(NamespaceStatus { phase: Some(\"Terminating\") })"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:388"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665977064-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:35:07.289587Z","message":"aptos-node resources for Forge removed in namespace: forge-compat-pr-5040"}
Failed to run tests:
Genesis did not succeed
Error: Genesis did not succeed
Debugging output:
NAME                                    READY   STATUS        RESTARTS   AGE
genesis-aptos-genesis-eforge134-nh2jx   0/1     Terminating   0          10m

github-actions[bot] avatar Oct 17 '22 03:10 github-actions[bot]

:white_check_mark: Forge suite land_blocking success on 9b5a82908db6add2f821ebc1a348659846877149

performance benchmark with full nodes : 6279 TPS, 6351 ms latency, 10800 ms p99 latency,(!) expired 660 out of 2682160 txns
Test Ok

github-actions[bot] avatar Oct 17 '22 03:10 github-actions[bot]

Forge is running suite compat on 843b204dce971d98449b82624f4f684c7a18b991 ==> 9b5a82908db6add2f821ebc1a348659846877149

github-actions[bot] avatar Oct 17 '22 03:10 github-actions[bot]

:x: Forge suite compat failure on 843b204dce971d98449b82624f4f684c7a18b991 ==> 9b5a82908db6add2f821ebc1a348659846877149

Forge test runner terminated:
Trailing Log Lines:
Error from server (BadRequest): container "genesis" in pod "genesis-aptos-genesis-eforge204-cxkvn" is waiting to start: trying and failing to pull image
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:81"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665978553-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:59:48.917434Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T03:50:03Z)), succeeded: None }"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:63"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665978553-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:59:58.923121Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T03:50:03Z)), succeeded: None }"}
Error from server (BadRequest): container "genesis" in pod "genesis-aptos-genesis-eforge204-cxkvn" is waiting to start: trying and failing to pull image
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:81"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665978553-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:59:58.997223Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T03:50:03Z)), succeeded: None }"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:280"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665978553-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:59:59.016867Z","message":"Deleting namespace forge-compat-pr-5040: Some(NamespaceStatus { phase: Some(\"Terminating\") })"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:388"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665978553-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T03:59:59.016896Z","message":"aptos-node resources for Forge removed in namespace: forge-compat-pr-5040"}
Failed to run tests:
Genesis did not succeed
Error: Genesis did not succeed
Debugging output:
NAME                                    READY   STATUS        RESTARTS   AGE
genesis-aptos-genesis-eforge204-cxkvn   0/1     Terminating   0          10m

github-actions[bot] avatar Oct 17 '22 04:10 github-actions[bot]

I'm not sure about the API here, I feel this might lead to some confusion. At the least I'd name the flag something like --save-transaction-to or something like that, the flag name now implies to me that it's referring to something that already exists. Beyond that this feels like a few of large ish changes, like you say, might be better to save this for post 1.0.0 so we can discuss some more (for example this could be something you configure in your profile).

Yeah, that's fair, it was pretty quick. Will update later

gregnazario avatar Oct 17 '22 05:10 gregnazario

Forge is running suite land_blocking on 6b30e71235d7ade91d3d41a16f8dcfc2f1f54944

github-actions[bot] avatar Oct 17 '22 06:10 github-actions[bot]

Forge is running suite compat on 843b204dce971d98449b82624f4f684c7a18b991 ==> 6b30e71235d7ade91d3d41a16f8dcfc2f1f54944

github-actions[bot] avatar Oct 17 '22 06:10 github-actions[bot]

:x: Forge suite compat failure on 843b204dce971d98449b82624f4f684c7a18b991 ==> 6b30e71235d7ade91d3d41a16f8dcfc2f1f54944

Forge test runner terminated:
Trailing Log Lines:
Error from server (BadRequest): container "genesis" in pod "genesis-aptos-genesis-eforge225-v5rrx" is waiting to start: trying and failing to pull image
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:81"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665988905-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T06:52:22.518582Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T06:42:35Z)), succeeded: None }"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:63"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665988905-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T06:52:32.526015Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T06:42:35Z)), succeeded: None }"}
Error from server (BadRequest): container "genesis" in pod "genesis-aptos-genesis-eforge225-v5rrx" is waiting to start: trying and failing to pull image
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:81"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665988905-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T06:52:32.615826Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-17T06:42:35Z)), succeeded: None }"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:280"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665988905-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T06:52:32.637277Z","message":"Deleting namespace forge-compat-pr-5040: Some(NamespaceStatus { phase: Some(\"Terminating\") })"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:388"},"thread_name":"main","hostname":"forge-compat-pr-5040-1665988905-843b204dce971d98449b82624f4f684","timestamp":"2022-10-17T06:52:32.637310Z","message":"aptos-node resources for Forge removed in namespace: forge-compat-pr-5040"}
Failed to run tests:
Genesis did not succeed
Error: Genesis did not succeed
Debugging output:
NAME                                    READY   STATUS        RESTARTS   AGE
genesis-aptos-genesis-eforge225-v5rrx   0/1     Terminating   0          10m

github-actions[bot] avatar Oct 17 '22 06:10 github-actions[bot]

:white_check_mark: Forge suite land_blocking success on 6b30e71235d7ade91d3d41a16f8dcfc2f1f54944

performance benchmark with full nodes : 6527 TPS, 6071 ms latency, 10800 ms p99 latency,(!) expired 1447 out of 2788520 txns
Test Ok

github-actions[bot] avatar Oct 17 '22 06:10 github-actions[bot]

Forge is running suite compat on 843b204dce971d98449b82624f4f684c7a18b991 ==> 6b30e71235d7ade91d3d41a16f8dcfc2f1f54944

github-actions[bot] avatar Oct 18 '22 06:10 github-actions[bot]

:x: Forge suite compat failure on 843b204dce971d98449b82624f4f684c7a18b991 ==> 6b30e71235d7ade91d3d41a16f8dcfc2f1f54944

Forge test runner terminated:
Trailing Log Lines:
Error from server (BadRequest): container "genesis" in pod "genesis-aptos-genesis-eforge8-rx58k" is waiting to start: trying and failing to pull image
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:81"},"thread_name":"main","hostname":"forge-compat-pr-5040-1666073392-843b204dce971d98449b82624f4f684","timestamp":"2022-10-18T06:20:33.204197Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-18T06:10:47Z)), succeeded: None }"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:63"},"thread_name":"main","hostname":"forge-compat-pr-5040-1666073392-843b204dce971d98449b82624f4f684","timestamp":"2022-10-18T06:20:43.209291Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-18T06:10:47Z)), succeeded: None }"}
Error from server (BadRequest): container "genesis" in pod "genesis-aptos-genesis-eforge8-rx58k" is waiting to start: trying and failing to pull image
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:81"},"thread_name":"main","hostname":"forge-compat-pr-5040-1666073392-843b204dce971d98449b82624f4f684","timestamp":"2022-10-18T06:20:43.277279Z","message":"Genesis status: JobStatus { active: Some(1), completion_time: None, conditions: None, failed: None, start_time: Some(Time(2022-10-18T06:10:47Z)), succeeded: None }"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:280"},"thread_name":"main","hostname":"forge-compat-pr-5040-1666073392-843b204dce971d98449b82624f4f684","timestamp":"2022-10-18T06:20:43.298445Z","message":"Deleting namespace forge-compat-pr-5040: Some(NamespaceStatus { phase: Some(\"Terminating\") })"}
{"level":"INFO","source":{"package":"forge","file":"testsuite/forge/src/backend/k8s/cluster_helper.rs:388"},"thread_name":"main","hostname":"forge-compat-pr-5040-1666073392-843b204dce971d98449b82624f4f684","timestamp":"2022-10-18T06:20:43.298465Z","message":"aptos-node resources for Forge removed in namespace: forge-compat-pr-5040"}
Failed to run tests:
Genesis did not succeed
Error: Genesis did not succeed
Debugging output:
NAME                                  READY   STATUS        RESTARTS   AGE
genesis-aptos-genesis-eforge8-rx58k   0/1     Terminating   0          10m

github-actions[bot] avatar Oct 18 '22 06:10 github-actions[bot]

Seems good, needs a refresh Some of these commits aren't super crisp, might as well be one commit.

davidiw avatar Nov 05 '22 20:11 davidiw

/cough/

davidiw avatar Dec 03 '22 21:12 davidiw

/cough/

This has some merge conflicts with the other CLI changes, the other ones are more important, so they will be addressed first then come back to this.

gregnazario avatar Dec 07 '22 20:12 gregnazario

Updated to handle merge conflicts

gregnazario avatar Dec 28 '22 22:12 gregnazario

Will look next week.

banool avatar Dec 28 '22 22:12 banool