From 19a3a0a0dd4109763f29a43c53ba382e7cb552b3 Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 14 Jun 2022 17:07:22 -0400 Subject: [PATCH] [aptos-genesis] Add new Genesis builder for using the new Genesis tool The new genesis tool can now be used for tests because it's integrated with the builder paradigm used by forge and the local test node. Closes: #1417 --- Cargo.lock | 49 +- Cargo.toml | 1 + api/Cargo.toml | 2 +- ...unts_test__test_get_core_account_data.json | 2 +- ...nsaction_with_script_function_payload.json | 32 +- ...e_when_start_version_is_not_specified.json | 284 +++++----- ...ed_by_invalid_module_payload_bytecode.json | 6 +- ...ed_by_invalid_script_function_address.json | 6 +- ..._by_invalid_script_function_arguments.json | 6 +- ...y_invalid_script_function_module_name.json | 6 +- ...ailed_by_invalid_script_function_name.json | 6 +- ...ed_by_invalid_script_payload_bytecode.json | 6 +- ..._by_missing_script_function_arguments.json | 6 +- ..._failed_by_script_function_validation.json | 18 +- ...est__test_post_bcs_format_transaction.json | 6 +- api/src/tests/test_context.rs | 31 +- aptos-node/Cargo.toml | 2 +- aptos-node/src/lib.rs | 14 +- .../management/genesis/src/config_builder.rs | 69 --- .../genesis/src/fullnode_builder.rs | 171 ------ config/management/genesis/src/lib.rs | 6 - .../genesis/src/validator_builder.rs | 416 -------------- config/src/config/safety_rules_config.rs | 7 + crates/aptos-genesis/Cargo.toml | 44 ++ crates/aptos-genesis/src/builder.rs | 521 ++++++++++++++++++ .../genesis => aptos-genesis/src}/config.rs | 74 ++- crates/aptos-genesis/src/keys.rs | 85 +++ crates/aptos-genesis/src/lib.rs | 91 +++ crates/aptos-genesis/src/test_utils.rs | 44 ++ crates/aptos/Cargo.toml | 1 + crates/aptos/src/common/types.rs | 6 + crates/aptos/src/genesis/git.rs | 2 +- crates/aptos/src/genesis/keys.rs | 60 +- crates/aptos/src/genesis/mod.rs | 94 ++-- crates/aptos/src/genesis/tests.rs | 51 +- crates/aptos/src/test/mod.rs | 2 +- execution/executor-benchmark/Cargo.toml | 2 +- .../benches/executor_benchmark.rs | 2 +- .../executor-benchmark/src/db_generator.rs | 2 +- execution/executor-benchmark/src/lib.rs | 2 +- execution/executor-test-helpers/Cargo.toml | 2 +- execution/executor-test-helpers/src/lib.rs | 2 +- execution/executor/Cargo.toml | 2 +- state-sync/state-sync-v1/Cargo.toml | 2 +- .../state-sync-multiplexer/Cargo.toml | 2 +- .../state-sync-multiplexer/src/lib.rs | 2 +- testsuite/forge/Cargo.toml | 2 +- testsuite/forge/src/backend/local/swarm.rs | 33 +- testsuite/smoke-test/Cargo.toml | 2 +- 49 files changed, 1210 insertions(+), 1074 deletions(-) delete mode 100644 config/management/genesis/src/config_builder.rs delete mode 100644 config/management/genesis/src/fullnode_builder.rs delete mode 100644 config/management/genesis/src/validator_builder.rs create mode 100644 crates/aptos-genesis/Cargo.toml create mode 100644 crates/aptos-genesis/src/builder.rs rename crates/{aptos/src/genesis => aptos-genesis/src}/config.rs (78%) create mode 100644 crates/aptos-genesis/src/keys.rs create mode 100644 crates/aptos-genesis/src/lib.rs create mode 100644 crates/aptos-genesis/src/test_utils.rs diff --git a/Cargo.lock b/Cargo.lock index 3c66b958ed7c1..c0a25d252ae28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -134,6 +134,7 @@ dependencies = [ "anyhow", "aptos-config", "aptos-crypto", + "aptos-genesis", "aptos-github-client", "aptos-keygen", "aptos-logger", @@ -182,7 +183,7 @@ dependencies = [ "aptos-api-types", "aptos-config", "aptos-crypto", - "aptos-genesis-tool", + "aptos-genesis", "aptos-global-constants", "aptos-logger", "aptos-mempool", @@ -436,6 +437,36 @@ dependencies = [ "structopt", ] +[[package]] +name = "aptos-genesis" +version = "0.1.0" +dependencies = [ + "anyhow", + "aptos-config", + "aptos-crypto", + "aptos-global-constants", + "aptos-keygen", + "aptos-management", + "aptos-secure-storage", + "aptos-state-view", + "aptos-temppath", + "aptos-types", + "aptos-vm", + "aptos-workspace-hack", + "aptosdb", + "bcs", + "cached-framework-packages", + "consensus-types", + "executor", + "rand 0.7.3", + "serde 1.0.137", + "serde_yaml", + "storage-interface", + "structopt", + "toml", + "vm-genesis", +] + [[package]] name = "aptos-genesis-tool" version = "0.1.0" @@ -687,7 +718,7 @@ dependencies = [ "aptos-config", "aptos-crypto", "aptos-data-client", - "aptos-genesis-tool", + "aptos-genesis", "aptos-infallible", "aptos-logger", "aptos-mempool", @@ -2949,7 +2980,7 @@ dependencies = [ "anyhow", "aptos-config", "aptos-crypto", - "aptos-genesis-tool", + "aptos-genesis", "aptos-infallible", "aptos-logger", "aptos-metrics-core", @@ -2984,7 +3015,7 @@ version = "0.1.0" dependencies = [ "aptos-config", "aptos-crypto", - "aptos-genesis-tool", + "aptos-genesis", "aptos-infallible", "aptos-jellyfish-merkle", "aptos-logger", @@ -3023,7 +3054,7 @@ dependencies = [ "anyhow", "aptos-config", "aptos-crypto", - "aptos-genesis-tool", + "aptos-genesis", "aptos-sdk", "aptos-state-view", "aptos-temppath", @@ -3159,7 +3190,7 @@ dependencies = [ "anyhow", "aptos-config", "aptos-faucet", - "aptos-genesis-tool", + "aptos-genesis", "aptos-logger", "aptos-rest-client", "aptos-retrier", @@ -7549,7 +7580,7 @@ dependencies = [ "aptos-config", "aptos-crypto", "aptos-faucet", - "aptos-genesis-tool", + "aptos-genesis", "aptos-global-constants", "aptos-indexer", "aptos-infallible", @@ -7669,7 +7700,7 @@ dependencies = [ "aptos-config", "aptos-crypto", "aptos-data-client", - "aptos-genesis-tool", + "aptos-genesis", "aptos-infallible", "aptos-temppath", "aptos-time-service", @@ -7699,7 +7730,7 @@ version = "0.1.0" dependencies = [ "aptos-config", "aptos-crypto", - "aptos-genesis-tool", + "aptos-genesis", "aptos-infallible", "aptos-logger", "aptos-mempool", diff --git a/Cargo.toml b/Cargo.toml index f80ce17bced75..935eb9f006190 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ members = [ "crates/aptos-crypto", "crates/aptos-crypto-derive", "crates/aptos-faucet", + "crates/aptos-genesis", "crates/aptos-id-generator", "crates/aptos-infallible", "crates/aptos-keygen", diff --git a/api/Cargo.toml b/api/Cargo.toml index 083cf3c8b84ea..f1f3ff7ab6c4c 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -45,7 +45,7 @@ regex = "1.5.5" reqwest = { version = "0.11.10", features = ["blocking", "json"], default_features = false } aptos-crypto = { path = "../crates/aptos-crypto" } -aptos-genesis-tool = { path = "../config/management/genesis", features = ["testing"] } +aptos-genesis = { path = "../crates/aptos-genesis", features = ["testing"] } aptos-global-constants = { path = "../config/global-constants" } aptos-mempool = { path = "../mempool", features = ["fuzzing"] } aptos-proptest-helpers = { path = "../crates/aptos-proptest-helpers" } diff --git a/api/goldens/aptos_api__tests__accounts_test__test_get_core_account_data.json b/api/goldens/aptos_api__tests__accounts_test__test_get_core_account_data.json index c271bb498b219..c550a085a6c47 100644 --- a/api/goldens/aptos_api__tests__accounts_test__test_get_core_account_data.json +++ b/api/goldens/aptos_api__tests__accounts_test__test_get_core_account_data.json @@ -1,4 +1,4 @@ { "sequence_number": "0", - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510" + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a" } diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_script_function_payload.json b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_script_function_payload.json index c98410dfe97f5..b04394e6ced45 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_script_function_payload.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_script_function_payload.json @@ -60,13 +60,13 @@ } } ], - "id": "0xe52bfb76e51cca8b4e9016838657edfae09cb9a71eb219025c4c87a67c4aaa86", + "id": "0x4e9016838657edfae09cb9a71eb219025c4c87a67c4aaa86f20ac0aa792bc121", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "1" }, { @@ -87,7 +87,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "1" } @@ -132,20 +132,20 @@ }, { "type": "write_resource", - "address": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", - "self_address": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "authentication_key": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", + "self_address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -155,7 +155,7 @@ "guid": { "guid": { "id": { - "addr": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "addr": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "creation_num": "0" } }, @@ -167,7 +167,7 @@ }, { "type": "write_resource", - "address": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -180,7 +180,7 @@ "guid": { "guid": { "id": { - "addr": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "addr": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "creation_num": "1" } }, @@ -192,7 +192,7 @@ "guid": { "guid": { "id": { - "addr": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "addr": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "creation_num": "2" } }, @@ -204,7 +204,7 @@ }, { "type": "write_resource", - "address": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -224,17 +224,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea" + "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x2496d9a46e38adcadfb09e2aa27882f3f1bbe52b1087ce75ae3bae2b4bad1f4ca8a40fed59608be896e6d56b83f1b0a76aade5b352b4f081ad3d914cb8436205" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x3d03661e4b3fffc4048c41046479b708e445116e391fc417ddc961b33a6752c238b5a794dc5c2af60f0741692bb4fc677203ca96a4dc7758296880e1489ca807" }, "events": [ { - "key": "0x0000000000000000d30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "key": "0x000000000000000034bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json index b6b8c99da89da..4e12a8140e85b 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_returns_last_page_when_start_version_is_not_specified.json @@ -17,7 +17,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "12" } @@ -62,20 +62,20 @@ }, { "type": "write_resource", - "address": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "address": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", - "self_address": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "authentication_key": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", + "self_address": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "address": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -85,7 +85,7 @@ "guid": { "guid": { "id": { - "addr": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "addr": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "creation_num": "0" } }, @@ -97,7 +97,7 @@ }, { "type": "write_resource", - "address": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "address": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -110,7 +110,7 @@ "guid": { "guid": { "id": { - "addr": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "addr": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "creation_num": "1" } }, @@ -122,7 +122,7 @@ "guid": { "guid": { "id": { - "addr": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "addr": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "creation_num": "2" } }, @@ -134,7 +134,7 @@ }, { "type": "write_resource", - "address": "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "address": "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -154,17 +154,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0x9cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd" + "0x7ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0xc892e6b408febef6c92500a1e625123ae513324755c97189e0b48da76f1aee62ebfee4780d6bf036d7edbc3c94b630dbf734f2647312c1e73569daf3f527260d" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x11852ac1e15a52b4ecdebefd4457c328b6cc9f50d6e726f29cd868827bc4a85c94bd74c6d42a8c29ab48ed8e23b775fe1f24ab3f8752000304d2e5b62f6e6e06" }, "events": [ { - "key": "0x00000000000000009cb76004a475da72d1631e72d6f1d43c5b198c6bb61534539c34355cd65572fd", + "key": "0x00000000000000007ed92b4f434df6f2615a6b56ae402c6011b628fbe3a7bb6a028bf1f757f4385b", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { @@ -252,13 +252,13 @@ } } ], - "id": "0xe9653d709374e9438c9a041f736278db6559cb7f1de04381d82258dc80fa9e12", + "id": "0x8c9a041f736278db6559cb7f1de04381d82258dc80fa9e128d9e44bc47487682", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "13" }, { @@ -279,7 +279,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "13" } @@ -324,20 +324,20 @@ }, { "type": "write_resource", - "address": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "address": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", - "self_address": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "authentication_key": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", + "self_address": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "address": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -347,7 +347,7 @@ "guid": { "guid": { "id": { - "addr": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "addr": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "creation_num": "0" } }, @@ -359,7 +359,7 @@ }, { "type": "write_resource", - "address": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "address": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -372,7 +372,7 @@ "guid": { "guid": { "id": { - "addr": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "addr": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "creation_num": "1" } }, @@ -384,7 +384,7 @@ "guid": { "guid": { "id": { - "addr": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "addr": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "creation_num": "2" } }, @@ -396,7 +396,7 @@ }, { "type": "write_resource", - "address": "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "address": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -416,17 +416,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0x7664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12" + "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x8d710a6b1e59f3fb3870ac719e0faf6413b92db57d9cc160e0d6017a59be6d3584391acad28dad6d41bfce4a06220b2137946b8ffe52c2056c9dd925fe232f06" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x289e92ca2d797b3558d3445f661e4c8ed6fd41df34f97007a5d715415cf3a0e2385a102027cdd31e73dffe7d9673f1121a9d32cbc0171479e7860e25f7b2950b" }, "events": [ { - "key": "0x00000000000000007664914f30a8940180aa86f67a197380c95779b3d2530287b24fc35735d14e12", + "key": "0x000000000000000048a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { @@ -514,13 +514,13 @@ } } ], - "id": "0x77b694cee503ea339ebb53fc221a6fc07f89f8048c6071e6460792b92ffe0782", + "id": "0x9ebb53fc221a6fc07f89f8048c6071e6460792b92ffe078247a77e73abc5297c", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "14" }, { @@ -541,7 +541,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "14" } @@ -586,20 +586,20 @@ }, { "type": "write_resource", - "address": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "address": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", - "self_address": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "authentication_key": "0x095f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", + "self_address": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "address": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -609,7 +609,7 @@ "guid": { "guid": { "id": { - "addr": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "addr": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "creation_num": "0" } }, @@ -621,7 +621,7 @@ }, { "type": "write_resource", - "address": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "address": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -634,7 +634,7 @@ "guid": { "guid": { "id": { - "addr": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "addr": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "creation_num": "1" } }, @@ -646,7 +646,7 @@ "guid": { "guid": { "id": { - "addr": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "addr": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "creation_num": "2" } }, @@ -658,7 +658,7 @@ }, { "type": "write_resource", - "address": "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "address": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -678,17 +678,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0xbbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f" + "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x0eda9db6a7f2f8a35f689c0df45e75d8800cf1f2ad403e824dd29b1d1833a73adfd4a8dcadd2cadce67f7bd77579a28eec62452c11a0eb40f179ef6ea8de0c03" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x2f1473c640e7126b2fec6565e6286c462a9357c5a7eae71478e16de4661f63d1e13c678c31c4532724a7a98876c6f36367b071c8cca77c675036e3fac443140d" }, "events": [ { - "key": "0x0000000000000000bbc57943855384e6eef5677aaf2eed0379a51828f5c887049eedc6d574977d4f", + "key": "0x0000000000000000095f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { @@ -776,13 +776,13 @@ } } ], - "id": "0x436e67164ec8ea033ddcb6c382270184cb1c0e7044b272ba0b2382d21b06966d", + "id": "0x3ddcb6c382270184cb1c0e7044b272ba0b2382d21b06966dd5ff00f5fa36dbef", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "15" }, { @@ -803,7 +803,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "15" } @@ -848,20 +848,20 @@ }, { "type": "write_resource", - "address": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "address": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", - "self_address": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "authentication_key": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", + "self_address": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "address": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -871,7 +871,7 @@ "guid": { "guid": { "id": { - "addr": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "addr": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "creation_num": "0" } }, @@ -883,7 +883,7 @@ }, { "type": "write_resource", - "address": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "address": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -896,7 +896,7 @@ "guid": { "guid": { "id": { - "addr": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "addr": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "creation_num": "1" } }, @@ -908,7 +908,7 @@ "guid": { "guid": { "id": { - "addr": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "addr": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "creation_num": "2" } }, @@ -920,7 +920,7 @@ }, { "type": "write_resource", - "address": "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "address": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -940,17 +940,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0xc860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c" + "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x8c3a15e8634f83de47375dce42e067082d53f5458ec21e1bd8c9de21acdfc9d3d417ae0716e58cb64092567bf738c83e5ca39c5238a6d1c51f2ace7cd6a5c50d" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0xb1cbef991cc5e19df2f93d8de0f7ef7363b5f364ce8e2d92ec8898e5edda693b92e632882c8db9a6ed5e19b6d8cffa3257a025d136a231eff85c37583ef8e901" }, "events": [ { - "key": "0x0000000000000000c860e81b9d757d6d3b2832e26f3f7419cf9dd802648de86a3255f97b03186f8c", + "key": "0x00000000000000004c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { @@ -1038,13 +1038,13 @@ } } ], - "id": "0x1abe62cb97d5716d5d05da6e72c49bf2791775d0465453e709d3d46d8aae8376", + "id": "0x5d05da6e72c49bf2791775d0465453e709d3d46d8aae837610781514ae1b0ee6", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "16" }, { @@ -1065,7 +1065,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "16" } @@ -1110,20 +1110,20 @@ }, { "type": "write_resource", - "address": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "address": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", - "self_address": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "authentication_key": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", + "self_address": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "address": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -1133,7 +1133,7 @@ "guid": { "guid": { "id": { - "addr": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "addr": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "creation_num": "0" } }, @@ -1145,7 +1145,7 @@ }, { "type": "write_resource", - "address": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "address": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -1158,7 +1158,7 @@ "guid": { "guid": { "id": { - "addr": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "addr": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "creation_num": "1" } }, @@ -1170,7 +1170,7 @@ "guid": { "guid": { "id": { - "addr": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "addr": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "creation_num": "2" } }, @@ -1182,7 +1182,7 @@ }, { "type": "write_resource", - "address": "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "address": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -1202,17 +1202,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0x7e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73" + "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x23f65b7383019caa813d245689b6cd9a7032214c52dc9a6c46c3c2f32f428a8437476b2fe396944947926d62d3013d517af635ed2dd5da1ffd26d8ecd07e560a" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0xab85659be777fde63a7715772090c7d50357def5b8f1a36e2a0e94f425469c8b8126f29302e5a8b84cdb0a9587a5e4c7d8b84998ab646f4460c3cfd7f690e40b" }, "events": [ { - "key": "0x00000000000000007e28d038b859043ae514ab78f6c50c7733996d7ab4f130ca2712e171db393b73", + "key": "0x000000000000000046925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { @@ -1300,13 +1300,13 @@ } } ], - "id": "0x77db5fa5015d6961d2d00107d2f0b1323b9e27213f8b003f78a5cdd081007bd1", + "id": "0xd2d00107d2f0b1323b9e27213f8b003f78a5cdd081007bd11f09b7e6fa232b0a", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "17" }, { @@ -1327,7 +1327,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "17" } @@ -1372,20 +1372,20 @@ }, { "type": "write_resource", - "address": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "address": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", - "self_address": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "authentication_key": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", + "self_address": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "address": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -1395,7 +1395,7 @@ "guid": { "guid": { "id": { - "addr": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "addr": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "creation_num": "0" } }, @@ -1407,7 +1407,7 @@ }, { "type": "write_resource", - "address": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "address": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -1420,7 +1420,7 @@ "guid": { "guid": { "id": { - "addr": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "addr": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "creation_num": "1" } }, @@ -1432,7 +1432,7 @@ "guid": { "guid": { "id": { - "addr": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "addr": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "creation_num": "2" } }, @@ -1444,7 +1444,7 @@ }, { "type": "write_resource", - "address": "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "address": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -1464,17 +1464,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0x62586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30" + "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x77bc335c241c02fb9ea077bef10de5b682afd2583e98cd967b4755997e1c3e484fade7c1921e20ca666e3e931f9c318b070e8940e21ce615b40e1f61899a880b" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0xfe8ffd3b0e65c56ccd05d7c1ba397b7fb86f9c885a86968e9b700d65b11a38b27f8fab39a04759815a99924482a9c50ef3ba6d9368ae9991ba83aba99de9060c" }, "events": [ { - "key": "0x000000000000000062586862c56887b6cfb38b793a81c0a801e53fad59248eab36e1b673013cca30", + "key": "0x0000000000000000fcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { @@ -1562,13 +1562,13 @@ } } ], - "id": "0x3dce7747a12ad1e8a8d6521a26daafda96dacf7f582cb1dbdc84c06e7953e5f1", + "id": "0xa8d6521a26daafda96dacf7f582cb1dbdc84c06e7953e5f1c769ef8a93dcbeb3", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "18" }, { @@ -1589,7 +1589,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "18" } @@ -1634,20 +1634,20 @@ }, { "type": "write_resource", - "address": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "address": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", - "self_address": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "authentication_key": "0x099acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", + "self_address": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "address": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -1657,7 +1657,7 @@ "guid": { "guid": { "id": { - "addr": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "addr": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "creation_num": "0" } }, @@ -1669,7 +1669,7 @@ }, { "type": "write_resource", - "address": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "address": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -1682,7 +1682,7 @@ "guid": { "guid": { "id": { - "addr": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "addr": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "creation_num": "1" } }, @@ -1694,7 +1694,7 @@ "guid": { "guid": { "id": { - "addr": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "addr": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "creation_num": "2" } }, @@ -1706,7 +1706,7 @@ }, { "type": "write_resource", - "address": "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "address": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -1726,17 +1726,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0x19c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f" + "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x590cb6489b4b3240594694506d3ec42c1bfccb6404498b6cc600bdcdb3c3ad9866be97ecdc4e9ca3cfa4301508e022702214beae7732061b59ed960ec6102500" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x38a3ae8066532dc30cf0e1dda988ed0cfee1dc984991e0b6943b3dd7a7663d77c569084af68505b62372c7a15375568fc647e13ed831dd982430fdfb83290704" }, "events": [ { - "key": "0x000000000000000019c02925b669c8a41ed35f90de405aaa00b17022318dfb20f2d8be840fd1da6f", + "key": "0x0000000000000000099acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { @@ -1824,13 +1824,13 @@ } } ], - "id": "0x9046d0558082b67f142c31e08bfca525c34fa8a59ebcb300e72586225d613eb0", + "id": "0x142c31e08bfca525c34fa8a59ebcb300e72586225d613eb0af32ce80b0e9529f", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "19" }, { @@ -1851,7 +1851,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "19" } @@ -1896,20 +1896,20 @@ }, { "type": "write_resource", - "address": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "address": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", - "self_address": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "authentication_key": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", + "self_address": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "address": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -1919,7 +1919,7 @@ "guid": { "guid": { "id": { - "addr": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "addr": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "creation_num": "0" } }, @@ -1931,7 +1931,7 @@ }, { "type": "write_resource", - "address": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "address": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -1944,7 +1944,7 @@ "guid": { "guid": { "id": { - "addr": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "addr": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "creation_num": "1" } }, @@ -1956,7 +1956,7 @@ "guid": { "guid": { "id": { - "addr": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "addr": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "creation_num": "2" } }, @@ -1968,7 +1968,7 @@ }, { "type": "write_resource", - "address": "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "address": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -1988,17 +1988,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0xa290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d" + "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x2385804b52fabb93b7670983c8c6e51357da7c62d48fb9e428429a1a8ea05012d36fa7bfd06cb1c5fdc9cf5fbea767980edbf7e3359c301cd0dde9b97f7b920a" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x41b2172e5c6d5f44b80a74476ded8a08e511469fb1d9d2df3e5a4d56369656d7daba336a29284cccd9b000f091f682dfcdfe149e62b763f3af5b53157e8a0800" }, "events": [ { - "key": "0x0000000000000000a290d45984dc2094cfdab4418136cc49cca85518a6e893244e7631407ee60e2d", + "key": "0x0000000000000000e9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { @@ -2086,13 +2086,13 @@ } } ], - "id": "0xc4aca2ae80a39350f6ce4988f3b078f37f863539358646c46f14aa24caa8745b", + "id": "0xf6ce4988f3b078f37f863539358646c46f14aa24caa8745bf26f63f76d85fdbd", "epoch": "0", "round": "1", "previous_block_votes": [ false ], - "proposer": "0x5a3f08d4b5f5d0643b9e1d698afbd0ab5d373e7a7b2c54f6a5dda9d04236fb5b", + "proposer": "0x66b22b7465af92a9dc8d07d2878716d9dffbbb280830a7d8cf80334b5da812ef", "timestamp": "20" }, { @@ -2113,7 +2113,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "20" } @@ -2158,20 +2158,20 @@ }, { "type": "write_resource", - "address": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "address": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", - "self_address": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "authentication_key": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", + "self_address": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "sequence_number": "0" } } }, { "type": "write_resource", - "address": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "address": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinEvents", @@ -2181,7 +2181,7 @@ "guid": { "guid": { "id": { - "addr": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "addr": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "creation_num": "0" } }, @@ -2193,7 +2193,7 @@ }, { "type": "write_resource", - "address": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "address": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -2206,7 +2206,7 @@ "guid": { "guid": { "id": { - "addr": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "addr": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "creation_num": "1" } }, @@ -2218,7 +2218,7 @@ "guid": { "guid": { "id": { - "addr": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "addr": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "creation_num": "2" } }, @@ -2230,7 +2230,7 @@ }, { "type": "write_resource", - "address": "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "address": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "state_key_hash": "", "data": { "type": "0x1::GUID::Generator", @@ -2250,17 +2250,17 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0xf046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734" + "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x474c35a0d798f625febd347325a04c0e3651d49baae9bb7556a0f36dcb272bb8923c087c0f6648568d8d0a5e00059b84119d76a2574209450ebb6618b136e208" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x63031b49145cecdce1a4bf705e38e1c3d0fb0875eac934d5d95275d7163991cdb6c664cbfea0c594a473eb8235784d38444c593ccca46d9f918460b505477e03" }, "events": [ { - "key": "0x0000000000000000f046c326e3904ccb882488161687a398bdc22c086591af2efa6594c6bebac734", + "key": "0x0000000000000000626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "sequence_number": "0", "type": "0x1::Coin::RegisterEvent", "data": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_module_payload_bytecode.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_module_payload_bytecode.json index 11883c56424c7..d071cd30e54e8 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_module_payload_bytecode.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_module_payload_bytecode.json @@ -16,7 +16,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "1" } @@ -76,8 +76,8 @@ }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0xc95cdd66c6d586018278b3fc7a7be5c2211b78ce9da492649025b96db57cff2b64f1f913afb4ab9c63e7088c621a1bf9215fe096de96d3874e07c3e7f373ec03" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0xd81d745f9595ef481907796ee853a15bb6c0fb4f8c18fcf25fc3461739c00f40cf6da86eb78727ca03390a04360733ae9f31475f45858809e933164444e96d00" }, "events": [], "timestamp": "1" diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_address.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_address.json index a91a6389dba48..102856a812e78 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_address.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_address.json @@ -16,7 +16,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "1" } @@ -78,8 +78,8 @@ }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x94449752712425a39b5b722588275ff6b10809f32cb533bfea320be6f41269dcdb61e783fcdb8759db346b55713d19896eb763244a081f388ecd0a9dfaaa7809" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x617deed882af2f20f9ff92b580d0a5e83762d8ce49117525007a5df109d234e25965fc63c5e3eb2eb1de3e1145aaf0e656a690cd7c74af5a1a46a2cf2b979f07" }, "events": [], "timestamp": "1" diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_arguments.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_arguments.json index 72d74adcef72a..decf8b27ec7ef 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_arguments.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_arguments.json @@ -16,7 +16,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "1" } @@ -78,8 +78,8 @@ }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x7b9d687b2c04c1adaa69e752ead4f880db8583382be3ec8c42e60c92409153517b0585a40281ebce4d340858a4af6d5d123c03b80747e6b2f3a23a2ff19fb902" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0xc092753608ea42033b0dd1338a92190d1bb515e018c047434de6485644e96515ece0ab071859561dfb6d2293ade5861f04ab4f27ecd3df568074663d49f91603" }, "events": [], "timestamp": "1" diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_module_name.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_module_name.json index 5e721df712453..ccdcee530a174 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_module_name.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_module_name.json @@ -16,7 +16,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "1" } @@ -78,8 +78,8 @@ }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x3bb42944c317eaad297496b9d5a8236d4022bde7d5005734cc6bc2e7d9f5a8b381635f2c18d9b5b25bec5079c3892b68fb0de51af5326d1c1a84391f742ebe0e" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0xd0b0b837563711ca969084dd5cd37aacd41bb11a95caf2ae631b1f7cdb8ebe65f26b78e2a654b4e98bf81ef315e2097207df74a048dcba0e760cfc814c0efc0b" }, "events": [], "timestamp": "1" diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_name.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_name.json index 6b5208ec805eb..2c5cb96952a8b 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_name.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_function_name.json @@ -16,7 +16,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "1" } @@ -78,8 +78,8 @@ }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x5181a332c42de557b1dd0dd8279413bcdc477f4b1824c6bc6eb871cad7245a72ebe39ea3f8983f0249a11f236092e177eec7b78ce50dd3a4a3acb0e83b2c9e04" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x0157c813a8fa4d5c1d2979e5a65963102d05ba2fd4d0c469646dbf3cf156e2386e0d40b74663a71fa5b94e52c9af76386203a5811e3881e7619458a383e95908" }, "events": [], "timestamp": "1" diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_payload_bytecode.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_payload_bytecode.json index 1ab360178511f..2501d57a3e5b3 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_payload_bytecode.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_script_payload_bytecode.json @@ -16,7 +16,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "1" } @@ -76,8 +76,8 @@ }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x5055b50faf77e3c8f97361bbbd45b863b9b5ee25bc7b9974cb9946257df9ebc293ed48e9d10266dfdf684a0cf309402d96b58e5465f16ccf1d3d58d8b88d0505" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x03b95571547a2042f4685974a4f4a6e7188aef8149be2cfb46b0b2f6f41f392cf6b9be21b23c25df6241d0247e1b921efdd7c9d392ecf27e51723a960bfff404" }, "events": [], "timestamp": "1" diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_script_function_arguments.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_script_function_arguments.json index 197aab80d69b7..1100aab2a8f25 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_script_function_arguments.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_script_function_arguments.json @@ -16,7 +16,7 @@ "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0x8e0d19280063fa870fe4dbb85cc724091a398451c5c11e1e76e64cdc7b588510", + "authentication_key": "0xcef8ffd1ab9017e96132df8a56b22de39a8155e1c3fc32affbbf93eb624b532a", "self_address": "0xa550c18", "sequence_number": "1" } @@ -77,8 +77,8 @@ }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x4fbb7999311c34c05d678a4a2934524696e8c92b9b4221b2d19b2334548225f43a98624afb684780ab7ea6aed5174808d08e2b57f4d88fba2118461143b5aa0b" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x0d9cb5802faaa33ab48f8c90f85ef02aff158a95e5ee8ecb266429f492faf82fb0133c365064b1d12fa85a216a25400b413bf05b26008bc6022e00b1671de206" }, "events": [], "timestamp": "1" diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_script_function_validation.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_script_function_validation.json index d4051b120d9f8..9f9028b0af640 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_script_function_validation.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_script_function_validation.json @@ -11,20 +11,20 @@ "changes": [ { "type": "write_resource", - "address": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "state_key_hash": "", "data": { "type": "0x1::Account::Account", "data": { - "authentication_key": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", - "self_address": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "authentication_key": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", + "self_address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "sequence_number": "1" } } }, { "type": "write_resource", - "address": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "state_key_hash": "", "data": { "type": "0x1::Coin::CoinStore<0x1::TestCoin::TestCoin>", @@ -37,7 +37,7 @@ "guid": { "guid": { "id": { - "addr": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "addr": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "creation_num": "1" } }, @@ -49,7 +49,7 @@ "guid": { "guid": { "id": { - "addr": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "addr": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "creation_num": "2" } }, @@ -60,7 +60,7 @@ } } ], - "sender": "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea", + "sender": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "sequence_number": "0", "max_gas_amount": "2000", "gas_unit_price": "0", @@ -78,8 +78,8 @@ }, "signature": { "type": "ed25519_signature", - "public_key": "0xcb2ee1fdd39ab7ad7047fd2edb7c37f8fd6ea6a5a8b8009d2710036624c0937f", - "signature": "0x6e087dfa839682866286734a2a25c050ae9a23671766738f4a62e1ec85dfb50ea80fbb25db5bd16020f2cbdb7205d60172c3febce48b5c79a0f208f2ddd6f405" + "public_key": "0xd5a781494d2bf1a174ddffde1e02cb8881cff6dab70e61cbdef393deac0ce639", + "signature": "0x2753c4d5673e34bcf088f6063a0776d419de08cc011c2698c1db509b5e5d22040136f2e727646f8d1b9b11a25a9c01de8f27feb673e16ed5db264bd7095bfd0d" }, "events": [], "timestamp": "2" diff --git a/api/goldens/aptos_api__tests__transactions_test__test_post_bcs_format_transaction.json b/api/goldens/aptos_api__tests__transactions_test__test_post_bcs_format_transaction.json index 0d577e086b009..5e0872b6858bc 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_post_bcs_format_transaction.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_post_bcs_format_transaction.json @@ -11,12 +11,12 @@ "function": "0x1::Account::create_account", "type_arguments": [], "arguments": [ - "0xd30c067c5c317672314ed69ebe81008891c7aca019294ce52d2524891b8026ea" + "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf" ] }, "signature": { "type": "ed25519_signature", - "public_key": "0x20fdbac9b10b7587bba7b5bc163bce69e796d71e4ed44c10fcb4488689f7a144", - "signature": "0x2496d9a46e38adcadfb09e2aa27882f3f1bbe52b1087ce75ae3bae2b4bad1f4ca8a40fed59608be896e6d56b83f1b0a76aade5b352b4f081ad3d914cb8436205" + "public_key": "0x14418f867a0bd6d42abb2daa50cd68a5a869ce208282481f57504f630510d0d3", + "signature": "0x3d03661e4b3fffc4048c41046479b708e445116e391fc417ddc961b33a6752c238b5a794dc5c2af60f0741692bb4fc677203ca96a4dc7758296880e1489ca807" } } diff --git a/api/src/tests/test_context.rs b/api/src/tests/test_context.rs index 40de6fbc6430c..e4796c8f759c4 100644 --- a/api/src/tests/test_context.rs +++ b/api/src/tests/test_context.rs @@ -8,8 +8,6 @@ use aptos_api_types::{ }; use aptos_config::config::ApiConfig; use aptos_crypto::{hash::HashValue, SigningKey}; -use aptos_genesis_tool::validator_builder::{RootKeys, ValidatorBuilder}; -use aptos_global_constants::OWNER_ACCOUNT; use aptos_mempool::mocks::MockSharedMempool; use aptos_sdk::{ transaction_builder::TransactionFactory, @@ -18,7 +16,6 @@ use aptos_sdk::{ LocalAccount, }, }; -use aptos_secure_storage::KVStorage; use aptos_temppath::TempPath; use aptos_types::{ account_address::AccountAddress, @@ -38,6 +35,8 @@ use mempool_notifications::MempoolNotificationSender; use storage_interface::DbReaderWriter; use crate::tests::golden_output::GoldenOutputs; +use aptos_config::keys::ConfigKey; +use aptos_crypto::ed25519::Ed25519PrivateKey; use executor::block_executor::BlockExecutor; use rand::SeedableRng; use serde_json::{json, Value}; @@ -51,13 +50,17 @@ pub fn new_test_context(test_name: &'static str) -> TestContext { tmp_dir.create_as_dir().unwrap(); let mut rng = ::rand::rngs::StdRng::from_seed([0u8; 32]); - let builder = - ValidatorBuilder::new(&tmp_dir, cached_framework_packages::module_blobs().to_vec()) - .min_price_per_gas_unit(0) - .randomize_first_validator_ports(false); + let builder = aptos_genesis::builder::Builder::new( + tmp_dir.path(), + cached_framework_packages::module_blobs().to_vec(), + ) + .unwrap() + .with_min_price_per_gas_unit(0) + .with_randomize_first_validator_ports(false); - let (root_keys, genesis, genesis_waypoint, validators) = builder.build(&mut rng).unwrap(); - let validator_owner = validators[0].storage().get(OWNER_ACCOUNT).unwrap().value; + let (root_key, genesis, genesis_waypoint, validators) = builder.build(&mut rng).unwrap(); + let (validator_identity, _, _) = validators[0].get_key_objects(None).unwrap(); + let validator_owner = validator_identity.account_address.unwrap(); let (db, db_rw) = DbReaderWriter::wrap(AptosDB::new_for_test(&tmp_dir)); let ret = @@ -74,7 +77,7 @@ pub fn new_test_context(test_name: &'static str) -> TestContext { ApiConfig::default(), ), rng, - root_keys, + root_key, validator_owner, Box::new(BlockExecutor::::new(db_rw)), mempool, @@ -90,7 +93,7 @@ pub struct TestContext { pub mempool: Arc, pub db: Arc, rng: rand::rngs::StdRng, - root_keys: Arc, + root_key: ConfigKey, executor: Arc, expect_status_code: u16, test_name: &'static str, @@ -102,7 +105,7 @@ impl TestContext { pub fn new( context: Context, rng: rand::rngs::StdRng, - root_keys: RootKeys, + root_key: Ed25519PrivateKey, validator_owner: AccountAddress, executor: Box, mempool: MockSharedMempool, @@ -112,7 +115,7 @@ impl TestContext { Self { context, rng, - root_keys: Arc::new(root_keys), + root_key: ConfigKey::new(root_key), validator_owner, executor: executor.into(), mempool: Arc::new(mempool), @@ -145,7 +148,7 @@ impl TestContext { } pub fn root_account(&self) -> LocalAccount { - LocalAccount::new(aptos_root_address(), self.root_keys.root_key.clone(), 0) + LocalAccount::new(aptos_root_address(), self.root_key.private_key(), 0) } pub fn latest_state_view(&self) -> DbStateView { diff --git a/aptos-node/Cargo.toml b/aptos-node/Cargo.toml index 2673fee7d38bb..4fbf128d3b14f 100644 --- a/aptos-node/Cargo.toml +++ b/aptos-node/Cargo.toml @@ -24,7 +24,7 @@ aptos-api = { path = "../api" } aptos-config = { path = "../config" } aptos-crypto = { path = "../crates/aptos-crypto" } aptos-data-client = { path = "../state-sync/aptos-data-client" } -aptos-genesis-tool = { path = "../config/management/genesis", features = ["testing"] } +aptos-genesis = { path = "../crates/aptos-genesis", features = ["testing"] } aptos-infallible = { path = "../crates/aptos-infallible" } aptos-logger = { path = "../crates/aptos-logger" } aptos-mempool = { path = "../mempool" } diff --git a/aptos-node/src/lib.rs b/aptos-node/src/lib.rs index 1c2687818b93c..23c5948bcde04 100644 --- a/aptos-node/src/lib.rs +++ b/aptos-node/src/lib.rs @@ -163,16 +163,14 @@ pub fn load_test_environment( template.consensus.quorum_store_poll_count = u64::MAX; } - let builder = aptos_genesis_tool::validator_builder::ValidatorBuilder::new( - &config_path, - genesis_modules, - ) - .template(template) - .randomize_first_validator_ports(random_ports); + let builder = aptos_genesis::builder::Builder::new(&config_path, genesis_modules) + .unwrap() + .with_template(template) + .with_randomize_first_validator_ports(random_ports); - let (root_keys, _genesis, genesis_waypoint, validators) = builder.build(rng).unwrap(); + let (root_key, _genesis, genesis_waypoint, validators) = builder.build(rng).unwrap(); - let serialized_keys = bcs::to_bytes(&root_keys.root_key).unwrap(); + let serialized_keys = bcs::to_bytes(&root_key).unwrap(); let mut key_file = std::fs::File::create(&aptos_root_key_path).unwrap(); key_file.write_all(&serialized_keys).unwrap(); diff --git a/config/management/genesis/src/config_builder.rs b/config/management/genesis/src/config_builder.rs deleted file mode 100644 index 705944453492b..0000000000000 --- a/config/management/genesis/src/config_builder.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Aptos -// SPDX-License-Identifier: Apache-2.0 - -use crate::validator_builder::ValidatorBuilder; -use aptos_config::config::NodeConfig; -use aptos_crypto::ed25519::Ed25519PrivateKey; -use aptos_secure_storage::{CryptoStorage, KVStorage, Storage}; -use aptos_temppath::TempPath; -use rand::{rngs::StdRng, SeedableRng}; - -pub fn test_config() -> (NodeConfig, Ed25519PrivateKey) { - let path = TempPath::new(); - path.create_as_dir().unwrap(); - let (root_keys, _genesis, _genesis_waypoint, validators) = ValidatorBuilder::new( - path.path(), - cached_framework_packages::module_blobs().to_vec(), - ) - .template(NodeConfig::default_for_validator()) - .build(StdRng::from_seed([0; 32])) - .unwrap(); - let mut configs = validators.into_iter().map(|v| v.config).collect::>(); - let key = root_keys.root_key; - - let mut config = configs.swap_remove(0); - config.set_data_dir(path.path().to_path_buf()); - let backend = &config - .validator_network - .as_ref() - .unwrap() - .identity_from_storage() - .backend; - let storage: Storage = std::convert::TryFrom::try_from(backend).unwrap(); - let mut test = aptos_config::config::TestConfig::new_with_temp_dir(Some(path)); - test.execution_key( - storage - .export_private_key(aptos_global_constants::EXECUTION_KEY) - .unwrap(), - ); - test.operator_key( - storage - .export_private_key(aptos_global_constants::OPERATOR_KEY) - .unwrap(), - ); - test.owner_key( - storage - .export_private_key(aptos_global_constants::OWNER_KEY) - .unwrap(), - ); - config.test = Some(test); - - let owner_account = storage - .get(aptos_global_constants::OWNER_ACCOUNT) - .unwrap() - .value; - let mut sr_test = aptos_config::config::SafetyRulesTestConfig::new(owner_account); - sr_test.consensus_key( - storage - .export_private_key(aptos_global_constants::CONSENSUS_KEY) - .unwrap(), - ); - sr_test.execution_key( - storage - .export_private_key(aptos_global_constants::EXECUTION_KEY) - .unwrap(), - ); - config.consensus.safety_rules.test = Some(sr_test); - - (config, key) -} diff --git a/config/management/genesis/src/fullnode_builder.rs b/config/management/genesis/src/fullnode_builder.rs deleted file mode 100644 index 6b1f1ee7df86e..0000000000000 --- a/config/management/genesis/src/fullnode_builder.rs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Aptos -// SPDX-License-Identifier: Apache-2.0 - -use anyhow::{ensure, Result}; -use aptos_config::{ - config::{Identity, NodeConfig, PeerRole, RoleType, WaypointConfig}, - generator::build_seed_for_network, - network_id::NetworkId, -}; -use aptos_crypto::{x25519, Uniform}; -use aptos_types::{transaction::Transaction, waypoint::Waypoint}; -use rand::rngs::OsRng; -use std::{ - fs::File, - io::Write, - path::{Path, PathBuf}, -}; - -pub struct FullnodeConfig { - pub name: String, - pub config: NodeConfig, - pub directory: PathBuf, -} - -impl FullnodeConfig { - pub fn public_fullnode( - name: String, - config_directory: &Path, - config: NodeConfig, - waypoint: &Waypoint, - genesis: &Transaction, - ) -> Result { - let mut fullnode_config = Self::new(name, config_directory, config)?; - - fullnode_config.insert_waypoint(waypoint); - fullnode_config.insert_genesis(genesis)?; - fullnode_config.set_identity(); - fullnode_config.config.randomize_ports(); - fullnode_config.save_config()?; - - Ok(fullnode_config) - } - - pub fn validator_fullnode( - name: String, - config_directory: &Path, - fullnode_config: NodeConfig, - validator_config: &mut NodeConfig, - waypoint: &Waypoint, - genesis: &Transaction, - ) -> Result { - let mut fullnode_config = Self::new(name, config_directory, fullnode_config)?; - - fullnode_config.insert_waypoint(waypoint); - fullnode_config.insert_genesis(genesis)?; - fullnode_config.config.randomize_ports(); - - fullnode_config.attach_to_validator(validator_config)?; - fullnode_config.save_config()?; - - Ok(fullnode_config) - } - - fn new(name: String, config_directory: &Path, mut config: NodeConfig) -> Result { - ensure!( - matches!(config.base.role, RoleType::FullNode), - "config must be a FullNode config" - ); - - let directory = config_directory.join(&name); - std::fs::create_dir_all(&directory)?; - - config.set_data_dir(directory.clone()); - - Ok(Self { - name, - config, - directory, - }) - } - - fn insert_waypoint(&mut self, waypoint: &Waypoint) { - self.config.base.waypoint = WaypointConfig::FromConfig(*waypoint); - } - - fn insert_genesis(&mut self, genesis: &Transaction) -> Result<()> { - // Save genesis file in this validator's config directory - let genesis_file_location = self.directory.join("genesis.blob"); - File::create(&genesis_file_location)?.write_all(&bcs::to_bytes(&genesis)?)?; - - self.config.execution.genesis = Some(genesis.clone()); - self.config.execution.genesis_file_location = genesis_file_location; - - Ok(()) - } - - fn set_identity(&mut self) { - let mut network_config = self - .config - .full_node_networks - .iter_mut() - .find(|config| config.network_id == NetworkId::Public) - .unwrap(); - - if let Identity::None = network_config.identity { - let key = x25519::PrivateKey::generate(&mut OsRng); - let peer_id = aptos_types::account_address::from_identity_public_key(key.public_key()); - network_config.identity = Identity::from_config(key, peer_id); - } - } - - fn attach_to_validator(&mut self, validator_config: &mut NodeConfig) -> Result<()> { - ensure!( - matches!(validator_config.base.role, RoleType::Validator), - "Validator config must be a Validator config" - ); - - // Grab the public network config from the validator and insert it into the VFN's config - let public_network = { - let (i, _) = validator_config - .full_node_networks - .iter() - .enumerate() - .find(|(_i, config)| config.network_id == NetworkId::Public) - .expect("Validator should have a public network"); - validator_config.full_node_networks.remove(i) - }; - - let fullnode_public_network = self - .config - .full_node_networks - .iter_mut() - .find(|config| config.network_id == NetworkId::Public) - .expect("VFN should have a public network"); - fullnode_public_network.identity = public_network.identity; - fullnode_public_network.listen_address = public_network.listen_address; - - // Grab the validator's vfn network information and configure it as a seed for the VFN's - // vfn network - let validators_vfn_network = validator_config - .full_node_networks - .iter() - .find(|config| config.network_id.is_vfn_network()) - .expect("Validator should have vfn network"); - - let fullnode_vfn_network = self - .config - .full_node_networks - .iter_mut() - .find(|config| config.network_id.is_vfn_network()) - .expect("VFN should have a vfn network"); - fullnode_vfn_network.seeds = - build_seed_for_network(validators_vfn_network, PeerRole::Validator); - - if let Identity::None = fullnode_vfn_network.identity { - let key = x25519::PrivateKey::generate(&mut OsRng); - let peer_id = aptos_types::account_address::from_identity_public_key(key.public_key()); - fullnode_vfn_network.identity = Identity::from_config(key, peer_id); - } - - Ok(()) - } - - pub fn config_path(&self) -> PathBuf { - self.directory.join("node.yaml") - } - - fn save_config(&mut self) -> Result<()> { - self.config.save(self.config_path()).map_err(Into::into) - } -} diff --git a/config/management/genesis/src/lib.rs b/config/management/genesis/src/lib.rs index 1152046173d9e..16fc4227a8774 100644 --- a/config/management/genesis/src/lib.rs +++ b/config/management/genesis/src/lib.rs @@ -5,20 +5,14 @@ pub mod builder; pub mod command; -pub mod fullnode_builder; mod genesis; mod key; pub mod layout; mod move_modules; -pub mod validator_builder; mod validator_operator; mod verify; mod waypoint; #[cfg(any(test, feature = "testing"))] -pub mod config_builder; #[cfg(test)] mod storage_helper; - -#[cfg(any(test, feature = "testing"))] -pub use crate::config_builder::test_config; diff --git a/config/management/genesis/src/validator_builder.rs b/config/management/genesis/src/validator_builder.rs deleted file mode 100644 index 9f9ccfac0ab87..0000000000000 --- a/config/management/genesis/src/validator_builder.rs +++ /dev/null @@ -1,416 +0,0 @@ -// Copyright (c) Aptos -// SPDX-License-Identifier: Apache-2.0 - -use crate::{ - builder::GenesisBuilder, layout::Layout, verify::verify_genesis, - waypoint::create_genesis_waypoint, -}; -use anyhow::Result; -use aptos_config::{ - config::{ - DiscoveryMethod, Identity, NetworkConfig, NodeConfig, OnDiskStorageConfig, - SafetyRulesService, SecureBackend, WaypointConfig, - }, - network_id::NetworkId, -}; -use aptos_crypto::{ - ed25519::{Ed25519PrivateKey, Ed25519PublicKey}, - Uniform, -}; -use aptos_global_constants::{ - CONSENSUS_KEY, EXECUTION_KEY, FULLNODE_NETWORK_KEY, GENESIS_WAYPOINT, OPERATOR_ACCOUNT, - OPERATOR_KEY, OWNER_ACCOUNT, OWNER_KEY, SAFETY_DATA, VALIDATOR_NETWORK_KEY, WAYPOINT, -}; -use aptos_management::{ - storage::StorageWrapper, validator_config::build_validator_config_transaction, -}; -use aptos_secure_storage::{CryptoStorage, KVStorage, OnDiskStorage, Storage}; -use aptos_types::{ - chain_id::ChainId, - transaction::{authenticator::AuthenticationKey, Transaction}, - waypoint::Waypoint, -}; -use consensus_types::safety_data::SafetyData; -use std::{ - convert::TryFrom, - fs::File, - io::Write, - num::NonZeroUsize, - path::{Path, PathBuf}, -}; - -const APTOS_ROOT_NS: &str = "aptos_root"; -const OPERATOR_NS: &str = "_operator"; -const OWNER_NS: &str = "_owner"; - -pub struct ValidatorConfig { - pub name: String, - pub storage_config: OnDiskStorageConfig, - pub config: NodeConfig, - pub directory: PathBuf, -} - -impl ValidatorConfig { - fn new( - name: String, - storage_config: OnDiskStorageConfig, - directory: PathBuf, - config: NodeConfig, - ) -> Self { - Self { - name, - storage_config, - config, - directory, - } - } - - pub fn config_path(&self) -> PathBuf { - self.directory.join("node.yaml") - } - - fn save_config(&mut self) -> Result<()> { - self.config.save(self.config_path()).map_err(Into::into) - } - - fn owner(&self) -> String { - format!("{}{}", self.name, OWNER_NS) - } - - fn operator(&self) -> String { - format!("{}{}", self.name, OPERATOR_NS) - } - - pub fn storage(&self) -> OnDiskStorage { - OnDiskStorage::new(self.storage_config.path()) - } - - fn owner_key(&self) -> Result { - self.storage() - .get_public_key(OWNER_KEY) - .map(|r| r.public_key) - .map_err(Into::into) - } - - fn operator_key(&self) -> Result { - self.storage() - .get_public_key(OPERATOR_KEY) - .map(|r| r.public_key) - .map_err(Into::into) - } - - fn insert_waypoint(&mut self, waypoint: &Waypoint) -> Result<()> { - // set waypoint in storage - let mut storage = self.storage(); - storage.set(WAYPOINT, waypoint)?; - storage.set(GENESIS_WAYPOINT, waypoint)?; - - self.config.base.waypoint = - WaypointConfig::FromStorage(SecureBackend::OnDiskStorage(self.storage_config.clone())); - - Ok(()) - } - - fn insert_genesis(&mut self, genesis: &Transaction) -> Result<()> { - // Save genesis file in this validator's config directory - let genesis_file_location = self.directory.join("genesis.blob"); - File::create(&genesis_file_location)?.write_all(&bcs::to_bytes(&genesis)?)?; - - self.config.execution.genesis = Some(genesis.clone()); - self.config.execution.genesis_file_location = genesis_file_location; - - Ok(()) - } -} - -pub struct RootKeys { - pub root_key: Ed25519PrivateKey, -} - -impl RootKeys { - pub fn generate(mut rng: R) -> Self - where - R: ::rand::RngCore + ::rand::CryptoRng, - { - let key = Ed25519PrivateKey::generate(&mut rng).to_bytes(); - let root_key = Ed25519PrivateKey::try_from(key.as_ref()).unwrap(); - - Self { root_key } - } -} - -#[derive(Clone)] -pub struct ValidatorBuilder { - config_directory: PathBuf, - /// Bytecodes of Move genesis modules - move_modules: Vec>, - num_validators: NonZeroUsize, - randomize_first_validator_ports: bool, - template: NodeConfig, - min_price_per_gas_unit: u64, -} - -impl ValidatorBuilder { - pub fn new>(config_directory: T, move_modules: Vec>) -> Self { - Self { - config_directory: config_directory.as_ref().into(), - move_modules, - num_validators: NonZeroUsize::new(1).unwrap(), - randomize_first_validator_ports: true, - template: NodeConfig::default_for_validator(), - min_price_per_gas_unit: 1, - } - } - - pub fn randomize_first_validator_ports(mut self, value: bool) -> Self { - self.randomize_first_validator_ports = value; - self - } - - pub fn num_validators(mut self, num_validators: NonZeroUsize) -> Self { - self.num_validators = num_validators; - self - } - - pub fn template(mut self, template: NodeConfig) -> Self { - self.template = template; - self - } - - pub fn min_price_per_gas_unit(mut self, min_price_per_gas_unit: u64) -> Self { - self.min_price_per_gas_unit = min_price_per_gas_unit; - self - } - - pub fn build( - mut self, - mut rng: R, - ) -> Result<(RootKeys, Transaction, Waypoint, Vec)> - where - R: ::rand::RngCore + ::rand::CryptoRng, - { - // Canonicalize the config directory path - self.config_directory = self.config_directory.canonicalize()?; - - // Generate chain root keys - let root_keys = RootKeys::generate(&mut rng); - - // Generate and initialize Validator configs - let mut validators = (0..self.num_validators.get()) - .map(|i| self.initialize_validator_config(i, &mut rng)) - .collect::>>()?; - - // Build genesis - let mut genesis_storage = - OnDiskStorage::new(self.config_directory.join("genesis-storage.json")); - let (genesis, waypoint) = Self::genesis_ceremony( - &mut genesis_storage, - &root_keys, - &validators, - self.move_modules, - self.min_price_per_gas_unit, - )?; - - // Insert Genesis and Waypoint into each validator - for validator in &mut validators { - validator.insert_genesis(&genesis)?; - validator.insert_waypoint(&waypoint)?; - - // verify genesis - let validator_storage = Storage::from(validator.storage()); - let output = verify_genesis( - StorageWrapper::new("validator", validator_storage), - Some(validator.config.execution.genesis_file_location.as_path()), - )?; - - anyhow::ensure!( - output.split("match").count() == 5, - "Failed to verify genesis" - ); - } - - // Save the configs for each validator - for validator in &mut validators { - validator.save_config()?; - } - - Ok((root_keys, genesis, waypoint, validators)) - } - - // - // Build helpers - // - - fn initialize_validator_config(&self, index: usize, rng: R) -> Result - where - R: ::rand::RngCore + ::rand::CryptoRng, - { - let name = index.to_string(); - let directory = self.config_directory.join(&name); - std::fs::create_dir_all(&directory)?; - - let storage_config = Self::storage_config(&directory); - - let mut validator = - ValidatorConfig::new(name, storage_config, directory, self.template.clone()); - Self::initialize_validator_storage(&validator, rng)?; - - validator.config.set_data_dir(validator.directory.clone()); - let mut config = &mut validator.config; - // Setup the network configs - let validator_network = config.validator_network.as_mut().unwrap(); - - let validator_identity = validator_network.identity_from_storage(); - validator_network.identity = Identity::from_storage( - validator_identity.key_name, - validator_identity.peer_id_name, - SecureBackend::OnDiskStorage(validator.storage_config.clone()), - ); - - // By default we don't start a swarm with VFNs, so make sure the public fullnode endpoint - // really is publicly accessable - - let fullnode_network_listen_address = - if let Some(template_fullnode_config) = config.full_node_networks.first() { - template_fullnode_config.listen_address.clone() - } else { - aptos_config::utils::get_available_port_in_multiaddr(true) - }; - let fullnode_network = NetworkConfig { - listen_address: fullnode_network_listen_address, - network_id: NetworkId::Public, - max_outbound_connections: 0, - discovery_method: DiscoveryMethod::Onchain, - identity: Identity::from_storage( - FULLNODE_NETWORK_KEY.to_owned(), - OWNER_ACCOUNT.to_owned(), - SecureBackend::OnDiskStorage(validator.storage_config.clone()), - ), - - ..Default::default() - }; - - let vfn_network = NetworkConfig { - listen_address: aptos_config::utils::get_available_port_in_multiaddr(true), - network_id: NetworkId::Vfn, - max_outbound_connections: 0, - identity: Identity::from_storage( - FULLNODE_NETWORK_KEY.to_owned(), - OWNER_ACCOUNT.to_owned(), - SecureBackend::OnDiskStorage(validator.storage_config.clone()), - ), - - ..Default::default() - }; - - config.full_node_networks = vec![fullnode_network, vfn_network]; - - // Setup consensus and execution configs - config.consensus.safety_rules.service = SafetyRulesService::Thread; - config.consensus.safety_rules.backend = - SecureBackend::OnDiskStorage(validator.storage_config.clone()); - - if index > 0 || self.randomize_first_validator_ports { - config.randomize_ports(); - } - - Ok(validator) - } - - fn storage_config(directory: &Path) -> OnDiskStorageConfig { - let mut storage_config = OnDiskStorageConfig::default(); - storage_config.path = directory.join("secure-storage.json"); - storage_config.set_data_dir(directory.into()); - storage_config - } - - fn initialize_validator_storage(validator: &ValidatorConfig, mut rng: R) -> Result<()> - where - R: ::rand::RngCore + ::rand::CryptoRng, - { - let mut storage = validator.storage(); - - // Set owner key and account address - let owner_key = Ed25519PrivateKey::generate(&mut rng); - let owner_address = - AuthenticationKey::ed25519(&Ed25519PublicKey::from(&owner_key)).derived_address(); - storage.set(OWNER_ACCOUNT, owner_address)?; - storage.import_private_key(OWNER_KEY, owner_key)?; - - // Set operator key and account address - let operator_key = Ed25519PrivateKey::generate(&mut rng); - let operator_address = - AuthenticationKey::ed25519(&Ed25519PublicKey::from(&operator_key)).derived_address(); - storage.set(OPERATOR_ACCOUNT, operator_address)?; - storage.import_private_key(OPERATOR_KEY, operator_key)?; - - storage.import_private_key(CONSENSUS_KEY, Ed25519PrivateKey::generate(&mut rng))?; - storage.import_private_key(EXECUTION_KEY, Ed25519PrivateKey::generate(&mut rng))?; - storage.import_private_key(FULLNODE_NETWORK_KEY, Ed25519PrivateKey::generate(&mut rng))?; - storage.import_private_key(VALIDATOR_NETWORK_KEY, Ed25519PrivateKey::generate(&mut rng))?; - - // Initialize all other data in storage - storage.set(SAFETY_DATA, SafetyData::new(0, 0, 0, 0, None))?; - storage.set(WAYPOINT, Waypoint::default())?; - - Ok(()) - } - - fn genesis_ceremony( - genesis_storage: &mut OnDiskStorage, - root_keys: &RootKeys, - validators: &[ValidatorConfig], - move_modules: Vec>, - min_price_per_gas_unit: u64, - ) -> Result<(Transaction, Waypoint)> { - let mut genesis_builder = GenesisBuilder::new(genesis_storage); - - // Set the Layout and Move modules - let layout = Layout { - owners: validators.iter().map(|v| v.owner()).collect(), - operators: validators.iter().map(|v| v.operator()).collect(), - aptos_root: APTOS_ROOT_NS.into(), - }; - genesis_builder.set_layout(&layout)?; - genesis_builder.set_move_modules(move_modules)?; - - // Set Root public keys - genesis_builder.set_root_key(Ed25519PublicKey::from(&root_keys.root_key))?; - - // Set Validator specific information - for validator in validators { - // Upload validator owner info - genesis_builder.set_owner_key(&validator.owner(), validator.owner_key()?)?; - - // Upload validator operator info - genesis_builder.set_operator(&validator.owner(), &validator.operator())?; - genesis_builder.set_operator_key(&validator.operator(), validator.operator_key()?)?; - - // Create and upload the onchain validator config - let validator_config = build_validator_config_transaction( - validator.storage(), - ChainId::test(), - 0, // sequence_number - validator.config.full_node_networks[0] - .listen_address - .clone(), - validator - .config - .validator_network - .as_ref() - .map(|a| a.listen_address.clone()) - .unwrap(), - false, // This isn't a reconfiguration - false, // Don't disable address validation - )?; - genesis_builder.set_validator_config(&validator.operator(), &validator_config)?; - } - genesis_builder.set_min_price_per_gas_unit(min_price_per_gas_unit)?; - - // Create Genesis and Genesis Waypoint - let genesis = genesis_builder.build(ChainId::test())?; - let waypoint = create_genesis_waypoint(&genesis)?; - - Ok((genesis, waypoint)) - } -} diff --git a/config/src/config/safety_rules_config.rs b/config/src/config/safety_rules_config.rs index 0a85c18cdc895..b2274cf620cc1 100644 --- a/config/src/config/safety_rules_config.rs +++ b/config/src/config/safety_rules_config.rs @@ -66,6 +66,13 @@ pub enum InitialSafetyRulesConfig { } impl InitialSafetyRulesConfig { + pub fn from_file(identity_blob_path: PathBuf, waypoint: WaypointConfig) -> Self { + Self::FromFile { + identity_blob_path, + waypoint, + } + } + pub fn waypoint(&self) -> Waypoint { match self { InitialSafetyRulesConfig::FromFile { waypoint, .. } => waypoint.waypoint(), diff --git a/crates/aptos-genesis/Cargo.toml b/crates/aptos-genesis/Cargo.toml new file mode 100644 index 0000000000000..5b01258fbc5d0 --- /dev/null +++ b/crates/aptos-genesis/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "aptos-genesis" +version = "0.1.0" +authors = ["Aptos Labs "] +description = "A tool to manage genesis" +repository = "https://github.com/aptos-labs/aptos-core" +homepage = "https://aptoslabs.com" +license = "Apache-2.0" +publish = false +edition = "2018" + +[dependencies] +anyhow = "1.0.57" +bcs = "0.1.3" +rand = "0.7.3" +serde = { version = "1.0.137", features = ["rc"], default-features = false } +serde_yaml = "0.8.24" +structopt = "0.3.21" +toml = { version = "0.5.9", default-features = false } + +aptos-config = { path = "../../config" } +aptos-crypto = { path = "../aptos-crypto" } +aptos-global-constants = { path = "../../config/global-constants" } +aptos-keygen = { path = "../aptos-keygen" } +aptos-management = { path = "../../config/management" } +aptos-secure-storage = { path = "../../secure/storage" } +aptos-state-view = { path = "../../storage/state-view" } +aptos-temppath = { path = "../aptos-temppath" } +aptos-types = { path = "../../types" } +aptos-vm = { path = "../../aptos-move/aptos-vm" } +aptos-workspace-hack = { path = "../aptos-workspace-hack" } +aptosdb = { path = "../../storage/aptosdb" } +cached-framework-packages = { path = "../../aptos-move/framework/cached-packages" } +consensus-types = { path = "../../consensus/consensus-types" } +executor = { path = "../../execution/executor" } +storage-interface = { path = "../../storage/storage-interface" } +vm-genesis = { path = "../../aptos-move/vm-genesis" } + +[dev-dependencies] +aptos-config = { path = "../../config", features = ["fuzzing"] } + +[features] +testing = [] +fuzzing = ["aptos-config/fuzzing"] diff --git a/crates/aptos-genesis/src/builder.rs b/crates/aptos-genesis/src/builder.rs new file mode 100644 index 0000000000000..d20e211b815f3 --- /dev/null +++ b/crates/aptos-genesis/src/builder.rs @@ -0,0 +1,521 @@ +// Copyright (c) Aptos +// SPDX-License-Identifier: Apache-2.0 + +use crate::{ + config::ValidatorConfiguration, + keys::{generate_key_objects, PrivateIdentity}, + GenesisInfo, +}; +use anyhow::ensure; +use aptos_config::{ + config::{ + DiscoveryMethod, Identity, IdentityBlob, InitialSafetyRulesConfig, NetworkConfig, + NodeConfig, PeerRole, RoleType, SafetyRulesService, WaypointConfig, + }, + generator::build_seed_for_network, + network_id::NetworkId, +}; +use aptos_crypto::{ + ed25519::{Ed25519PrivateKey, Ed25519PublicKey}, + PrivateKey, +}; +use aptos_keygen::KeyGen; +use aptos_types::{chain_id::ChainId, transaction::Transaction, waypoint::Waypoint}; +use rand::Rng; +use serde::{de::DeserializeOwned, Serialize}; +use std::{ + convert::{TryFrom, TryInto}, + fs::File, + io::{Read, Write}, + num::NonZeroUsize, + path::{Path, PathBuf}, +}; + +const VALIDATOR_IDENTITY: &str = "validator-identity.yaml"; +const VFN_IDENTITY: &str = "vfn-identity.yaml"; +const PRIVATE_IDENTITY: &str = "private-identity.yaml"; +const CONFIG_FILE: &str = "node.yaml"; +const GENESIS_BLOB: &str = "genesis.blob"; + +/// Configuration to run a local validator node +#[derive(Debug, Clone)] +pub struct ValidatorNodeConfig { + pub name: String, + pub config: NodeConfig, + pub dir: PathBuf, +} + +impl ValidatorNodeConfig { + /// Create a new validator and initialize keys appropriately + pub fn new( + name: String, + base_dir: &Path, + mut config: NodeConfig, + ) -> anyhow::Result { + // Create the data dir and set it appropriately + let dir = base_dir.join(&name); + std::fs::create_dir_all(dir.as_path())?; + config.set_data_dir(dir.clone()); + + Ok(ValidatorNodeConfig { name, config, dir }) + } + + /// Initializes keys and identities for a validator config + /// TODO: Put this all in storage rather than files? + fn init_keys(&mut self, seed: Option<[u8; 32]>) -> anyhow::Result<()> { + self.get_key_objects(seed)?; + + // Init network identity + let validator_network = self.config.validator_network.as_mut().unwrap(); + let validator_identity_file = self.dir.join(VALIDATOR_IDENTITY); + validator_network.identity = Identity::from_file(validator_identity_file); + + Ok(()) + } + + /// Allows for on disk caching of already generated keys + pub fn get_key_objects( + &self, + seed: Option<[u8; 32]>, + ) -> anyhow::Result<(IdentityBlob, IdentityBlob, PrivateIdentity)> { + let dir = &self.dir; + let val_identity_file = dir.join(VALIDATOR_IDENTITY); + let vfn_identity_file = dir.join(VFN_IDENTITY); + let private_identity_file = dir.join(PRIVATE_IDENTITY); + + // If they all already exist, use them, otherwise generate new ones and overwrite + if val_identity_file.exists() + && vfn_identity_file.exists() + && private_identity_file.exists() + { + Ok(( + read_yaml(val_identity_file.as_path())?, + read_yaml(vfn_identity_file.as_path())?, + read_yaml(private_identity_file.as_path())?, + )) + } else { + let mut key_generator = if let Some(seed) = seed { + KeyGen::from_seed(seed) + } else { + KeyGen::from_os_rng() + }; + + let (validator_identity, vfn_identity, private_identity) = + generate_key_objects(&mut key_generator)?; + + // Write identities in files + write_yaml(val_identity_file.as_path(), &validator_identity)?; + write_yaml(vfn_identity_file.as_path(), &vfn_identity)?; + write_yaml(private_identity_file.as_path(), &private_identity)?; + Ok((validator_identity, vfn_identity, private_identity)) + } + } + + fn insert_genesis(&mut self, genesis: &Transaction) { + self.config.execution.genesis = Some(genesis.clone()); + self.config.execution.genesis_file_location = self.dir.join(GENESIS_BLOB) + } + + fn insert_waypoint(&mut self, waypoint: &Waypoint) { + let waypoint_config = WaypointConfig::FromConfig(*waypoint); + + // Init safety rules + let validator_identity_file = self.dir.join(VALIDATOR_IDENTITY); + self.config + .consensus + .safety_rules + .initial_safety_rules_config = + InitialSafetyRulesConfig::from_file(validator_identity_file, waypoint_config.clone()); + self.config.base.waypoint = waypoint_config; + } + + fn save_config(&mut self) -> anyhow::Result<()> { + Ok(self.config.save(self.dir.join(CONFIG_FILE))?) + } +} + +impl TryFrom<&ValidatorNodeConfig> for ValidatorConfiguration { + type Error = anyhow::Error; + + fn try_from(config: &ValidatorNodeConfig) -> Result { + let (_, _, private_identity) = config.get_key_objects(None)?; + let validator_host = (&config + .config + .validator_network + .as_ref() + .unwrap() + .listen_address) + .try_into()?; + let full_node_host = Some( + (&config + .config + .full_node_networks + .iter() + .find(|network| network.network_id == NetworkId::Public) + .unwrap() + .listen_address) + .try_into()?, + ); + Ok(ValidatorConfiguration { + account_address: private_identity.account_address, + consensus_public_key: private_identity.consensus_private_key.public_key(), + account_public_key: private_identity.account_private_key.public_key(), + validator_network_public_key: private_identity + .validator_network_private_key + .public_key(), + validator_host, + full_node_network_public_key: Some( + private_identity.full_node_network_private_key.public_key(), + ), + full_node_host, + stake_amount: 1, + }) + } +} + +pub struct FullnodeNodeConfig { + pub name: String, + pub config: NodeConfig, + pub dir: PathBuf, +} + +impl FullnodeNodeConfig { + pub fn public_fullnode( + name: String, + config_dir: &Path, + config: NodeConfig, + waypoint: &Waypoint, + genesis: &Transaction, + ) -> anyhow::Result { + let mut fullnode_config = Self::new(name, config_dir, config)?; + + fullnode_config.insert_waypoint(waypoint); + fullnode_config.insert_genesis(genesis)?; + fullnode_config.set_identity()?; + fullnode_config.config.randomize_ports(); + fullnode_config.save_config()?; + + Ok(fullnode_config) + } + + pub fn validator_fullnode( + name: String, + config_dir: &Path, + fullnode_config: NodeConfig, + validator_config: &mut NodeConfig, + waypoint: &Waypoint, + genesis: &Transaction, + ) -> anyhow::Result { + let mut fullnode_config = Self::new(name, config_dir, fullnode_config)?; + + fullnode_config.insert_waypoint(waypoint); + fullnode_config.insert_genesis(genesis)?; + fullnode_config.config.randomize_ports(); + fullnode_config.attach_to_validator(validator_config)?; + fullnode_config.save_config()?; + + Ok(fullnode_config) + } + + fn new(name: String, config_dir: &Path, mut config: NodeConfig) -> anyhow::Result { + ensure!( + matches!(config.base.role, RoleType::FullNode), + "config must be a FullNode config" + ); + + let dir = config_dir.join(&name); + std::fs::create_dir_all(&dir)?; + + config.set_data_dir(dir.clone()); + + Ok(Self { name, config, dir }) + } + + fn insert_waypoint(&mut self, waypoint: &Waypoint) { + self.config.base.waypoint = WaypointConfig::FromConfig(*waypoint); + } + + fn insert_genesis(&mut self, genesis: &Transaction) -> anyhow::Result<()> { + // Save genesis file in this validator's config dir + let genesis_file_location = self.dir.join("genesis.blob"); + File::create(&genesis_file_location)?.write_all(&bcs::to_bytes(&genesis)?)?; + + self.config.execution.genesis = Some(genesis.clone()); + self.config.execution.genesis_file_location = genesis_file_location; + + Ok(()) + } + + /// Sets identity for a public full node. Should only be run on a public full node + fn set_identity(&mut self) -> anyhow::Result<()> { + if self + .config + .full_node_networks + .iter() + .any(|config| config.network_id == NetworkId::Vfn) + { + panic!("Shouldn't call set_identity on a Validator full node"); + } + + let public_network = self + .config + .full_node_networks + .iter_mut() + .find(|config| config.network_id == NetworkId::Public) + .unwrap(); + + set_identity_for_network(public_network)?; + Ok(()) + } + + /// Attaches a Full node to a validator full node + fn attach_to_validator(&mut self, validator_config: &mut NodeConfig) -> anyhow::Result<()> { + ensure!( + matches!(validator_config.base.role, RoleType::Validator), + "Validator config must be a Validator config" + ); + + // Grab the public network config from the validator and insert it into the VFN's config + // The validator's public network identity is the same as the VFN's public network identity + // We remove it from the validator so the VFN can hold it + let public_network = { + let (i, _) = validator_config + .full_node_networks + .iter() + .enumerate() + .find(|(_i, config)| config.network_id == NetworkId::Public) + .expect("Validator should have a public network"); + validator_config.full_node_networks.remove(i) + }; + + let fullnode_public_network = self + .config + .full_node_networks + .iter_mut() + .find(|config| config.network_id == NetworkId::Public) + .expect("VFN should have a public network"); + fullnode_public_network.identity = public_network.identity; + fullnode_public_network.listen_address = public_network.listen_address; + + // Grab the validator's vfn network information and configure it as a seed for the VFN's + // vfn network + let validators_vfn_network = validator_config + .full_node_networks + .iter() + .find(|config| config.network_id.is_vfn_network()) + .expect("Validator should have vfn network"); + + let fullnode_vfn_network = self + .config + .full_node_networks + .iter_mut() + .find(|config| config.network_id.is_vfn_network()) + .expect("VFN should have a vfn network"); + fullnode_vfn_network.seeds = + build_seed_for_network(validators_vfn_network, PeerRole::Validator); + + // Set the identity for the VFN port + set_identity_for_network(fullnode_vfn_network)?; + + Ok(()) + } + + pub fn config_path(&self) -> PathBuf { + self.dir.join("node.yaml") + } + + fn save_config(&mut self) -> anyhow::Result<()> { + self.config.save(self.config_path()).map_err(Into::into) + } +} + +fn set_identity_for_network(network: &mut NetworkConfig) -> anyhow::Result<()> { + if let Identity::None = network.identity { + let mut keygen = KeyGen::from_os_rng(); + let key = keygen.generate_x25519_private_key()?; + let peer_id = aptos_types::account_address::from_identity_public_key(key.public_key()); + network.identity = Identity::from_config(key, peer_id); + } + Ok(()) +} + +fn read_yaml(path: &Path) -> anyhow::Result { + let mut string = String::new(); + File::open(path)?.read_to_string(&mut string)?; + Ok(serde_yaml::from_str(&string)?) +} + +fn write_yaml(path: &Path, object: &T) -> anyhow::Result<()> { + File::create(path)?.write_all(serde_yaml::to_string(object)?.as_bytes())?; + Ok(()) +} + +/// Builder that builds a network of validator nodes that can run locally +#[derive(Clone)] +pub struct Builder { + config_dir: PathBuf, + move_modules: Vec>, + num_validators: NonZeroUsize, + randomize_first_validator_ports: bool, + template: NodeConfig, + min_price_per_gas_unit: u64, +} + +impl Builder { + pub fn new(config_dir: &Path, move_modules: Vec>) -> anyhow::Result { + let config_dir: PathBuf = config_dir.into(); + let config_dir = config_dir.canonicalize()?; + Ok(Self { + config_dir, + move_modules, + num_validators: NonZeroUsize::new(1).unwrap(), + randomize_first_validator_ports: true, + template: NodeConfig::default_for_validator(), + min_price_per_gas_unit: 1, + }) + } + + pub fn with_randomize_first_validator_ports(mut self, value: bool) -> Self { + self.randomize_first_validator_ports = value; + self + } + + pub fn with_num_validators(mut self, num_validators: NonZeroUsize) -> Self { + self.num_validators = num_validators; + self + } + + pub fn with_template(mut self, template: NodeConfig) -> Self { + self.template = template; + self + } + + pub fn with_min_price_per_gas_unit(mut self, min_price_per_gas_unit: u64) -> Self { + self.min_price_per_gas_unit = min_price_per_gas_unit; + self + } + + /// Build all of the validators and save their configs + pub fn build( + mut self, + mut rng: R, + ) -> anyhow::Result<( + Ed25519PrivateKey, + Transaction, + Waypoint, + Vec, + )> + where + R: rand::RngCore + rand::CryptoRng, + { + let mut keygen = KeyGen::from_seed(rng.gen()); + + // Generate root key + let root_key = keygen.generate_ed25519_private_key(); + + // Generate validator configs + let mut validators: Vec = (0..self.num_validators.get()) + .map(|i| self.generate_validator_config(i, &mut rng)) + .collect::>>()?; + + // Build genesis + let (genesis, waypoint) = self.genesis_ceremony(&mut validators, root_key.public_key())?; + + // Save configs for validators so they can run + for validator in validators.iter_mut() { + validator.save_config()?; + } + + Ok((root_key, genesis, waypoint, validators)) + } + + /// Generate a configuration for a single validator + fn generate_validator_config( + &mut self, + index: usize, + mut rng: R, + ) -> anyhow::Result + where + R: rand::RngCore + rand::CryptoRng, + { + let name = index.to_string(); + + let mut validator = + ValidatorNodeConfig::new(name, self.config_dir.as_path(), self.template.clone())?; + + validator.init_keys(Some(rng.gen()))?; + + // By default, we don't start with VFNs, so ensure that the REST port is open + let vfn_identity_path = validator.dir.join(VFN_IDENTITY); + + let config = &mut validator.config; + let fullnode_network_listen_address = + if let Some(template_fullnode_config) = config.full_node_networks.first() { + template_fullnode_config.listen_address.clone() + } else { + aptos_config::utils::get_available_port_in_multiaddr(true) + }; + + let fullnode_network = NetworkConfig { + listen_address: fullnode_network_listen_address, + network_id: NetworkId::Public, + max_outbound_connections: 0, + discovery_method: DiscoveryMethod::Onchain, + identity: Identity::from_file(vfn_identity_path.clone()), + ..Default::default() + }; + + // VFN has the same credentials as the public full node identity + let vfn_network = NetworkConfig { + listen_address: aptos_config::utils::get_available_port_in_multiaddr(true), + network_id: NetworkId::Vfn, + max_outbound_connections: 0, + identity: Identity::from_file(vfn_identity_path), + ..Default::default() + }; + + config.full_node_networks = vec![fullnode_network, vfn_network]; + + // Ensure safety rules runs in a thread + config.consensus.safety_rules.service = SafetyRulesService::Thread; + + if index > 0 || self.randomize_first_validator_ports { + config.randomize_ports(); + } + + Ok(validator) + } + + /// Do the genesis ceremony and copy waypoint and genesis to each node + fn genesis_ceremony( + &mut self, + validators: &mut Vec, + root_key: Ed25519PublicKey, + ) -> anyhow::Result<(Transaction, Waypoint)> { + let mut configs: Vec = Vec::new(); + + for validator in validators.iter() { + configs.push(validator.try_into()?); + } + + // Build genesis & waypoint + let mut genesis_info = GenesisInfo::new( + ChainId::test(), + root_key, + configs, + self.move_modules.clone(), + self.min_price_per_gas_unit, + )?; + let waypoint = genesis_info.generate_waypoint()?; + let genesis = genesis_info.get_genesis(); + + // Insert genesis and waypoint into validators + // TODO: verify genesis? + for validator in validators { + validator.insert_waypoint(&waypoint); + validator.insert_genesis(genesis); + } + + Ok((genesis.clone(), waypoint)) + } +} diff --git a/crates/aptos/src/genesis/config.rs b/crates/aptos-genesis/src/config.rs similarity index 78% rename from crates/aptos/src/genesis/config.rs rename to crates/aptos-genesis/src/config.rs index 9a3a586640b87..29be59ee919d9 100644 --- a/crates/aptos/src/genesis/config.rs +++ b/crates/aptos-genesis/src/config.rs @@ -1,25 +1,22 @@ // Copyright (c) Aptos // SPDX-License-Identifier: Apache-2.0 -use crate::{ - common::types::{CliError, CliTypedResult}, - genesis::git::from_yaml, -}; use aptos_config::config::HANDSHAKE_VERSION; use aptos_crypto::{ed25519::Ed25519PublicKey, x25519}; use aptos_types::{ + account_address::AccountAddress, chain_id::ChainId, network_address::{DnsName, NetworkAddress, Protocol}, transaction::authenticator::AuthenticationKey, }; -use move_deps::move_core_types::account_address::AccountAddress; use serde::{Deserialize, Serialize}; use std::{ + collections::HashMap, convert::TryFrom, fs::File, io::Read, - net::{Ipv4Addr, Ipv6Addr}, - path::PathBuf, + net::{Ipv4Addr, Ipv6Addr, ToSocketAddrs}, + path::Path, str::FromStr, }; use vm_genesis::Validator; @@ -35,17 +32,29 @@ pub struct Layout { pub users: Vec, /// ChainId for the target network pub chain_id: ChainId, + /// Whether to allow validators to join post genesis + #[serde(default)] + pub allow_new_validators: bool, + /// Initial lockup period for genesis validators + #[serde(default)] + pub initial_lockup_period_duration_secs: u64, + /// Initial balances for the target network + #[serde(default)] + pub initial_balances: HashMap, } impl Layout { /// Read the layout from a YAML file on disk - pub fn from_disk(path: &PathBuf) -> CliTypedResult { - let mut file = - File::open(&path).map_err(|e| CliError::IO(path.display().to_string(), e))?; + pub fn from_disk(path: &Path) -> anyhow::Result { + let mut file = File::open(&path).map_err(|e| { + anyhow::Error::msg(format!("Failed to open file {}, {}", path.display(), e)) + })?; let mut contents = String::new(); - file.read_to_string(&mut contents) - .map_err(|e| CliError::IO(path.display().to_string(), e))?; - from_yaml(&contents) + file.read_to_string(&mut contents).map_err(|e| { + anyhow::Error::msg(format!("Failed to read file {}, {}", path.display(), e)) + })?; + + Ok(serde_yaml::from_str(&contents)?) } } @@ -95,9 +104,9 @@ pub struct StringValidatorConfiguration { } impl TryFrom for Validator { - type Error = CliError; + type Error = anyhow::Error; - fn try_from(config: ValidatorConfiguration) -> Result { + fn try_from(config: ValidatorConfiguration) -> Result { let auth_key = AuthenticationKey::ed25519(&config.account_public_key); let validator_addresses = vec![config .validator_host @@ -109,8 +118,8 @@ impl TryFrom for Validator { .as_network_address(full_node_network_key) .unwrap()] } else { - return Err(CliError::CommandArgumentError( - "Full node host specified, but not full node network key".to_string(), + return Err(anyhow::Error::msg( + "Full node host specified, but not full node network key", )); } } else { @@ -119,7 +128,7 @@ impl TryFrom for Validator { let derived_address = auth_key.derived_address(); if config.account_address != derived_address { - return Err(CliError::CommandArgumentError(format!( + return Err(anyhow::Error::msg(format!( "AccountAddress {} does not match account key derived one {}", config.account_address, derived_address ))); @@ -143,7 +152,7 @@ pub struct HostAndPort { } impl HostAndPort { - pub fn as_network_address(&self, key: x25519::PublicKey) -> CliTypedResult { + pub fn as_network_address(&self, key: x25519::PublicKey) -> anyhow::Result { let host = self.host.to_string(); // Since DnsName supports IPs as well, let's properly fix what the type is @@ -158,31 +167,36 @@ impl HostAndPort { let noise_protocol = Protocol::NoiseIK(key); let handshake_protocol = Protocol::Handshake(HANDSHAKE_VERSION); - NetworkAddress::try_from(vec![ + Ok(NetworkAddress::try_from(vec![ host_protocol, port_protocol, noise_protocol, handshake_protocol, - ]) - .map_err(|e| CliError::UnexpectedError(e.to_string())) + ])?) + } +} + +impl TryFrom<&NetworkAddress> for HostAndPort { + type Error = anyhow::Error; + + fn try_from(address: &NetworkAddress) -> Result { + let socket_addr = address.to_socket_addrs()?.next().unwrap(); + HostAndPort::from_str(&socket_addr.to_string()) } } impl FromStr for HostAndPort { - type Err = CliError; + type Err = anyhow::Error; fn from_str(s: &str) -> Result { let parts: Vec<_> = s.split(':').collect(); if parts.len() != 2 { - Err(CliError::CommandArgumentError( - "Invalid host and port, must be of the form 'host:port` e.g. '127.0.0.1:6180'" - .to_string(), + Err(anyhow::Error::msg( + "Invalid host and port, must be of the form 'host:port` e.g. '127.0.0.1:6180'", )) } else { - let host = DnsName::from_str(*parts.get(0).unwrap()) - .map_err(|e| CliError::CommandArgumentError(e.to_string()))?; - let port = u16::from_str(parts.get(1).unwrap()) - .map_err(|e| CliError::CommandArgumentError(e.to_string()))?; + let host = DnsName::from_str(*parts.get(0).unwrap())?; + let port = u16::from_str(parts.get(1).unwrap())?; Ok(HostAndPort { host, port }) } } diff --git a/crates/aptos-genesis/src/keys.rs b/crates/aptos-genesis/src/keys.rs new file mode 100644 index 0000000000000..679750beb9f17 --- /dev/null +++ b/crates/aptos-genesis/src/keys.rs @@ -0,0 +1,85 @@ +// Copyright (c) Aptos +// SPDX-License-Identifier: Apache-2.0 + +use crate::config::{HostAndPort, ValidatorConfiguration}; +use aptos_config::{config::IdentityBlob, keys::ConfigKey}; +use aptos_crypto::{ed25519::Ed25519PrivateKey, x25519, PrivateKey}; +use aptos_keygen::KeyGen; +use aptos_types::{account_address::AccountAddress, transaction::authenticator::AuthenticationKey}; +use serde::{Deserialize, Serialize}; + +/// Type for serializing private keys file +#[derive(Deserialize, Serialize)] +pub struct PrivateIdentity { + pub account_address: AccountAddress, + pub account_private_key: Ed25519PrivateKey, + pub consensus_private_key: Ed25519PrivateKey, + pub full_node_network_private_key: x25519::PrivateKey, + pub validator_network_private_key: x25519::PrivateKey, +} + +/// Builds validator configuration from private identity +pub fn build_validator_configuration( + private_identity: PrivateIdentity, + validator_host: HostAndPort, + full_node_host: Option, + stake_amount: u64, +) -> anyhow::Result { + let account_address = private_identity.account_address; + let account_public_key = private_identity.account_private_key.public_key(); + let consensus_public_key = private_identity.consensus_private_key.public_key(); + let validator_network_public_key = private_identity.validator_network_private_key.public_key(); + + let full_node_network_public_key = if full_node_host.is_some() { + Some(private_identity.full_node_network_private_key.public_key()) + } else { + None + }; + + Ok(ValidatorConfiguration { + account_address, + consensus_public_key, + account_public_key, + validator_network_public_key, + validator_host, + full_node_network_public_key, + full_node_host, + stake_amount, + }) +} + +/// Generates objects used for a user in genesis +pub fn generate_key_objects( + keygen: &mut KeyGen, +) -> anyhow::Result<(IdentityBlob, IdentityBlob, PrivateIdentity)> { + let account_key = ConfigKey::new(keygen.generate_ed25519_private_key()); + let consensus_key = ConfigKey::new(keygen.generate_ed25519_private_key()); + let validator_network_key = ConfigKey::new(keygen.generate_x25519_private_key()?); + let full_node_network_key = ConfigKey::new(keygen.generate_x25519_private_key()?); + + let account_address = AuthenticationKey::ed25519(&account_key.public_key()).derived_address(); + + // Build these for use later as node identity + let validator_blob = IdentityBlob { + account_address: Some(account_address), + account_private_key: Some(account_key.private_key()), + consensus_private_key: Some(consensus_key.private_key()), + network_private_key: validator_network_key.private_key(), + }; + let vfn_blob = IdentityBlob { + account_address: Some(account_address), + account_private_key: None, + consensus_private_key: None, + network_private_key: full_node_network_key.private_key(), + }; + + let private_identity = PrivateIdentity { + account_address, + account_private_key: account_key.private_key(), + consensus_private_key: consensus_key.private_key(), + full_node_network_private_key: full_node_network_key.private_key(), + validator_network_private_key: validator_network_key.private_key(), + }; + + Ok((validator_blob, vfn_blob, private_identity)) +} diff --git a/crates/aptos-genesis/src/lib.rs b/crates/aptos-genesis/src/lib.rs new file mode 100644 index 0000000000000..9c89d3c55284d --- /dev/null +++ b/crates/aptos-genesis/src/lib.rs @@ -0,0 +1,91 @@ +// Copyright (c) Aptos +// SPDX-License-Identifier: Apache-2.0 + +#![forbid(unsafe_code)] + +pub mod builder; +pub mod config; +pub mod keys; + +#[cfg(any(test, feature = "testing"))] +pub mod test_utils; + +use crate::config::ValidatorConfiguration; +use aptos_config::config::{RocksdbConfig, NO_OP_STORAGE_PRUNER_CONFIG}; +use aptos_crypto::ed25519::Ed25519PublicKey; +use aptos_temppath::TempPath; +use aptos_types::{chain_id::ChainId, transaction::Transaction, waypoint::Waypoint}; +use aptos_vm::AptosVM; +use aptosdb::AptosDB; +use std::convert::TryInto; +use storage_interface::DbReaderWriter; +use vm_genesis::Validator; + +/// Holder object for all pieces needed to generate a genesis transaction +#[derive(Clone)] +pub struct GenesisInfo { + chain_id: ChainId, + root_key: Ed25519PublicKey, + validators: Vec, + /// Compiled bytecode of framework modules + modules: Vec>, + min_price_per_gas_unit: u64, + genesis: Option, +} + +impl GenesisInfo { + pub fn new( + chain_id: ChainId, + root_key: Ed25519PublicKey, + configs: Vec, + modules: Vec>, + min_price_per_gas_unit: u64, + ) -> anyhow::Result { + let mut validators = Vec::new(); + + for config in configs { + validators.push(config.try_into()?) + } + + Ok(GenesisInfo { + chain_id, + root_key, + validators, + modules, + min_price_per_gas_unit, + genesis: None, + }) + } + + pub fn get_genesis(&mut self) -> &Transaction { + if let Some(ref genesis) = self.genesis { + genesis + } else { + self.genesis = Some(self.generate_genesis_txn()); + self.genesis.as_ref().unwrap() + } + } + + fn generate_genesis_txn(&self) -> Transaction { + vm_genesis::encode_genesis_transaction( + self.root_key.clone(), + &self.validators, + &self.modules, + self.chain_id, + self.min_price_per_gas_unit, + ) + } + + pub fn generate_waypoint(&mut self) -> anyhow::Result { + let genesis = self.get_genesis(); + let path = TempPath::new(); + let aptosdb = AptosDB::open( + &path, + false, + NO_OP_STORAGE_PRUNER_CONFIG, + RocksdbConfig::default(), + )?; + let db_rw = DbReaderWriter::new(aptosdb); + executor::db_bootstrapper::generate_waypoint::(&db_rw, genesis) + } +} diff --git a/crates/aptos-genesis/src/test_utils.rs b/crates/aptos-genesis/src/test_utils.rs new file mode 100644 index 0000000000000..a06d762d92341 --- /dev/null +++ b/crates/aptos-genesis/src/test_utils.rs @@ -0,0 +1,44 @@ +// Copyright (c) Aptos +// SPDX-License-Identifier: Apache-2.0 + +use aptos_config::config::{IdentityBlob, NodeConfig}; +use aptos_crypto::ed25519::Ed25519PrivateKey; +use aptos_temppath::TempPath; +use rand::{rngs::StdRng, SeedableRng}; + +pub fn test_config() -> (NodeConfig, Ed25519PrivateKey) { + let path = TempPath::new(); + path.create_as_dir().unwrap(); + let (root_key, _genesis, _genesis_waypoint, validators) = crate::builder::Builder::new( + path.path(), + cached_framework_packages::module_blobs().to_vec(), + ) + .unwrap() + .with_template(NodeConfig::default_for_validator()) + .build(StdRng::from_seed([0; 32])) + .unwrap(); + let ( + IdentityBlob { + account_address, + account_private_key, + consensus_private_key, + .. + }, + _, + _, + ) = validators[0].get_key_objects(None).unwrap(); + let mut configs = validators.into_iter().map(|v| v.config).collect::>(); + + let mut config = configs.swap_remove(0); + config.set_data_dir(path.path().to_path_buf()); + let mut test = aptos_config::config::TestConfig::new_with_temp_dir(Some(path)); + + test.owner_key(account_private_key.unwrap()); + config.test = Some(test); + + let mut sr_test = aptos_config::config::SafetyRulesTestConfig::new(account_address.unwrap()); + sr_test.consensus_key(consensus_private_key.unwrap()); + config.consensus.safety_rules.test = Some(sr_test); + + (config, root_key) +} diff --git a/crates/aptos/Cargo.toml b/crates/aptos/Cargo.toml index 4fdfae3ce9667..67129f43f5e38 100644 --- a/crates/aptos/Cargo.toml +++ b/crates/aptos/Cargo.toml @@ -33,6 +33,7 @@ uuid = { version = "1.0.0", features = ["v4", "serde"] } aptos-config = { path = "../../config" } aptos-crypto = { path = "../aptos-crypto", features = [] } +aptos-genesis = { path = "../aptos-genesis" } aptos-github-client = { path = "../../secure/storage/github" } aptos-keygen = { path = "../aptos-keygen" } aptos-logger = { path = "../aptos-logger" } diff --git a/crates/aptos/src/common/types.rs b/crates/aptos/src/common/types.rs index b7572f9977ea4..1c703c58009f7 100644 --- a/crates/aptos/src/common/types.rs +++ b/crates/aptos/src/common/types.rs @@ -132,6 +132,12 @@ impl From for CliError { } } +impl From for CliError { + fn from(e: anyhow::Error) -> Self { + CliError::UnexpectedError(e.to_string()) + } +} + /// Config saved to `.aptos/config.yaml` #[derive(Debug, Serialize, Deserialize)] pub struct CliConfig { diff --git a/crates/aptos/src/genesis/git.rs b/crates/aptos/src/genesis/git.rs index fb0d54fc43ae8..a24df46dc84fa 100644 --- a/crates/aptos/src/genesis/git.rs +++ b/crates/aptos/src/genesis/git.rs @@ -6,10 +6,10 @@ use crate::{ types::{CliError, CliTypedResult}, utils::write_to_file, }, - genesis::config::Layout, CliCommand, }; use aptos_config::config::Token; +use aptos_genesis::config::Layout; use aptos_github_client::Client as GithubClient; use async_trait::async_trait; use clap::Parser; diff --git a/crates/aptos/src/genesis/keys.rs b/crates/aptos/src/genesis/keys.rs index ac22b6994146f..e828fdc3742c4 100644 --- a/crates/aptos/src/genesis/keys.rs +++ b/crates/aptos/src/genesis/keys.rs @@ -6,19 +6,16 @@ use crate::{ types::{CliError, CliTypedResult, PromptOptions, RngArgs}, utils::{check_if_file_exists, read_from_file, write_to_user_only_file}, }, - genesis::{ - config::{HostAndPort, ValidatorConfiguration}, - git::{from_yaml, to_yaml, GitOptions}, - }, + genesis::git::{from_yaml, to_yaml, GitOptions}, CliCommand, }; -use aptos_config::{config::IdentityBlob, keys::ConfigKey}; -use aptos_crypto::{ed25519::Ed25519PrivateKey, x25519, PrivateKey}; -use aptos_types::transaction::authenticator::AuthenticationKey; +use aptos_crypto::PrivateKey; +use aptos_genesis::{ + config::{HostAndPort, ValidatorConfiguration}, + keys::{generate_key_objects, PrivateIdentity}, +}; use async_trait::async_trait; use clap::Parser; -use move_deps::move_core_types::account_address::AccountAddress; -use serde::{Deserialize, Serialize}; use std::path::PathBuf; const PRIVATE_KEYS_FILE: &str = "private-keys.yaml"; @@ -51,36 +48,9 @@ impl CliCommand> for GenerateKeys { check_if_file_exists(validator_file.as_path(), self.prompt_options)?; check_if_file_exists(vfn_file.as_path(), self.prompt_options)?; - let mut keygen = self.rng_args.key_generator()?; - let account_key = ConfigKey::new(keygen.generate_ed25519_private_key()); - let consensus_key = ConfigKey::new(keygen.generate_ed25519_private_key()); - let validator_network_key = ConfigKey::new(keygen.generate_x25519_private_key()?); - let full_node_network_key = ConfigKey::new(keygen.generate_x25519_private_key()?); - - let account_address = - AuthenticationKey::ed25519(&account_key.public_key()).derived_address(); - - // Build these for use later as node identity - let validator_blob = IdentityBlob { - account_address: Some(account_address), - account_private_key: Some(account_key.private_key()), - consensus_private_key: Some(consensus_key.private_key()), - network_private_key: validator_network_key.private_key(), - }; - let vfn_blob = IdentityBlob { - account_address: Some(account_address), - account_private_key: None, - consensus_private_key: None, - network_private_key: full_node_network_key.private_key(), - }; - - let config = PrivateIdentity { - account_address, - account_private_key: account_key.private_key(), - consensus_private_key: consensus_key.private_key(), - full_node_network_private_key: full_node_network_key.private_key(), - validator_network_private_key: validator_network_key.private_key(), - }; + let mut key_generator = self.rng_args.key_generator()?; + let (validator_blob, vfn_blob, private_identity) = + generate_key_objects(&mut key_generator)?; // Create the directory if it doesn't exist if !self.output_dir.exists() || !self.output_dir.is_dir() { @@ -91,7 +61,7 @@ impl CliCommand> for GenerateKeys { write_to_user_only_file( keys_file.as_path(), PRIVATE_KEYS_FILE, - to_yaml(&config)?.as_bytes(), + to_yaml(&private_identity)?.as_bytes(), )?; write_to_user_only_file( validator_file.as_path(), @@ -103,16 +73,6 @@ impl CliCommand> for GenerateKeys { } } -/// Type for serializing private keys file -#[derive(Deserialize, Serialize)] -pub struct PrivateIdentity { - account_address: AccountAddress, - account_private_key: Ed25519PrivateKey, - consensus_private_key: Ed25519PrivateKey, - full_node_network_private_key: x25519::PrivateKey, - validator_network_private_key: x25519::PrivateKey, -} - /// Set ValidatorConfiguration for a single validator in the git repository #[derive(Parser)] pub struct SetValidatorConfiguration { diff --git a/crates/aptos/src/genesis/mod.rs b/crates/aptos/src/genesis/mod.rs index 3b88f6ac997b1..55514be3f25cb 100644 --- a/crates/aptos/src/genesis/mod.rs +++ b/crates/aptos/src/genesis/mod.rs @@ -1,7 +1,6 @@ // Copyright (c) Aptos // SPDX-License-Identifier: Apache-2.0 -pub mod config; pub mod git; pub mod keys; #[cfg(test)] @@ -12,23 +11,19 @@ use crate::{ types::{CliError, CliTypedResult, PromptOptions}, utils::{check_if_file_exists, write_to_file}, }, - genesis::{ - config::{Layout, StringValidatorConfiguration, ValidatorConfiguration}, - git::{Client, GitOptions, LAYOUT_NAME}, - }, + genesis::git::{Client, GitOptions, LAYOUT_NAME}, CliCommand, CliResult, }; -use aptos_config::config::{RocksdbConfig, NO_OP_STORAGE_PRUNER_CONFIG}; use aptos_crypto::{ed25519::Ed25519PublicKey, x25519, ValidCryptoMaterialStringExt}; -use aptos_temppath::TempPath; -use aptos_types::{account_address::AccountAddress, chain_id::ChainId, transaction::Transaction}; -use aptos_vm::AptosVM; -use aptosdb::AptosDB; +use aptos_genesis::{ + config::{HostAndPort, Layout, ValidatorConfiguration}, + GenesisInfo, +}; +use aptos_types::account_address::AccountAddress; use async_trait::async_trait; use clap::Parser; -use std::{convert::TryInto, path::PathBuf, str::FromStr}; -use storage_interface::DbReaderWriter; -use vm_genesis::Validator; +use serde::{Deserialize, Serialize}; +use std::{path::PathBuf, str::FromStr}; const MIN_PRICE_PER_GAS_UNIT: u64 = 1; const WAYPOINT_FILE: &str = "waypoint.txt"; @@ -66,20 +61,6 @@ pub struct GenerateGenesis { output_dir: PathBuf, } -impl GenerateGenesis { - fn generate_genesis_txn(git_options: GitOptions) -> CliTypedResult { - let genesis_info = fetch_genesis_info(git_options)?; - - Ok(vm_genesis::encode_genesis_transaction( - genesis_info.root_key.clone(), - &genesis_info.validators, - &genesis_info.modules, - genesis_info.chain_id, - MIN_PRICE_PER_GAS_UNIT, - )) - } -} - #[async_trait] impl CliCommand> for GenerateGenesis { fn command_name(&self) -> &'static str { @@ -93,25 +74,16 @@ impl CliCommand> for GenerateGenesis { check_if_file_exists(waypoint_file.as_path(), self.prompt_options)?; // Generate genesis file - let genesis = Self::generate_genesis_txn(self.git_options)?; + let mut genesis_info = fetch_genesis_info(self.git_options)?; + let genesis = genesis_info.get_genesis(); write_to_file( genesis_file.as_path(), GENESIS_FILE, - &bcs::to_bytes(&genesis).map_err(|e| CliError::BCS(GENESIS_FILE, e))?, + &bcs::to_bytes(genesis).map_err(|e| CliError::BCS(GENESIS_FILE, e))?, )?; // Generate waypoint file - let path = TempPath::new(); - let aptosdb = AptosDB::open( - &path, - false, - NO_OP_STORAGE_PRUNER_CONFIG, - RocksdbConfig::default(), - ) - .map_err(|e| CliError::UnexpectedError(e.to_string()))?; - let db_rw = DbReaderWriter::new(aptosdb); - let waypoint = executor::db_bootstrapper::generate_waypoint::(&db_rw, &genesis) - .map_err(|e| CliError::UnexpectedError(e.to_string()))?; + let waypoint = genesis_info.generate_waypoint()?; write_to_file( waypoint_file.as_path(), WAYPOINT_FILE, @@ -156,16 +128,17 @@ pub fn fetch_genesis_info(git_options: GitOptions) -> CliTypedResult CliTypedResult { +fn get_config(client: &Client, user: &str) -> CliTypedResult { let config = client.get::(user)?; // Convert each individually @@ -191,7 +164,7 @@ fn get_config(client: &Client, user: &str) -> CliTypedResult { }; let full_node_host = config.full_node_host; - let config = ValidatorConfiguration { + Ok(ValidatorConfiguration { account_address, consensus_public_key: consensus_key, account_public_key: account_key, @@ -200,15 +173,26 @@ fn get_config(client: &Client, user: &str) -> CliTypedResult { full_node_network_public_key: full_node_network_key, full_node_host, stake_amount: config.stake_amount, - }; - config.try_into() + }) } -/// Holder object for all pieces needed to generate a genesis transaction -#[derive(Clone)] -pub struct GenesisInfo { - chain_id: ChainId, - root_key: Ed25519PublicKey, - validators: Vec, - modules: Vec>, +/// For better parsing error messages +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct StringValidatorConfiguration { + /// Account address + pub account_address: String, + /// Key used for signing in consensus + pub consensus_public_key: String, + /// Key used for signing transactions with the account + pub account_public_key: String, + /// Public key used for validator network identity (same as account address) + pub validator_network_public_key: String, + /// Host for validator which can be an IP or a DNS name + pub validator_host: HostAndPort, + /// Public key used for full node network identity (same as account address) + pub full_node_network_public_key: Option, + /// Host for full node which can be an IP or a DNS name and is optional + pub full_node_host: Option, + /// Stake amount for consensus + pub stake_amount: u64, } diff --git a/crates/aptos/src/genesis/tests.rs b/crates/aptos/src/genesis/tests.rs index 6b1f0675c053c..5f287827f48a0 100644 --- a/crates/aptos/src/genesis/tests.rs +++ b/crates/aptos/src/genesis/tests.rs @@ -7,7 +7,6 @@ use crate::{ utils::write_to_file, }, genesis::{ - config::{HostAndPort, Layout}, git::{GitOptions, SetupGit}, keys::{GenerateKeys, SetValidatorConfiguration}, GenerateGenesis, @@ -18,11 +17,13 @@ use aptos_crypto::{ ed25519::{Ed25519PrivateKey, Ed25519PublicKey}, PrivateKey, }; +use aptos_genesis::config::{HostAndPort, Layout}; use aptos_keygen::KeyGen; use aptos_temppath::TempPath; use aptos_types::chain_id::ChainId; use move_deps::move_binary_format::access::ModuleAccess; use std::{ + collections::HashMap, path::{Path, PathBuf}, str::FromStr, }; @@ -30,26 +31,31 @@ use std::{ /// Test the E2E genesis flow since it doesn't require a node to run #[tokio::test] async fn test_genesis_e2e_flow() { - let user_a = "user_a".to_string(); - let user_b = "user_b".to_string(); + const NUM_USERS: u8 = 2; let chain_id = ChainId::test(); + let mut users: HashMap = HashMap::new(); + let dir = TempPath::new(); + dir.create_as_dir().unwrap(); + + // Create users + for i in 0..NUM_USERS { + let name = format!("user-{}", i); + let dir = generate_keys(dir.path(), i).await; + users.insert(name, dir); + } + + let names: Vec<_> = users.keys().map(|key| key.to_string()).collect(); - let mut keygen = KeyGen::from_seed([0; 32]); + let mut keygen = KeyGen::from_seed([NUM_USERS.saturating_add(1); 32]); // First step is setup the local git repo let root_private_key = keygen.generate_ed25519_private_key(); - let git_options = setup_git_dir( - &root_private_key, - vec![user_a.clone(), user_b.clone()], - chain_id, - ) - .await; + let git_options = setup_git_dir(&root_private_key, names, chain_id).await; - // Now create the two users - let user_a_dir = generate_keys().await; - add_public_keys(user_a, git_options.clone(), user_a_dir.path()).await; - let user_b_dir = generate_keys().await; - add_public_keys(user_b, git_options.clone(), user_b_dir.path()).await; + // Add keys + for (name, user_dir) in users.iter() { + add_public_keys(name.to_string(), git_options.clone(), user_dir.as_path()).await; + } // Now generate genesis let output_dir = TempPath::new(); @@ -128,6 +134,9 @@ fn create_layout_file( root_key: root_public_key, users, chain_id, + allow_new_validators: false, + initial_lockup_period_duration_secs: 0, + initial_balances: Default::default(), }; let file = TempPath::new(); file.create_as_file().unwrap(); @@ -142,18 +151,16 @@ fn create_layout_file( } /// Generate keys for a "user" -async fn generate_keys() -> TempPath { - let dir = TempPath::new(); - dir.create_as_dir().unwrap(); - let output_dir = PathBuf::from(dir.path()); +async fn generate_keys(dir: &Path, index: u8) -> PathBuf { + let output_dir = dir.join(index.to_string()); let command = GenerateKeys { - rng_args: RngArgs::from_seed([0; 32]), + rng_args: RngArgs::from_seed([index; 32]), prompt_options: PromptOptions::yes(), - output_dir, + output_dir: output_dir.clone(), }; let _ = command.execute().await.unwrap(); - dir + output_dir } /// Set validator configuration for a user diff --git a/crates/aptos/src/test/mod.rs b/crates/aptos/src/test/mod.rs index 04d677f2986c6..668ab2cc744b0 100644 --- a/crates/aptos/src/test/mod.rs +++ b/crates/aptos/src/test/mod.rs @@ -37,7 +37,7 @@ impl CliTestFramework { endpoint, faucet_endpoint, }; - let mut keygen = KeyGen::from_seed([0; 32]); + let mut keygen = KeyGen::from_seed([9; 32]); // TODO: Make this allow a passed in random seed for i in 0..num_accounts { diff --git a/execution/executor-benchmark/Cargo.toml b/execution/executor-benchmark/Cargo.toml index ef4d8f29d721e..6f93b66cf0bd7 100644 --- a/execution/executor-benchmark/Cargo.toml +++ b/execution/executor-benchmark/Cargo.toml @@ -24,7 +24,7 @@ toml = "0.5.9" aptos-config = { path = "../../config" } aptos-crypto = { path = "../../crates/aptos-crypto" } -aptos-genesis-tool = { path = "../../config/management/genesis", features = ["testing"] } +aptos-genesis = { path = "../../crates/aptos-genesis", features = ["testing"] } aptos-infallible = { path = "../../crates/aptos-infallible" } aptos-jellyfish-merkle = { path = "../../storage/jellyfish-merkle" } aptos-logger = { path = "../../crates/aptos-logger" } diff --git a/execution/executor-benchmark/benches/executor_benchmark.rs b/execution/executor-benchmark/benches/executor_benchmark.rs index fd7e3d23af563..d24b60385324b 100644 --- a/execution/executor-benchmark/benches/executor_benchmark.rs +++ b/execution/executor-benchmark/benches/executor_benchmark.rs @@ -21,7 +21,7 @@ pub const INITIAL_BALANCE: u64 = 1000000; // fn executor_benchmark(c: &mut Criterion) { - let (config, genesis_key) = aptos_genesis_tool::test_config(); + let (config, genesis_key) = aptos_genesis::test_utils::test_config(); let (_db, executor) = init_db_and_executor(&config); let parent_block_id = executor.committed_block_id(); diff --git a/execution/executor-benchmark/src/db_generator.rs b/execution/executor-benchmark/src/db_generator.rs index ef1a6abe89fea..58d760a2359d6 100644 --- a/execution/executor-benchmark/src/db_generator.rs +++ b/execution/executor-benchmark/src/db_generator.rs @@ -43,7 +43,7 @@ pub fn run( // create if not exists fs::create_dir_all(db_dir.as_ref()).unwrap(); - let (config, genesis_key) = aptos_genesis_tool::test_config(); + let (config, genesis_key) = aptos_genesis::test_utils::test_config(); // Create executor. let (db, db_rw) = DbReaderWriter::wrap( AptosDB::open( diff --git a/execution/executor-benchmark/src/lib.rs b/execution/executor-benchmark/src/lib.rs index 9dedf4cfc29ff..6d2df58da3b47 100644 --- a/execution/executor-benchmark/src/lib.rs +++ b/execution/executor-benchmark/src/lib.rs @@ -70,7 +70,7 @@ pub fn run_benchmark( .create_checkpoint(checkpoint_dir.as_ref()) .expect("db checkpoint creation fails."); - let (mut config, _genesis_key) = aptos_genesis_tool::test_config(); + let (mut config, _genesis_key) = aptos_genesis::test_utils::test_config(); config.storage.dir = checkpoint_dir.as_ref().to_path_buf(); config.storage.storage_pruner_config = pruner_config; diff --git a/execution/executor-test-helpers/Cargo.toml b/execution/executor-test-helpers/Cargo.toml index eafe933958e71..b2ee31383b767 100644 --- a/execution/executor-test-helpers/Cargo.toml +++ b/execution/executor-test-helpers/Cargo.toml @@ -15,7 +15,7 @@ rand = "0.7.3" aptos-config = { path = "../../config" } aptos-crypto = { path = "../../crates/aptos-crypto" } -aptos-genesis-tool = { path = "../../config/management/genesis", features = ["testing"] } +aptos-genesis = { path = "../../crates/aptos-genesis", features = ["testing"] } aptos-sdk = { path = "../../sdk" } aptos-state-view = { path = "../../storage/state-view" } aptos-temppath = { path = "../../crates/aptos-temppath" } diff --git a/execution/executor-test-helpers/src/lib.rs b/execution/executor-test-helpers/src/lib.rs index c73f7ff47bc47..72550fc62f8cb 100644 --- a/execution/executor-test-helpers/src/lib.rs +++ b/execution/executor-test-helpers/src/lib.rs @@ -39,7 +39,7 @@ pub fn bootstrap_genesis( } pub fn start_storage_service() -> (NodeConfig, JoinHandle<()>, DbReaderWriter) { - let (mut config, _genesis_key) = aptos_genesis_tool::test_config(); + let (mut config, _genesis_key) = aptos_genesis::test_utils::test_config(); let server_port = utils::get_available_port(); config.storage.address = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), server_port); let (db, db_rw) = DbReaderWriter::wrap(AptosDB::new_for_test(&config.storage.dir())); diff --git a/execution/executor/Cargo.toml b/execution/executor/Cargo.toml index d36d8db1b7961..0dd0cd4686b29 100644 --- a/execution/executor/Cargo.toml +++ b/execution/executor/Cargo.toml @@ -38,7 +38,7 @@ proptest = "1.0.0" rand = "0.7.3" aptos-config = { path = "../../config" } -aptos-genesis-tool = { path = "../../config/management/genesis", features = ["testing"] } +aptos-genesis = { path = "../../crates/aptos-genesis", features = ["testing"] } aptos-temppath = { path = "../../crates/aptos-temppath" } aptos-transaction-builder = { path = "../../sdk/transaction-builder" } aptos-types = { path = "../../types", features = ["fuzzing"] } diff --git a/state-sync/state-sync-v1/Cargo.toml b/state-sync/state-sync-v1/Cargo.toml index ed8a18d942f32..6c1dfb80b9963 100644 --- a/state-sync/state-sync-v1/Cargo.toml +++ b/state-sync/state-sync-v1/Cargo.toml @@ -54,7 +54,7 @@ claim = "0.5.0" proptest = "1.0.0" aptos-crypto = { path = "../../crates/aptos-crypto" } -aptos-genesis-tool = { path = "../../config/management/genesis", features = ["testing"] } +aptos-genesis = { path = "../../crates/aptos-genesis", features = ["testing"] } aptos-mempool = { path = "../../mempool", features = ["fuzzing"] } aptos-proptest-helpers = { path = "../../crates/aptos-proptest-helpers" } aptos-time-service = { path = "../../crates/aptos-time-service", features = ["testing"] } diff --git a/state-sync/state-sync-v2/state-sync-multiplexer/Cargo.toml b/state-sync/state-sync-v2/state-sync-multiplexer/Cargo.toml index 8bb8e36cfe662..86ab2e03e773d 100644 --- a/state-sync/state-sync-v2/state-sync-multiplexer/Cargo.toml +++ b/state-sync/state-sync-v2/state-sync-multiplexer/Cargo.toml @@ -29,7 +29,7 @@ storage-interface = { path = "../../../storage/storage-interface" } [dev-dependencies] aptos-crypto = { path = "../../../crates/aptos-crypto" } -aptos-genesis-tool = { path = "../../../config/management/genesis", features = ["testing"] } +aptos-genesis = { path = "../../../crates/aptos-genesis", features = ["testing"] } aptos-infallible = { path = "../../../crates/aptos-infallible" } aptos-temppath = { path = "../../../crates/aptos-temppath" } aptos-time-service = { path = "../../../crates/aptos-time-service", features = ["async", "testing"] } diff --git a/state-sync/state-sync-v2/state-sync-multiplexer/src/lib.rs b/state-sync/state-sync-v2/state-sync-multiplexer/src/lib.rs index edd8765b1c33c..43bf162443c38 100644 --- a/state-sync/state-sync-v2/state-sync-multiplexer/src/lib.rs +++ b/state-sync/state-sync-v2/state-sync-multiplexer/src/lib.rs @@ -170,7 +170,7 @@ mod tests { }; use aptos_crypto::HashValue; use aptos_data_client::aptosnet::AptosNetDataClient; - use aptos_genesis_tool::test_config; + use aptos_genesis::test_utils::test_config; use aptos_infallible::RwLock; use aptos_temppath::TempPath; use aptos_time_service::TimeService; diff --git a/testsuite/forge/Cargo.toml b/testsuite/forge/Cargo.toml index 0e81f9a4a9cfc..ad56c591afc9d 100644 --- a/testsuite/forge/Cargo.toml +++ b/testsuite/forge/Cargo.toml @@ -36,7 +36,7 @@ url = "2.2.2" aptos-config = { path = "../../config" } aptos-faucet = { path = "../../crates/aptos-faucet" } -aptos-genesis-tool = { path = "../../config/management/genesis" } +aptos-genesis = { path = "../../crates/aptos-genesis" } aptos-logger = { path = "../../crates/aptos-logger" } aptos-rest-client = { path = "../../crates/aptos-rest-client" } aptos-retrier = { path = "../../crates/aptos-retrier" } diff --git a/testsuite/forge/src/backend/local/swarm.rs b/testsuite/forge/src/backend/local/swarm.rs index 46e0df8b375bb..204f05267e7bf 100644 --- a/testsuite/forge/src/backend/local/swarm.rs +++ b/testsuite/forge/src/backend/local/swarm.rs @@ -7,7 +7,7 @@ use crate::{ }; use anyhow::{anyhow, bail, Result}; use aptos_config::{config::NodeConfig, keys::ConfigKey}; -use aptos_genesis_tool::{fullnode_builder::FullnodeConfig, validator_builder::ValidatorBuilder}; +use aptos_genesis::builder::FullnodeNodeConfig; use aptos_sdk::{ crypto::ed25519::Ed25519PrivateKey, types::{ @@ -146,15 +146,16 @@ impl LocalSwarmBuilder { self.template.consensus.quorum_store_poll_count = 30; } - let (root_keys, genesis, genesis_waypoint, validators) = ValidatorBuilder::new( - &dir, - self.genesis_modules - .unwrap_or_else(|| cached_framework_packages::module_blobs().to_vec()), - ) - .num_validators(self.number_of_validators) - .template(self.template) - .min_price_per_gas_unit(self.min_price_per_gas_unit) - .build(rng)?; + let (root_key, genesis, genesis_waypoint, validators) = + aptos_genesis::builder::Builder::new( + &dir, + self.genesis_modules + .unwrap_or_else(|| cached_framework_packages::module_blobs().to_vec()), + )? + .with_num_validators(self.number_of_validators) + .with_template(self.template) + .with_min_price_per_gas_unit(self.min_price_per_gas_unit) + .build(rng)?; // Get the initial version to start the nodes with, either the one provided or fallback to // using the the latest version @@ -172,11 +173,11 @@ impl LocalSwarmBuilder { let validators = validators .into_iter() .map(|v| { - let node = LocalNode::new(version.to_owned(), v.name, v.directory)?; + let node = LocalNode::new(version.to_owned(), v.name, v.dir)?; Ok((node.peer_id(), node)) }) .collect::>>()?; - let root_key = ConfigKey::new(root_keys.root_key); + let root_key = ConfigKey::new(root_key); let root_account = LocalAccount::new( aptos_sdk::types::account_config::aptos_root_address(), AccountKey::from_private_key(root_key.private_key()), @@ -295,7 +296,7 @@ impl LocalSwarm { let mut validator_config = validator.config().clone(); let name = self.node_name_counter.to_string(); self.node_name_counter += 1; - let fullnode_config = FullnodeConfig::validator_fullnode( + let fullnode_config = FullnodeNodeConfig::validator_fullnode( name, self.dir.as_ref(), template, @@ -313,7 +314,7 @@ impl LocalSwarm { let mut fullnode = LocalNode::new( version.to_owned(), fullnode_config.name, - fullnode_config.directory, + fullnode_config.dir, )?; let peer_id = fullnode.peer_id(); @@ -328,7 +329,7 @@ impl LocalSwarm { fn add_fullnode(&mut self, version: &Version, template: NodeConfig) -> Result { let name = self.node_name_counter.to_string(); self.node_name_counter += 1; - let fullnode_config = FullnodeConfig::public_fullnode( + let fullnode_config = FullnodeNodeConfig::public_fullnode( name, self.dir.as_ref(), template, @@ -340,7 +341,7 @@ impl LocalSwarm { let mut fullnode = LocalNode::new( version.to_owned(), fullnode_config.name, - fullnode_config.directory, + fullnode_config.dir, )?; let peer_id = fullnode.peer_id(); diff --git a/testsuite/smoke-test/Cargo.toml b/testsuite/smoke-test/Cargo.toml index 0000136f626ee..cea7ec772f4b4 100644 --- a/testsuite/smoke-test/Cargo.toml +++ b/testsuite/smoke-test/Cargo.toml @@ -44,7 +44,7 @@ rand = "0.7.3" regex = "1.5.5" serde_yaml = "0.8.24" -aptos-genesis-tool = { path = "../../config/management/genesis", features = ["testing"] } +aptos-genesis = { path = "../../crates/aptos-genesis", features = ["testing"] } aptos-global-constants = { path = "../../config/global-constants" } aptos-infallible = { path = "../../crates/aptos-infallible" } aptos-logger = { path = "../../crates/aptos-logger" }