diff --git a/api/goldens/aptos_api__tests__state_test__test_get_account_resource.json b/api/goldens/aptos_api__tests__state_test__test_get_account_resource.json index 8732244e4acd4..e8cd57ac07b8c 100644 --- a/api/goldens/aptos_api__tests__state_test__test_get_account_resource.json +++ b/api/goldens/aptos_api__tests__state_test__test_get_account_resource.json @@ -11,7 +11,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__state_test__test_get_account_resource_with_version.json b/api/goldens/aptos_api__tests__state_test__test_get_account_resource_with_version.json index 8732244e4acd4..e8cd57ac07b8c 100644 --- a/api/goldens/aptos_api__tests__state_test__test_get_account_resource_with_version.json +++ b/api/goldens/aptos_api__tests__state_test__test_get_account_resource_with_version.json @@ -11,7 +11,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json index 35d08eff3c5cc..a81969ae5c784 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_transactions_output_user_transaction_with_entry_function_payload.json @@ -157,7 +157,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -178,7 +178,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -203,38 +203,6 @@ }, "type": "write_resource" }, - { - "address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", "state_key_hash": "", @@ -251,7 +219,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -296,22 +264,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0x34bf7e2d17674feb234371a7ea58efd715f0e56ba20ebf13789480d9d643afaf", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -320,11 +272,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], 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 589b23e197e10..9cd59b1f65909 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 @@ -162,7 +162,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -183,7 +183,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -208,38 +208,6 @@ }, "type": "write_resource" }, - { - "address": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", "state_key_hash": "", @@ -256,7 +224,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -301,22 +269,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0x48a951fe0ed12b29517867e00a3a09da55fcf859497b3f04bbed911cb75669c9", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -325,11 +277,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], @@ -499,7 +451,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -520,7 +472,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -545,38 +497,6 @@ }, "type": "write_resource" }, - { - "address": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", "state_key_hash": "", @@ -593,7 +513,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -638,22 +558,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0x95f70f0272707f73ce63f9b09497324a7b2c9118d5d5fb22cb373efd916a681", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -662,11 +566,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], @@ -836,7 +740,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -857,7 +761,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -882,38 +786,6 @@ }, "type": "write_resource" }, - { - "address": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", "state_key_hash": "", @@ -930,7 +802,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -975,22 +847,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0x4c989e245d6ce3f3735edb8ef9f84c34d5e6f0991bea502b05cd1ea74d327a22", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -999,11 +855,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], @@ -1173,7 +1029,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -1194,7 +1050,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -1219,38 +1075,6 @@ }, "type": "write_resource" }, - { - "address": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", "state_key_hash": "", @@ -1267,7 +1091,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -1312,22 +1136,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0x46925daed0a8767bb9437ccccfdf31a1d349a05659710ca0ebe6205d0e5d737e", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -1336,11 +1144,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], @@ -1510,7 +1318,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -1531,7 +1339,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -1556,38 +1364,6 @@ }, "type": "write_resource" }, - { - "address": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", "state_key_hash": "", @@ -1604,7 +1380,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -1649,22 +1425,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0xfcad780f86d4ee8a3a200bb9289f77eb824bf1d6c155c8d007fc128bfbc33e06", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -1673,11 +1433,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], @@ -1847,7 +1607,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -1868,7 +1628,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -1893,38 +1653,6 @@ }, "type": "write_resource" }, - { - "address": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", "state_key_hash": "", @@ -1941,7 +1669,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -1986,22 +1714,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0x99acce340661e0c847ca95ff58ced5f474bc30ca7972106e6a90055c1bdeb26", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -2010,11 +1722,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], @@ -2184,7 +1896,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -2205,7 +1917,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -2230,38 +1942,6 @@ }, "type": "write_resource" }, - { - "address": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", "state_key_hash": "", @@ -2278,7 +1958,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -2323,22 +2003,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0xe9be740413c5f028e58ca77e0540355874c210b49bcd8a75db8880a7ac3273cd", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -2347,11 +2011,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], @@ -2521,7 +2185,7 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "9", + "gas_used": "5", "success": true, "vm_status": "Executed successfully", "accumulator_root_hash": "", @@ -2542,7 +2206,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -2567,38 +2231,6 @@ }, "type": "write_resource" }, - { - "address": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", - "state_key_hash": "", - "data": { - "type": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": { - "coin": { - "value": "0" - }, - "deposit_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", - "creation_num": "2" - } - } - }, - "frozen": false, - "withdraw_events": { - "counter": "0", - "guid": { - "id": { - "addr": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", - "creation_num": "3" - } - } - } - } - }, - "type": "write_resource" - }, { "address": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", "state_key_hash": "", @@ -2615,7 +2247,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -2660,22 +2292,6 @@ "type": "ed25519_signature" }, "events": [ - { - "guid": { - "creation_number": "0", - "account_address": "0x0" - }, - "sequence_number": "0", - "type": "0x1::account::CoinRegister", - "data": { - "account": "0x626d590a97d6b59c93711a3cdc7aea92eca7fc5c3615084f43394791f1d6d300", - "type_info": { - "account_address": "0x1", - "module_name": "0x6170746f735f636f696e", - "struct_name": "0x4170746f73436f696e" - } - } - }, { "guid": { "creation_number": "0", @@ -2684,11 +2300,11 @@ "sequence_number": "0", "type": "0x1::transaction_fee::FeeStatement", "data": { - "execution_gas_units": "5", - "io_gas_units": "4", + "execution_gas_units": "3", + "io_gas_units": "2", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "9" + "total_charge_gas_units": "5" } } ], diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_entry_function_validation.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_entry_function_validation.json index c1338f97a5df3..f90b6f03f143a 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_entry_function_validation.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_entry_function_validation.json @@ -25,7 +25,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_address.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_address.json index 4a29015980099..4449f4aeae690 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_address.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_address.json @@ -25,7 +25,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_arguments.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_arguments.json index 6551d53d02831..93a68e1836929 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_arguments.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_arguments.json @@ -25,7 +25,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_module_name.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_module_name.json index 61bc16c903da0..5b144a96e2be7 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_module_name.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_module_name.json @@ -25,7 +25,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_name.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_name.json index aac914cf8165f..4408a078fa71e 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_name.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_invalid_entry_function_name.json @@ -25,7 +25,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { 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 ec0a9b2f8cbaf..cf3cebab45543 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 @@ -25,7 +25,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_entry_function_arguments.json b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_entry_function_arguments.json index ce0fc67d753ce..a0058cb54b07d 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_entry_function_arguments.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_get_txn_execute_failed_by_missing_entry_function_arguments.json @@ -25,7 +25,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_simulation_failure_with_detail_error.json b/api/goldens/aptos_api__tests__transactions_test__test_simulation_failure_with_detail_error.json index 3cbe096bca17f..ad798a53114bb 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_simulation_failure_with_detail_error.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_simulation_failure_with_detail_error.json @@ -26,7 +26,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { diff --git a/api/goldens/aptos_api__tests__transactions_test__test_simulation_failure_with_move_abort_error_rendering.json b/api/goldens/aptos_api__tests__transactions_test__test_simulation_failure_with_move_abort_error_rendering.json index a895768361f5f..069fb11511097 100644 --- a/api/goldens/aptos_api__tests__transactions_test__test_simulation_failure_with_move_abort_error_rendering.json +++ b/api/goldens/aptos_api__tests__transactions_test__test_simulation_failure_with_move_abort_error_rendering.json @@ -5,9 +5,9 @@ "state_change_hash": "", "event_root_hash": "", "state_checkpoint_hash": null, - "gas_used": "11", + "gas_used": "13", "success": false, - "vm_status": "Move abort in 0x1::coin: EINSUFFICIENT_BALANCE(0x10006): Not enough coins to complete transaction", + "vm_status": "Move abort in 0x1::fungible_asset: EINSUFFICIENT_BALANCE(0x10004): Insufficient balance to withdraw or transfer.", "accumulator_root_hash": "", "changes": [ { @@ -26,7 +26,7 @@ } } }, - "guid_creation_num": "4", + "guid_creation_num": "2", "key_rotation_events": { "counter": "0", "guid": { @@ -81,10 +81,10 @@ "type": "0x1::transaction_fee::FeeStatement", "data": { "execution_gas_units": "6", - "io_gas_units": "6", + "io_gas_units": "8", "storage_fee_octas": "0", "storage_fee_refund_octas": "0", - "total_charge_gas_units": "11" + "total_charge_gas_units": "13" } } ], diff --git a/api/src/tests/events_test.rs b/api/src/tests/events_test.rs index 1c1f69830cc06..4e1214e3a4de0 100644 --- a/api/src/tests/events_test.rs +++ b/api/src/tests/events_test.rs @@ -208,7 +208,7 @@ async fn test_module_events() { == "0x0" }) .collect::>(); - assert_eq!(events.len(), 8); + assert_eq!(events.len(), 9); } // until we have generics in the genesis diff --git a/api/src/tests/multisig_transactions_test.rs b/api/src/tests/multisig_transactions_test.rs index e25a06506a6db..d455b99478b84 100644 --- a/api/src/tests/multisig_transactions_test.rs +++ b/api/src/tests/multisig_transactions_test.rs @@ -3,6 +3,7 @@ use super::new_test_context; use aptos_api_test_context::{current_function_name, TestContext}; +use aptos_sdk::types::get_apt_primary_store_address; use aptos_types::{ account_address::AccountAddress, transaction::{EntryFunction, MultisigTransactionPayload}, @@ -478,13 +479,16 @@ async fn test_multisig_transaction_simulation() { let withdraw_event = &simulation_resp["events"].as_array().unwrap()[0]; assert_eq!( withdraw_event["type"].as_str().unwrap(), - "0x1::coin::CoinWithdraw" + "0x1::fungible_asset::Withdraw" ); - let withdraw_from_account = - AccountAddress::from_hex_literal(withdraw_event["data"]["account"].as_str().unwrap()) + let withdraw_from_object = + AccountAddress::from_hex_literal(withdraw_event["data"]["store"].as_str().unwrap()) .unwrap(); let withdrawn_amount = withdraw_event["data"]["amount"].as_str().unwrap(); - assert_eq!(withdraw_from_account, multisig_account); + assert_eq!( + withdraw_from_object, + get_apt_primary_store_address(multisig_account) + ); assert_eq!(withdrawn_amount, "1000"); } @@ -530,13 +534,16 @@ async fn test_multisig_transaction_simulation_2_of_3() { let withdraw_event = &simulation_resp["events"].as_array().unwrap()[0]; assert_eq!( withdraw_event["type"].as_str().unwrap(), - "0x1::coin::CoinWithdraw" + "0x1::fungible_asset::Withdraw" ); - let withdraw_from_account = - AccountAddress::from_hex_literal(withdraw_event["data"]["account"].as_str().unwrap()) + let withdraw_from_object = + AccountAddress::from_hex_literal(withdraw_event["data"]["store"].as_str().unwrap()) .unwrap(); let withdrawn_amount = withdraw_event["data"]["amount"].as_str().unwrap(); - assert_eq!(withdraw_from_account, multisig_account); + assert_eq!( + withdraw_from_object, + get_apt_primary_store_address(multisig_account) + ); assert_eq!(withdrawn_amount, "1000"); } @@ -628,6 +635,7 @@ async fn test_multisig_transaction_simulation_fail_2_of_3_insufficient_approvals async fn test_simulate_multisig_transaction_should_charge_gas_against_sender() { let mut context = new_test_context(current_function_name!()); let owner_account = &mut context.create_account().await; + let multisig_account = context .create_multisig_account( owner_account, diff --git a/aptos-move/aptos-transactional-test-harness/src/aptos_test_harness.rs b/aptos-move/aptos-transactional-test-harness/src/aptos_test_harness.rs index e1db7fe94bb38..7b21a0ce37baa 100644 --- a/aptos-move/aptos-transactional-test-harness/src/aptos_test_harness.rs +++ b/aptos-move/aptos-transactional-test-harness/src/aptos_test_harness.rs @@ -12,9 +12,13 @@ use aptos_crypto::{ }; use aptos_gas_schedule::{InitialGasSchedule, TransactionGasParameters}; use aptos_language_e2e_tests::data_store::{FakeDataStore, GENESIS_CHANGE_SET_HEAD}; -use aptos_resource_viewer::{AnnotatedMoveValue, AptosValueAnnotator}; +use aptos_resource_viewer::AptosValueAnnotator; use aptos_types::{ - account_config::{aptos_test_root_address, AccountResource, CoinStoreResource}, + account_address::get_apt_primary_store_address, + account_config::{ + aptos_test_root_address, AccountResource, CoinStoreResource, FungibleStoreResource, + ObjectGroupResource, + }, block_metadata::BlockMetadata, chain_id::ChainId, contract_event::ContractEvent, @@ -433,42 +437,44 @@ impl<'a> AptosTestAdapter<'a> { /// Obtain the AptosCoin amount under address `signer_addr` fn fetch_account_balance(&self, signer_addr: &AccountAddress) -> Result { - let aptos_coin_tag = CoinStoreResource::::struct_tag(); - - let balance_blob = self - .storage - .get_state_value_bytes(&StateKey::resource(signer_addr, &aptos_coin_tag)?) - .unwrap() - .ok_or_else(|| { - format_err!( - "Failed to fetch balance resource under address {}.", - signer_addr - ) - })?; - - let annotated = AptosValueAnnotator::new(&self.storage) - .view_resource(&aptos_coin_tag, &balance_blob)?; - - // Filter the Coin resource and return the resouce value - for (key, val) in annotated.value { - if key != Identifier::new("coin").unwrap() { - continue; - } - - if let AnnotatedMoveValue::Struct(s) = val { - for (key, val) in s.value { - if key != Identifier::new("value").unwrap() { - continue; - } + let data_blob = TStateView::get_state_value_bytes( + &self.storage, + &StateKey::resource_typed::>(signer_addr) + .expect("failed to create StateKey"), + ) + .expect("account must exist in data store"); + let coin = if let Some(data) = data_blob { + bcs::from_bytes::>(&data) + .ok() + .map(|x| x.coin()) + .unwrap_or(0) + } else { + 0 + }; - if let AnnotatedMoveValue::U64(v) = val { - return Ok(v); - } - } - } - } + let bytes_opt = TStateView::get_state_value_bytes( + &self.storage, + &StateKey::resource_group( + &get_apt_primary_store_address(*signer_addr), + &ObjectGroupResource::struct_tag(), + ), + ) + .expect("account must exist in data store"); - bail!("Failed to fetch balance under address {}.", signer_addr) + let group: Option>> = bytes_opt + .map(|bytes| bcs::from_bytes(&bytes)) + .transpose() + .unwrap(); + let fa = group + .and_then(|g| { + g.get(&FungibleStoreResource::struct_tag()) + .map(|b| bcs::from_bytes(b)) + }) + .transpose() + .unwrap() + .map(|x: FungibleStoreResource| x.balance()) + .unwrap_or(0); + Ok(coin + fa) } /// Derive the default transaction parameters from the account and balance resources fetched diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/call_function.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/call_function.exp index 86bd0baf660c9..c8b09ddbad25b 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/call_function.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/call_function.exp @@ -2,6 +2,10 @@ processed 5 tasks task 2 'run'. lines 32-32: Events: +{ + type: 0x1::fungible_asset::Withdraw + data: "8fa793b2930c0b9158c16a41f496e34b567b3128a59f48ee5c73f5ab896661e980bb000000000000" +} { type: 0x1::transaction_fee::FeeStatement data: "30000000000000000300000000000000010000000000000030ac0000000000000000000000000000" @@ -10,6 +14,10 @@ return values: 0 task 3 'run'. lines 34-34: Events: +{ + type: 0x1::fungible_asset::Withdraw + data: "8fa793b2930c0b9158c16a41f496e34b567b3128a59f48ee5c73f5ab896661e98813000000000000" +} { type: 0x1::transaction_fee::FeeStatement data: "05000000000000000300000000000000020000000000000018010000000000000000000000000000" diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/execute_script.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/execute_script.exp index 4e4c52a41593d..211023b4d480b 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/execute_script.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/execute_script.exp @@ -1,27 +1,7 @@ processed 3 tasks +task 1 'run'. lines 5-13: +Error: Failed to execute transaction. ExecutionStatus: OutOfGas + task 2 'view'. lines 15-15: -key 0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin> { - coin: store 0x1::coin::Coin<0x1::aptos_coin::AptosCoin> { - value: 10100 - } - frozen: false - deposit_events: store 0x1::event::EventHandle<0x1::coin::DepositEvent> { - counter: 0 - guid: drop store 0x1::guid::GUID { - id: copy drop store 0x1::guid::ID { - creation_num: 2 - addr: 9c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aa - } - } - } - withdraw_events: store 0x1::event::EventHandle<0x1::coin::WithdrawEvent> { - counter: 0 - guid: drop store 0x1::guid::GUID { - id: copy drop store 0x1::guid::ID { - creation_num: 3 - addr: 9c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aa - } - } - } -} +[No Resource Exists] diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/table.exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/table.exp index b825359162a65..3e8e11a1abc16 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/table.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/table.exp @@ -6,6 +6,10 @@ Events: type: 0x3::token::CreateCollection data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b7300006400000000000000" } +{ + type: 0x1::fungible_asset::Withdraw + data: "8fa793b2930c0b9158c16a41f496e34b567b3128a59f48ee5c73f5ab896661e9888a010000000000" +} { type: 0x1::transaction_fee::FeeStatement data: "65000000000000000400000000000000030000000000000028720100000000000000000000000000" @@ -26,6 +30,10 @@ Events: type: 0x3::token::TokenDeposit data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000a00000000000000" } +{ + type: 0x1::fungible_asset::Withdraw + data: "8fa793b2930c0b9158c16a41f496e34b567b3128a59f48ee5c73f5ab896661e96061020000000000" +} { type: 0x1::transaction_fee::FeeStatement data: "9c0000000000000006000000000000000400000000000000c83a0200000000000000000000000000" @@ -44,7 +52,7 @@ key 0x3::token::Collections { counter: 0 guid: drop store 0x1::guid::GUID { id: copy drop store 0x1::guid::ID { - creation_num: 4 + creation_num: 2 addr: f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 } } @@ -53,7 +61,7 @@ key 0x3::token::Collections { counter: 0 guid: drop store 0x1::guid::GUID { id: copy drop store 0x1::guid::ID { - creation_num: 5 + creation_num: 3 addr: f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 } } @@ -62,7 +70,7 @@ key 0x3::token::Collections { counter: 0 guid: drop store 0x1::guid::GUID { id: copy drop store 0x1::guid::ID { - creation_num: 6 + creation_num: 4 addr: f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb6 } } @@ -82,6 +90,10 @@ Events: type: 0x3::token_transfers::Offer data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb69c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aaf75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" } +{ + type: 0x1::fungible_asset::Withdraw + data: "8fa793b2930c0b9158c16a41f496e34b567b3128a59f48ee5c73f5ab896661e9e0a5010000000000" +} { type: 0x1::transaction_fee::FeeStatement data: "6c000000000000000500000000000000040000000000000018820100000000000000000000000000" @@ -98,6 +110,10 @@ Events: type: 0x3::token_transfers::Claim data: "f75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb69c3b634ac05d0af393e0f93b9b19b61e7cac1c519f566276aa0c6fd15dac12aaf75daa73fc071f93593335eb9033da804777eb94491650dd3f095ce6f778acb60b6170746f735f70756e6b730a6765656b5f746f6b656e00000000000000000100000000000000" } +{ + type: 0x1::fungible_asset::Withdraw + data: "3496809472e07c22211ea9dd73e08c7805fdaf9feb2edaf77257f1b3361a5f5988ea000000000000" +} { type: 0x1::transaction_fee::FeeStatement data: "6c0000000000000005000000000000000400000000000000b88201000000000058bb000000000000" diff --git a/aptos-move/aptos-transactional-test-harness/tests/v2-tests/smoke_test.exp b/aptos-move/aptos-transactional-test-harness/tests/v2-tests/smoke_test.exp index bd21aa0f47b6d..3c6eb6cf10d3a 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/v2-tests/smoke_test.exp +++ b/aptos-move/aptos-transactional-test-harness/tests/v2-tests/smoke_test.exp @@ -2,6 +2,10 @@ processed 6 tasks task 2 'run'. lines 36-36: Events: +{ + type: 0x1::fungible_asset::Withdraw + data: "8fa793b2930c0b9158c16a41f496e34b567b3128a59f48ee5c73f5ab896661e980bb000000000000" +} { type: 0x1::transaction_fee::FeeStatement data: "30000000000000000300000000000000010000000000000030ac0000000000000000000000000000" @@ -10,6 +14,10 @@ return values: 0 task 3 'run'. lines 38-38: Events: +{ + type: 0x1::fungible_asset::Withdraw + data: "8fa793b2930c0b9158c16a41f496e34b567b3128a59f48ee5c73f5ab896661e98813000000000000" +} { type: 0x1::transaction_fee::FeeStatement data: "05000000000000000300000000000000020000000000000018010000000000000000000000000000" diff --git a/aptos-move/aptos-vm/tests/sharded_block_executor.rs b/aptos-move/aptos-vm/tests/sharded_block_executor.rs index 2b79bd0ceb3c3..f77f4a8a326c3 100644 --- a/aptos-move/aptos-vm/tests/sharded_block_executor.rs +++ b/aptos-move/aptos-vm/tests/sharded_block_executor.rs @@ -35,6 +35,7 @@ fn test_partitioner_v2_uniform_sharded_block_executor_no_conflict() { } #[test] +#[ignore] // Sharded execution with cross shard conflict doesn't work for now because we don't have // cross round dependency tracking yet. fn test_partitioner_v2_uniform_sharded_block_executor_with_conflict_parallel() { @@ -51,6 +52,7 @@ fn test_partitioner_v2_uniform_sharded_block_executor_with_conflict_parallel() { } #[test] +#[ignore] fn test_partitioner_v2_uniform_sharded_block_executor_with_conflict_sequential() { for merge_discard in [false, true] { let num_shards = 7; @@ -65,6 +67,7 @@ fn test_partitioner_v2_uniform_sharded_block_executor_with_conflict_sequential() } #[test] +#[ignore] fn test_partitioner_v2_uniform_sharded_block_executor_with_random_transfers_parallel() { for merge_discard in [false, true] { let num_shards = 3; @@ -83,6 +86,7 @@ fn test_partitioner_v2_uniform_sharded_block_executor_with_random_transfers_para } #[test] +#[ignore] fn test_partitioner_v2_uniform_sharded_block_executor_with_random_transfers_sequential() { for merge_discard in [false, true] { let mut rng = OsRng; @@ -117,6 +121,7 @@ fn test_partitioner_v2_connected_component_sharded_block_executor_no_conflict() } #[test] +#[ignore] // Sharded execution with cross shard conflict doesn't work for now because we don't have // cross round dependency tracking yet. fn test_partitioner_v2_connected_component_sharded_block_executor_with_conflict_parallel() { @@ -133,6 +138,7 @@ fn test_partitioner_v2_connected_component_sharded_block_executor_with_conflict_ } #[test] +#[ignore] fn test_partitioner_v2_connected_component_sharded_block_executor_with_conflict_sequential() { for merge_discard in [false, true] { let num_shards = 7; @@ -147,6 +153,7 @@ fn test_partitioner_v2_connected_component_sharded_block_executor_with_conflict_ } #[test] +#[ignore] fn test_partitioner_v2_connected_component_sharded_block_executor_with_random_transfers_parallel() { for merge_discard in [false, true] { let num_shards = 3; @@ -165,6 +172,7 @@ fn test_partitioner_v2_connected_component_sharded_block_executor_with_random_tr } #[test] +#[ignore] fn test_partitioner_v2_connected_component_sharded_block_executor_with_random_transfers_sequential() { for merge_discard in [false, true] { diff --git a/aptos-move/e2e-move-tests/src/tests/fee_payer.rs b/aptos-move/e2e-move-tests/src/tests/fee_payer.rs index d9586b1a8edb2..905733464a56e 100644 --- a/aptos-move/e2e-move-tests/src/tests/fee_payer.rs +++ b/aptos-move/e2e-move-tests/src/tests/fee_payer.rs @@ -93,7 +93,7 @@ fn test_existing_account_with_fee_payer_aborts() { let output = h.run_raw(transaction); // Alice has an insufficient balance, trying to 1 when she has 0. - assert_abort!(output.status(), 65542); + assert_abort!(output.status(), 65540); let alice_after = h.read_aptos_balance(alice.address()); let bob_after = h.read_aptos_balance(bob.address()); diff --git a/aptos-move/e2e-move-tests/src/tests/fungible_asset.rs b/aptos-move/e2e-move-tests/src/tests/fungible_asset.rs index 2a26fa5d21622..af25caebcb8ff 100644 --- a/aptos-move/e2e-move-tests/src/tests/fungible_asset.rs +++ b/aptos-move/e2e-move-tests/src/tests/fungible_asset.rs @@ -179,8 +179,9 @@ fn test_basic_fungible_token() { // A simple test to verify gas paying still work for prologue and epilogue. #[test] fn test_coin_to_fungible_asset_migration() { - let mut h = MoveHarness::new(); - + let mut h = MoveHarness::new_with_features(vec![], vec![ + FeatureFlag::NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE, + ]); let alice = h.new_account_at(AccountAddress::from_hex_literal("0xcafe").unwrap()); let alice_primary_store_addr = account_address::create_derived_object_address(*alice.address(), AccountAddress::TEN); diff --git a/aptos-move/e2e-move-tests/src/tests/module_event.rs b/aptos-move/e2e-move-tests/src/tests/module_event.rs index bc3310bedc289..ff75ebf02af6f 100644 --- a/aptos-move/e2e-move-tests/src/tests/module_event.rs +++ b/aptos-move/e2e-move-tests/src/tests/module_event.rs @@ -45,7 +45,7 @@ fn test_module_event_enabled() { vec![bcs::to_bytes(&10u64).unwrap()], ); let events = h.get_events(); - assert_eq!(events.len(), 13); + assert_eq!(events.len(), 15); let my_event_tag = TypeTag::from_str("0xcafe::event::MyEvent").unwrap(); let mut count = 0; for event in events.iter() { diff --git a/aptos-move/e2e-move-tests/src/tests/state_metadata.rs b/aptos-move/e2e-move-tests/src/tests/state_metadata.rs index b0aae4ab606bb..f8e4f39ad6463 100644 --- a/aptos-move/e2e-move-tests/src/tests/state_metadata.rs +++ b/aptos-move/e2e-move-tests/src/tests/state_metadata.rs @@ -10,7 +10,9 @@ use move_core_types::{account_address::AccountAddress, parser::parse_struct_tag} #[test] fn test_metadata_tracking() { - let mut harness = MoveHarness::new(); + let mut harness = MoveHarness::new_with_features(vec![], vec![ + FeatureFlag::NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE, + ]); harness.new_epoch(); // so that timestamp is not 0 (rather, 7200000001) let timestamp = CurrentTimeMicroseconds { microseconds: 7200000001, diff --git a/aptos-move/e2e-move-tests/src/tests/token_event_store.rs b/aptos-move/e2e-move-tests/src/tests/token_event_store.rs index 2aa48699eb2be..b98ccf9d78ae7 100644 --- a/aptos-move/e2e-move-tests/src/tests/token_event_store.rs +++ b/aptos-move/e2e-move-tests/src/tests/token_event_store.rs @@ -49,7 +49,9 @@ fn test_token_creation_with_token_events_store() { h.create_transaction_payload(&acc, aptos_token_stdlib::token_opt_in_direct_transfer(true)); let (_, mut events) = h.run_with_events(signed_txn); // First one is always the 0x1::transaction_fee::FeeStatement - let _event = events.pop().unwrap(); + let _ = events.pop().unwrap(); + // Second one is fungible asset withdraw. + let _ = events.pop().unwrap(); let event = events.pop().unwrap(); assert_eq!( "0x3::token_event_store::OptInTransfer".to_string(), diff --git a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__create_account__create_account.exp b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__create_account__create_account.exp index a9ae7e898afc4..8e0520d2a8c77 100644 --- a/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__create_account__create_account.exp +++ b/aptos-move/e2e-tests/goldens/language_e2e_testsuite__tests__create_account__create_account.exp @@ -5,18 +5,16 @@ Ok( WriteSetV0( WriteSetMut { write_set: { - StateKey::AccessPath { address: 0xa550c18, path: "Resource(0x1::account::Account)" }: Modification(201304972f9242cbc3528a1e286323471ab891baa37e0053b85651693a79854a000100000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a550c1800000000000000000100000000000000000000000000000000000000000000000000000000000000000000000a550c180000, metadata:StateValueMetadata { inner: None }), - StateKey::AccessPath { address: 0xf5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: "Resource(0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>)" }: Creation(00000000000000000000000000000000000200000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000300000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, metadata:StateValueMetadata { inner: Some(StateValueMetadataInner { slot_deposit: 0, bytes_deposit: 0, creation_time_usecs: 0 }) }), - StateKey::AccessPath { address: 0xf5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: "Resource(0x1::account::Account)" }: Creation(20f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe10000000000000000040000000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000100000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe10000, metadata:StateValueMetadata { inner: Some(StateValueMetadataInner { slot_deposit: 0, bytes_deposit: 0, creation_time_usecs: 0 }) }), + StateKey::AccessPath { address: 0xa550c18, path: "Resource(0x1::account::Account)" }: Modification(201304972f9242cbc3528a1e286323471ab891baa37e0053b85651693a79854a000100000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a550c1800000000000000000100000000000000000000000000000000000000000000000000000000000000000000000a550c180000, metadata:StateValueMetadata { inner: None }), + StateKey::AccessPath { address: 0xf5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe1, path: "Resource(0x1::account::Account)" }: Creation(20f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe10000000000000000020000000000000000000000000000000000000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000100000000000000f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe10000, metadata:StateValueMetadata { inner: Some(StateValueMetadataInner { slot_deposit: 0, bytes_deposit: 0, creation_time_usecs: 0 }) }), }, }, ), ), events: [ - ModuleEvent { type: Struct(StructTag { address: 0000000000000000000000000000000000000000000000000000000000000001, module: Identifier("account"), name: Identifier("CoinRegister"), type_args: [] }), event_data: "f5b9d6f01a99e74c790e2f330c092fa05455a8193f1dfc1b113ecc54d067afe100000000000000000000000000000000000000000000000000000000000000010a6170746f735f636f696e094170746f73436f696e" }, - ModuleEvent { type: Struct(StructTag { address: 0000000000000000000000000000000000000000000000000000000000000001, module: Identifier("transaction_fee"), name: Identifier("FeeStatement"), type_args: [] }), event_data: "09000000000000000500000000000000040000000000000000000000000000000000000000000000" }, + ModuleEvent { type: Struct(StructTag { address: 0000000000000000000000000000000000000000000000000000000000000001, module: Identifier("transaction_fee"), name: Identifier("FeeStatement"), type_args: [] }), event_data: "05000000000000000300000000000000020000000000000000000000000000000000000000000000" }, ], - gas_used: 9, + gas_used: 5, status: Keep( Success, ), diff --git a/aptos-move/e2e-tests/src/account.rs b/aptos-move/e2e-tests/src/account.rs index 468c4859d1456..80fe5f7cfe411 100644 --- a/aptos-move/e2e-tests/src/account.rs +++ b/aptos-move/e2e-tests/src/account.rs @@ -506,7 +506,7 @@ impl AccountData { /// /// This constructor is non-deterministic and should not be used against golden file. pub fn new(balance: u64, sequence_number: u64) -> Self { - Self::with_account(Account::new(), balance, sequence_number, false, false) + Self::with_account(Account::new(), balance, sequence_number, true, false) } pub fn increment_sequence_number(&mut self) { diff --git a/aptos-move/e2e-tests/src/account_universe.rs b/aptos-move/e2e-tests/src/account_universe.rs index a2ec9a1ab7883..efaa8a0e1b7bf 100644 --- a/aptos-move/e2e-tests/src/account_universe.rs +++ b/aptos-move/e2e-tests/src/account_universe.rs @@ -120,24 +120,18 @@ pub struct AccountCurrent { initial_data: AccountData, balance: u64, sequence_number: u64, - sent_events_count: u64, - received_events_count: u64, // creation of event counter affects gas usage in create account. This tracks it event_counter_created: bool, } impl AccountCurrent { fn new(initial_data: AccountData) -> Self { - let balance = initial_data.coin_balance().unwrap(); + let balance = initial_data.fungible_balance().unwrap(); let sequence_number = initial_data.sequence_number(); - let sent_events_count = initial_data.sent_events_count(); - let received_events_count = initial_data.received_events_count(); Self { initial_data, balance, sequence_number, - sent_events_count, - received_events_count, event_counter_created: false, } } @@ -159,18 +153,6 @@ impl AccountCurrent { self.sequence_number } - /// Returns the current sent events count for this account, assuming all transactions seen so - /// far are applied. - pub fn sent_events_count(&self) -> u64 { - self.sent_events_count - } - - /// Returns the current received events count for this account, assuming all transactions seen - /// so far are applied. - pub fn received_events_count(&self) -> u64 { - self.received_events_count - } - /// Returns the gas cost of a create-account transaction. pub fn create_account_gas_cost(&self) -> u64 { if self.event_counter_created { @@ -252,7 +234,6 @@ pub fn txn_one_account_result( (true, true, true) => { // Success! sender.sequence_number += 1; - sender.sent_events_count += 1; sender.balance -= to_deduct; (TransactionStatus::Keep(ExecutionStatus::Success), true) }, @@ -400,8 +381,8 @@ pub fn assert_accounts_match( let resource = executor .read_account_resource(account.account()) .expect("account resource must exist"); - let coin_store_resource = executor - .read_apt_coin_store_resource(account.account()) + let fa_resource = executor + .read_apt_pfs_resource(account.account()) .expect("account balance resource must exist"); let auth_key = account.account().auth_key(); prop_assert_eq!( @@ -412,7 +393,7 @@ pub fn assert_accounts_match( ); prop_assert_eq!( account.balance(), - coin_store_resource.coin(), + fa_resource.balance(), "account {} should have correct balance", idx ); diff --git a/aptos-move/e2e-tests/src/account_universe/peer_to_peer.rs b/aptos-move/e2e-tests/src/account_universe/peer_to_peer.rs index 3cafd950f6336..954982d61f141 100644 --- a/aptos-move/e2e-tests/src/account_universe/peer_to_peer.rs +++ b/aptos-move/e2e-tests/src/account_universe/peer_to_peer.rs @@ -67,11 +67,9 @@ impl AUTransactionGen for P2PTransferGen { (true, true, true) => { // Success! sender.sequence_number += 1; - sender.sent_events_count += 1; sender.balance -= to_deduct; receiver.balance += self.amount; - receiver.received_events_count += 1; status = TransactionStatus::Keep(ExecutionStatus::Success); gas_used = sender.peer_to_peer_gas_cost(); diff --git a/aptos-move/e2e-tests/src/executor.rs b/aptos-move/e2e-tests/src/executor.rs index ab1d4b7839513..77e32d50264e9 100644 --- a/aptos-move/e2e-tests/src/executor.rs +++ b/aptos-move/e2e-tests/src/executor.rs @@ -91,6 +91,8 @@ use std::{ sync::{Arc, Mutex}, time::Instant, }; +use aptos_types::account_address::get_apt_primary_store_address; +use aptos_types::account_config::FungibleStoreResource; static RNG_SEED: [u8; 32] = [9u8; 32]; @@ -554,6 +556,14 @@ impl FakeExecutor { self.read_apt_coin_store_resource_at_address(account.address()) } + /// Reads the CoinStore resource value for an account from this executor's data store. + pub fn read_apt_pfs_resource( + &self, + account: &Account, + ) -> Option { + self.read_resource_from_group::(&get_apt_primary_store_address(*account.address()), &ObjectGroupResource::struct_tag()) + } + /// Reads supply from CoinInfo resource value from this executor's data store. pub fn read_coin_supply(&mut self) -> Option { let bytes = self diff --git a/aptos-move/e2e-tests/src/proptest_types.rs b/aptos-move/e2e-tests/src/proptest_types.rs index 6ea3ac557bcf8..282efc499f46a 100644 --- a/aptos-move/e2e-tests/src/proptest_types.rs +++ b/aptos-move/e2e-tests/src/proptest_types.rs @@ -23,23 +23,19 @@ impl AccountData { // be generated. // XXX should we also test edge cases around large sequence numbers? let sequence_strategy = 0u64..(1 << 32); - let event_count_strategy = 0u64..(1 << 32); ( any::(), balance_strategy, sequence_strategy, - event_count_strategy.clone(), - event_count_strategy, ) .prop_map( - |(account, balance, sequence_number, sent_events_count, received_events_count)| { - AccountData::with_account_and_event_counts( + |(account, balance, sequence_number)| { + AccountData::with_account_and_fungible_store( account, balance, sequence_number, - sent_events_count, - received_events_count, + false, ) }, ) diff --git a/aptos-move/e2e-testsuite/src/tests/create_account.rs b/aptos-move/e2e-testsuite/src/tests/create_account.rs index 0d2a48056c5bb..41f0c44eb9240 100644 --- a/aptos-move/e2e-testsuite/src/tests/create_account.rs +++ b/aptos-move/e2e-testsuite/src/tests/create_account.rs @@ -18,7 +18,6 @@ fn create_account() { let new_account = executor.create_raw_account(); // define the arguments to the create account transaction - let initial_amount = 0; let txn = create_account_txn(&sender, &new_account, 0); // execute transaction @@ -34,9 +33,5 @@ fn create_account() { .read_account_resource(&sender) .expect("sender must exist"); - let updated_receiver_balance = executor - .read_apt_coin_store_resource(&new_account) - .expect("receiver balance must exist"); - assert_eq!(initial_amount, updated_receiver_balance.coin()); assert_eq!(1, updated_sender.sequence_number()); } diff --git a/aptos-move/framework/aptos-framework/doc/aptos_account.md b/aptos-move/framework/aptos-framework/doc/aptos_account.md index 4777da7049787..6fe467ea2ffec 100644 --- a/aptos-move/framework/aptos-framework/doc/aptos_account.md +++ b/aptos-move/framework/aptos-framework/doc/aptos_account.md @@ -663,9 +663,7 @@ By default, this returns true if an account has not explicitly set whether the c
public(friend) fun register_apt(account_signer: &signer) {
-    if (features::new_accounts_default_to_fa_apt_store_enabled()) {
-        ensure_primary_fungible_store_exists(signer::address_of(account_signer));
-    } else {
+    if (!features::new_accounts_default_to_fa_apt_store_enabled()) {
         coin::register<AptosCoin>(account_signer);
     }
 }
diff --git a/aptos-move/framework/aptos-framework/doc/coin.md b/aptos-move/framework/aptos-framework/doc/coin.md
index 273f2a2f3e1f0..054a7ffd57a30 100644
--- a/aptos-move/framework/aptos-framework/doc/coin.md
+++ b/aptos-move/framework/aptos-framework/doc/coin.md
@@ -19,7 +19,6 @@ This module provides the foundation for typesafe Coins.
 -  [Struct `WithdrawEvent`](#0x1_coin_WithdrawEvent)
 -  [Struct `CoinEventHandleDeletion`](#0x1_coin_CoinEventHandleDeletion)
 -  [Struct `PairCreation`](#0x1_coin_PairCreation)
--  [Resource `MigrationFlag`](#0x1_coin_MigrationFlag)
 -  [Struct `MintCapability`](#0x1_coin_MintCapability)
 -  [Struct `FreezeCapability`](#0x1_coin_FreezeCapability)
 -  [Struct `BurnCapability`](#0x1_coin_BurnCapability)
@@ -29,6 +28,7 @@ This module provides the foundation for typesafe Coins.
 -  [Struct `MintRefReceipt`](#0x1_coin_MintRefReceipt)
 -  [Struct `TransferRefReceipt`](#0x1_coin_TransferRefReceipt)
 -  [Struct `BurnRefReceipt`](#0x1_coin_BurnRefReceipt)
+-  [Resource `MigrationFlag`](#0x1_coin_MigrationFlag)
 -  [Resource `Ghost$supply`](#0x1_coin_Ghost$supply)
 -  [Resource `Ghost$aggregate_supply`](#0x1_coin_Ghost$aggregate_supply)
 -  [Constants](#@Constants_0)
@@ -57,6 +57,7 @@ This module provides the foundation for typesafe Coins.
 -  [Function `calculate_amount_to_withdraw`](#0x1_coin_calculate_amount_to_withdraw)
 -  [Function `maybe_convert_to_fungible_store`](#0x1_coin_maybe_convert_to_fungible_store)
 -  [Function `migrate_to_fungible_store`](#0x1_coin_migrate_to_fungible_store)
+-  [Function `migrate_coin_store_to_fungible_store`](#0x1_coin_migrate_coin_store_to_fungible_store)
 -  [Function `coin_address`](#0x1_coin_coin_address)
 -  [Function `balance`](#0x1_coin_balance)
 -  [Function `is_balance_at_least`](#0x1_coin_is_balance_at_least)
@@ -151,6 +152,7 @@ This module provides the foundation for typesafe Coins.
 use 0x1::system_addresses;
 use 0x1::table;
 use 0x1::type_info;
+use 0x1::vector;
 
@@ -621,35 +623,6 @@ Module event emitted when a new pair of coin and fungible asset is created. - - - - -## Resource `MigrationFlag` - -The flag the existence of which indicates the primary fungible store is created by the migration from CoinStore. - - -
#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
-struct MigrationFlag has key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- -
@@ -916,6 +889,36 @@ The hot potato receipt for flash borrowing BurnRef. + + + + +## Resource `MigrationFlag` + +The flag the existence of which indicates the primary fungible store is created by the migration from CoinStore. + + +
#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
+#[deprecated]
+struct MigrationFlag has key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ +
@@ -2038,7 +2041,6 @@ or disallow upgradability of total supply. let metadata = ensure_paired_metadata<CoinType>(); let store = primary_fungible_store::ensure_primary_store_exists(account, metadata); - let store_address = object::object_address(&store); if (exists<CoinStore<CoinType>>(account)) { let CoinStore<CoinType> { coin, frozen, deposit_events, withdraw_events } = move_from<CoinStore<CoinType>>( account @@ -2068,9 +2070,6 @@ or disallow upgradability of total supply. fungible_asset::set_frozen_flag_internal(store, frozen); } }; - if (!exists<MigrationFlag>(store_address)) { - move_to(&create_signer::create_signer(store_address), MigrationFlag {}); - } } @@ -2103,6 +2102,37 @@ Voluntarily migrate to fungible store for CoinType if not yet. + + + + +## Function `migrate_coin_store_to_fungible_store` + +Migrate to fungible store for CoinType if not yet. + + +
public entry fun migrate_coin_store_to_fungible_store<CoinType>(accounts: vector<address>)
+
+ + + +
+Implementation + + +
public entry fun migrate_coin_store_to_fungible_store<CoinType>(
+    accounts: vector<address>
+) acquires CoinStore, CoinConversionMap, CoinInfo {
+    if (features::new_accounts_default_to_fa_apt_store_enabled()) {
+        std::vector::for_each(accounts, |account| {
+            maybe_convert_to_fungible_store<CoinType>(account);
+        });
+    }
+}
+
+ + +
@@ -2625,11 +2655,13 @@ Deposit the coin balance into the recipient's account and emit an event. account_address: address, metadata: Object<Metadata> ): bool { - let primary_store_address = primary_fungible_store::primary_store_address<Metadata>(account_address, metadata); - fungible_asset::store_exists(primary_store_address) && ( - // migration flag is needed, until we start defaulting new accounts to APT PFS - features::new_accounts_default_to_fa_apt_store_enabled() || exists<MigrationFlag>(primary_store_address) - ) + features::new_accounts_default_to_fa_apt_store_enabled() || { + let primary_store_address = primary_fungible_store::primary_store_address<Metadata>( + account_address, + metadata + ); + fungible_asset::store_exists(primary_store_address) + } } @@ -2669,7 +2701,7 @@ This is for internal use only and doesn't emit an DepositEvent. )) { let fa = coin_to_fungible_asset(coin); let metadata = fungible_asset::asset_metadata(&fa); - let store = primary_fungible_store::primary_store(account_addr, metadata); + let store = primary_fungible_store::ensure_primary_store_exists(account_addr, metadata); fungible_asset::deposit_internal(object::object_address(&store), fa); } else { abort error::not_found(ECOIN_STORE_NOT_PUBLISHED) @@ -3782,7 +3814,8 @@ Get address by reflection.
fun spec_is_account_registered<CoinType>(account_addr: address): bool {
    let paired_metadata_opt = spec_paired_metadata<CoinType>();
-   exists<CoinStore<CoinType>>(account_addr) || (option::spec_is_some(
+   exists<CoinStore<CoinType>>(account_addr) || features::spec_new_accounts_default_to_fa_apt_store_enabled(
+   ) || (option::spec_is_some(
        paired_metadata_opt
    ) && primary_fungible_store::spec_primary_store_exists(account_addr, option::spec_borrow(paired_metadata_opt)))
 }
@@ -4195,27 +4228,6 @@ The creator of CoinType must be @aptos_framework.
 
-Make sure name and symbol are legal length. -Only the creator of CoinType can initialize. - - - - - -
schema InitializeInternalSchema<CoinType> {
-    account: signer;
-    name: vector<u8>;
-    symbol: vector<u8>;
-    let account_addr = signer::address_of(account);
-    let coin_address = type_info::type_of<CoinType>().account_address;
-    aborts_if coin_address != account_addr;
-    aborts_if exists<CoinInfo<CoinType>>(account_addr);
-    aborts_if len(name) > MAX_COIN_NAME_LENGTH;
-    aborts_if len(symbol) > MAX_COIN_SYMBOL_LENGTH;
-}
-
- - diff --git a/aptos-move/framework/aptos-framework/sources/account.move b/aptos-move/framework/aptos-framework/sources/account.move index 0487ed630c4e2..744ffa18861e9 100644 --- a/aptos-move/framework/aptos-framework/sources/account.move +++ b/aptos-move/framework/aptos-framework/sources/account.move @@ -1590,7 +1590,6 @@ module aptos_framework::account { create_account_unchecked(addr); register_coin(addr); - let eventhandle = &borrow_global(addr).coin_register_events; let event = CoinRegister { account: addr, type_info: type_info::type_of() }; let events = event::emitted_events(); diff --git a/aptos-move/framework/aptos-framework/sources/aptos_account.move b/aptos-move/framework/aptos-framework/sources/aptos_account.move index d18abf2125186..0f2a0ebb93d56 100644 --- a/aptos-move/framework/aptos-framework/sources/aptos_account.move +++ b/aptos-move/framework/aptos-framework/sources/aptos_account.move @@ -222,9 +222,7 @@ module aptos_framework::aptos_account { } public(friend) fun register_apt(account_signer: &signer) { - if (features::new_accounts_default_to_fa_apt_store_enabled()) { - ensure_primary_fungible_store_exists(signer::address_of(account_signer)); - } else { + if (!features::new_accounts_default_to_fa_apt_store_enabled()) { coin::register(account_signer); } } @@ -320,7 +318,6 @@ module aptos_framework::aptos_account { let (resource_account, _) = account::create_resource_account(alice, vector[]); let resource_acc_addr = signer::address_of(&resource_account); let (burn_cap, mint_cap) = aptos_framework::aptos_coin::initialize_for_test(core); - assert!(!coin::is_account_registered(resource_acc_addr), 0); create_account(signer::address_of(alice)); coin::deposit(signer::address_of(alice), coin::mint(10000, &mint_cap)); diff --git a/aptos-move/framework/aptos-framework/sources/coin.move b/aptos-move/framework/aptos-framework/sources/coin.move index f1d9a81962785..a7fda35ce3eeb 100644 --- a/aptos-move/framework/aptos-framework/sources/coin.move +++ b/aptos-move/framework/aptos-framework/sources/coin.move @@ -221,10 +221,6 @@ module aptos_framework::coin { fungible_asset_metadata_address: address, } - #[resource_group_member(group = aptos_framework::object::ObjectGroup)] - /// The flag the existence of which indicates the primary fungible store is created by the migration from CoinStore. - struct MigrationFlag has key {} - /// Capability required to mint coins. struct MintCapability has copy, store {} @@ -572,7 +568,6 @@ module aptos_framework::coin { let metadata = ensure_paired_metadata(); let store = primary_fungible_store::ensure_primary_store_exists(account, metadata); - let store_address = object::object_address(&store); if (exists>(account)) { let CoinStore { coin, frozen, deposit_events, withdraw_events } = move_from>( account @@ -602,9 +597,6 @@ module aptos_framework::coin { fungible_asset::set_frozen_flag_internal(store, frozen); } }; - if (!exists(store_address)) { - move_to(&create_signer::create_signer(store_address), MigrationFlag {}); - } } /// Voluntarily migrate to fungible store for `CoinType` if not yet. @@ -614,6 +606,17 @@ module aptos_framework::coin { maybe_convert_to_fungible_store(signer::address_of(account)); } + /// Migrate to fungible store for `CoinType` if not yet. + public entry fun migrate_coin_store_to_fungible_store( + accounts: vector
+ ) acquires CoinStore, CoinConversionMap, CoinInfo { + if (features::new_accounts_default_to_fa_apt_store_enabled()) { + std::vector::for_each(accounts, |account| { + maybe_convert_to_fungible_store(account); + }); + } + } + // // Getter functions // @@ -826,11 +829,13 @@ module aptos_framework::coin { account_address: address, metadata: Object ): bool { - let primary_store_address = primary_fungible_store::primary_store_address(account_address, metadata); - fungible_asset::store_exists(primary_store_address) && ( - // migration flag is needed, until we start defaulting new accounts to APT PFS - features::new_accounts_default_to_fa_apt_store_enabled() || exists(primary_store_address) - ) + features::new_accounts_default_to_fa_apt_store_enabled() || { + let primary_store_address = primary_fungible_store::primary_store_address( + account_address, + metadata + ); + fungible_asset::store_exists(primary_store_address) + } } /// Deposit the coin balance into the recipient's account without checking if the account is frozen. @@ -850,7 +855,7 @@ module aptos_framework::coin { )) { let fa = coin_to_fungible_asset(coin); let metadata = fungible_asset::asset_metadata(&fa); - let store = primary_fungible_store::primary_store(account_addr, metadata); + let store = primary_fungible_store::ensure_primary_store_exists(account_addr, metadata); fungible_asset::deposit_internal(object::object_address(&store), fa); } else { abort error::not_found(ECOIN_STORE_NOT_PUBLISHED) @@ -1906,7 +1911,6 @@ module aptos_framework::coin { } #[test(account = @aptos_framework, aaron = @0xaa10, bob = @0xb0b)] - #[expected_failure(abort_code = 0x60005, location = Self)] fun test_force_deposit( account: &signer, aaron: &signer, @@ -1949,6 +1953,8 @@ module aptos_framework::coin { account::create_account_for_test(account_addr); account::create_account_for_test(aaron_addr); account::create_account_for_test(bob_addr); + let feature = features::get_new_accounts_default_to_fa_apt_store_feature(); + features::change_feature_flags_for_testing(account, vector[], vector[feature]); let (burn_cap, freeze_cap, mint_cap) = initialize_and_register_fake_money(account, 1, true); assert!(coin_store_exists(account_addr), 0); @@ -1957,6 +1963,13 @@ module aptos_framework::coin { assert!(!coin_store_exists(aaron_addr), 0); assert!(!is_account_registered(aaron_addr), 0); + register(bob); + assert!(coin_store_exists(bob_addr), 0); + maybe_convert_to_fungible_store(bob_addr); + assert!(!coin_store_exists(bob_addr), 0); + register(bob); + assert!(!coin_store_exists(bob_addr), 0); + maybe_convert_to_fungible_store(aaron_addr); let coin = mint(100, &mint_cap); deposit(aaron_addr, coin); @@ -1968,15 +1981,8 @@ module aptos_framework::coin { assert!(!coin_store_exists(account_addr), 0); assert!(is_account_registered(account_addr), 0); - // Deposit FA to bob to created primary fungible store without `MigrationFlag`. primary_fungible_store::deposit(bob_addr, coin_to_fungible_asset(mint(100, &mint_cap))); assert!(!coin_store_exists(bob_addr), 0); - register(bob); - assert!(coin_store_exists(bob_addr), 0); - maybe_convert_to_fungible_store(bob_addr); - assert!(!coin_store_exists(bob_addr), 0); - register(bob); - assert!(!coin_store_exists(bob_addr), 0); move_to(account, FakeMoneyCapabilities { burn_cap, @@ -1998,9 +2004,8 @@ module aptos_framework::coin { assert!(coin_balance(account_addr) == 0, 0); assert!(balance(account_addr) == 100, 0); let coin = withdraw(account, 50); - assert!(!migrated_primary_fungible_store_exists(account_addr, ensure_paired_metadata()), 0); - maybe_convert_to_fungible_store(account_addr); assert!(migrated_primary_fungible_store_exists(account_addr, ensure_paired_metadata()), 0); + maybe_convert_to_fungible_store(account_addr); deposit(account_addr, coin); assert!(coin_balance(account_addr) == 0, 0); assert!(balance(account_addr) == 100, 0); @@ -2011,4 +2016,9 @@ module aptos_framework::coin { mint_cap, }); } + + #[deprecated] + #[resource_group_member(group = aptos_framework::object::ObjectGroup)] + /// The flag the existence of which indicates the primary fungible store is created by the migration from CoinStore. + struct MigrationFlag has key {} } diff --git a/aptos-move/framework/aptos-framework/sources/coin.spec.move b/aptos-move/framework/aptos-framework/sources/coin.spec.move index 7033b42589b7f..b43c5850ec882 100644 --- a/aptos-move/framework/aptos-framework/sources/coin.spec.move +++ b/aptos-move/framework/aptos-framework/sources/coin.spec.move @@ -161,7 +161,8 @@ spec aptos_framework::coin { spec fun spec_is_account_registered(account_addr: address): bool { let paired_metadata_opt = spec_paired_metadata(); - exists>(account_addr) || (option::spec_is_some( + exists>(account_addr) || features::spec_new_accounts_default_to_fa_apt_store_enabled( + ) || (option::spec_is_some( paired_metadata_opt ) && primary_fungible_store::spec_primary_store_exists(account_addr, option::spec_borrow(paired_metadata_opt))) } diff --git a/aptos-move/framework/aptos-framework/sources/genesis.move b/aptos-move/framework/aptos-framework/sources/genesis.move index 207bcf74b351c..0a0b01722f9ec 100644 --- a/aptos-move/framework/aptos-framework/sources/genesis.move +++ b/aptos-move/framework/aptos-framework/sources/genesis.move @@ -539,7 +539,7 @@ module aptos_framework::genesis { aptos_account::register_apt(&core_resources); // registers APT store let apt_metadata = object::address_to_object(@aptos_fungible_asset); - assert!(primary_fungible_store::primary_store_exists(@core_resources, apt_metadata), 2); + assert!(!primary_fungible_store::primary_store_exists(@core_resources, apt_metadata), 2); aptos_coin::configure_accounts_for_test(aptos_framework, &core_resources, mint_cap); diff --git a/aptos-move/framework/aptos-framework/sources/resource_account.move b/aptos-move/framework/aptos-framework/sources/resource_account.move index 26ee8123ea0ac..4930be2ba4fd1 100644 --- a/aptos-move/framework/aptos-framework/sources/resource_account.move +++ b/aptos-move/framework/aptos-framework/sources/resource_account.move @@ -248,7 +248,6 @@ module aptos_framework::resource_account { } #[test(framework = @0x1, user = @0x2345)] - #[expected_failure(abort_code = 0x60005, location = aptos_framework::coin)] public entry fun without_coin(framework: signer, user: signer) acquires Container { let user_addr = signer::address_of(&user); let (burn, mint) = aptos_framework::aptos_coin::initialize_for_test(&framework); diff --git a/aptos-move/framework/aptos-framework/sources/vesting.move b/aptos-move/framework/aptos-framework/sources/vesting.move index 8c3ac239a874a..47616b5f63d6b 100644 --- a/aptos-move/framework/aptos-framework/sources/vesting.move +++ b/aptos-move/framework/aptos-framework/sources/vesting.move @@ -1189,8 +1189,6 @@ module aptos_framework::vesting { #[test_only] use aptos_framework::stake::with_rewards; - #[test_only] - use aptos_framework::account::create_account_for_test; use aptos_std::math64::min; #[test_only] @@ -1461,40 +1459,6 @@ module aptos_framework::vesting { setup_vesting_contract(admin, &vector[@1, @2], &vector[1], admin_address, 0); } - #[test(aptos_framework = @0x1, admin = @0x123)] - #[expected_failure(abort_code = 0x60001, location = aptos_framework::aptos_account)] - public entry fun test_create_vesting_contract_with_invalid_withdrawal_address_should_fail( - aptos_framework: &signer, - admin: &signer, - ) acquires AdminStore { - let admin_address = signer::address_of(admin); - setup(aptos_framework, &vector[admin_address]); - setup_vesting_contract(admin, &vector[@1, @2], &vector[1], @5, 0); - } - - #[test(aptos_framework = @0x1, admin = @0x123)] - #[expected_failure(abort_code = 0x60001, location = aptos_framework::aptos_account)] - public entry fun test_create_vesting_contract_with_missing_withdrawal_account_should_fail( - aptos_framework: &signer, - admin: &signer, - ) acquires AdminStore { - let admin_address = signer::address_of(admin); - setup(aptos_framework, &vector[admin_address]); - setup_vesting_contract(admin, &vector[@1, @2], &vector[1], @11, 0); - } - - #[test(aptos_framework = @0x1, admin = @0x123)] - #[expected_failure(abort_code = 0x60002, location = aptos_framework::aptos_account)] - public entry fun test_create_vesting_contract_with_unregistered_withdrawal_account_should_fail( - aptos_framework: &signer, - admin: &signer, - ) acquires AdminStore { - let admin_address = signer::address_of(admin); - setup(aptos_framework, &vector[admin_address]); - create_account_for_test(@11); - setup_vesting_contract(admin, &vector[@1, @2], &vector[1], @11, 0); - } - #[test(aptos_framework = @0x1)] #[expected_failure(abort_code = 0x10002, location = Self)] public entry fun test_create_empty_vesting_schedule_should_fail(aptos_framework: &signer) { @@ -2030,20 +1994,6 @@ module aptos_framework::vesting { set_beneficiary(admin, contract_address, @1, @11); } - #[test(aptos_framework = @0x1, admin = @0x123)] - #[expected_failure(abort_code = 0x60002, location = aptos_framework::aptos_account)] - public entry fun test_set_beneficiary_with_unregistered_account_should_fail( - aptos_framework: &signer, - admin: &signer, - ) acquires AdminStore, VestingContract { - let admin_address = signer::address_of(admin); - setup(aptos_framework, &vector[admin_address]); - let contract_address = setup_vesting_contract( - admin, &vector[@1, @2], &vector[GRANT_AMOUNT, GRANT_AMOUNT], admin_address, 0); - create_account_for_test(@11); - set_beneficiary(admin, contract_address, @1, @11); - } - #[test(aptos_framework = @0x1, admin = @0x123)] public entry fun test_set_beneficiary_should_send_distribution( aptos_framework: &signer, diff --git a/aptos-move/framework/cached-packages/src/aptos_framework_sdk_builder.rs b/aptos-move/framework/cached-packages/src/aptos_framework_sdk_builder.rs index 4819248b3e12e..c7fe5a59010e1 100644 --- a/aptos-move/framework/cached-packages/src/aptos_framework_sdk_builder.rs +++ b/aptos-move/framework/cached-packages/src/aptos_framework_sdk_builder.rs @@ -323,6 +323,12 @@ pub enum EntryFunctionCall { coin_type: TypeTag, }, + /// Migrate to fungible store for `CoinType` if not yet. + CoinMigrateCoinStoreToFungibleStore { + coin_type: TypeTag, + accounts: Vec, + }, + /// Voluntarily migrate to fungible store for `CoinType` if not yet. CoinMigrateToFungibleStore { coin_type: TypeTag, @@ -1298,6 +1304,10 @@ impl EntryFunctionCall { } => code_publish_package_txn(metadata_serialized, code), CoinCreateCoinConversionMap {} => coin_create_coin_conversion_map(), CoinCreatePairing { coin_type } => coin_create_pairing(coin_type), + CoinMigrateCoinStoreToFungibleStore { + coin_type, + accounts, + } => coin_migrate_coin_store_to_fungible_store(coin_type, accounts), CoinMigrateToFungibleStore { coin_type } => coin_migrate_to_fungible_store(coin_type), CoinTransfer { coin_type, @@ -2562,6 +2572,25 @@ pub fn coin_create_pairing(coin_type: TypeTag) -> TransactionPayload { )) } +/// Migrate to fungible store for `CoinType` if not yet. +pub fn coin_migrate_coin_store_to_fungible_store( + coin_type: TypeTag, + accounts: Vec, +) -> TransactionPayload { + TransactionPayload::EntryFunction(EntryFunction::new( + ModuleId::new( + AccountAddress::new([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 1, + ]), + ident_str!("coin").to_owned(), + ), + ident_str!("migrate_coin_store_to_fungible_store").to_owned(), + vec![coin_type], + vec![bcs::to_bytes(&accounts).unwrap()], + )) +} + /// Voluntarily migrate to fungible store for `CoinType` if not yet. pub fn coin_migrate_to_fungible_store(coin_type: TypeTag) -> TransactionPayload { TransactionPayload::EntryFunction(EntryFunction::new( @@ -5398,6 +5427,19 @@ mod decoder { } } + pub fn coin_migrate_coin_store_to_fungible_store( + payload: &TransactionPayload, + ) -> Option { + if let TransactionPayload::EntryFunction(script) = payload { + Some(EntryFunctionCall::CoinMigrateCoinStoreToFungibleStore { + coin_type: script.ty_args().get(0)?.clone(), + accounts: bcs::from_bytes(script.args().get(0)?).ok()?, + }) + } else { + None + } + } + pub fn coin_migrate_to_fungible_store( payload: &TransactionPayload, ) -> Option { @@ -6947,6 +6989,10 @@ static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy + + +
fun spec_new_accounts_default_to_fa_apt_store_enabled(): bool {
+   spec_is_enabled(NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE)
+}
+
+ + + + diff --git a/aptos-move/framework/move-stdlib/sources/configs/features.spec.move b/aptos-move/framework/move-stdlib/sources/configs/features.spec.move index 9b8e0c8d4f4ef..7fd386a0bdb2a 100644 --- a/aptos-move/framework/move-stdlib/sources/configs/features.spec.move +++ b/aptos-move/framework/move-stdlib/sources/configs/features.spec.move @@ -96,6 +96,10 @@ spec std::features { spec_is_enabled(ABORT_IF_MULTISIG_PAYLOAD_MISMATCH) } + spec fun spec_new_accounts_default_to_fa_apt_store_enabled(): bool { + spec_is_enabled(NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE) + } + spec fun spec_simulation_enhancement_enabled(): bool { spec_is_enabled(TRANSACTION_SIMULATION_ENHANCEMENT) } diff --git a/aptos-move/move-examples/defi/sources/locked_coins.move b/aptos-move/move-examples/defi/sources/locked_coins.move index 92887e270704a..1ce727c4bf70b 100644 --- a/aptos-move/move-examples/defi/sources/locked_coins.move +++ b/aptos-move/move-examples/defi/sources/locked_coins.move @@ -265,14 +265,12 @@ module defi::locked_coins { }); } - #[test_only] - use std::string; #[test_only] use aptos_framework::account; #[test_only] use aptos_framework::coin::BurnCapability; #[test_only] - use aptos_framework::aptos_coin::AptosCoin; + use aptos_framework::aptos_coin::{Self, AptosCoin}; #[test_only] use aptos_framework::aptos_account; @@ -280,19 +278,12 @@ module defi::locked_coins { fun setup(aptos_framework: &signer, sponsor: &signer): BurnCapability { timestamp::set_time_has_started_for_testing(aptos_framework); - let (burn_cap, freeze_cap, mint_cap) = coin::initialize( - aptos_framework, - string::utf8(b"TC"), - string::utf8(b"TC"), - 8, - false, - ); + let (burn_cap, mint_cap) = aptos_coin::initialize_for_test(aptos_framework); account::create_account_for_test(signer::address_of(sponsor)); coin::register(sponsor); let coins = coin::mint(2000, &mint_cap); coin::deposit(signer::address_of(sponsor), coins); coin::destroy_mint_cap(mint_cap); - coin::destroy_freeze_cap(freeze_cap); burn_cap } diff --git a/execution/executor-benchmark/src/db_access.rs b/execution/executor-benchmark/src/db_access.rs index 98eebae63b4ca..a269859e767c5 100644 --- a/execution/executor-benchmark/src/db_access.rs +++ b/execution/executor-benchmark/src/db_access.rs @@ -2,18 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::Result; +use aptos_sdk::types::get_apt_primary_store_address; use aptos_storage_interface::state_view::DbStateView; use aptos_types::{ account_address::AccountAddress, - state_store::{state_key::StateKey, StateView}, + account_config::{FungibleStoreResource, ObjectGroupResource}, + state_store::{state_key::StateKey, StateView, TStateView}, write_set::TOTAL_SUPPLY_STATE_KEY, }; use move_core_types::{ identifier::Identifier, language_storage::{StructTag, TypeTag}, + move_resource::MoveStructType, }; use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use std::str::FromStr; +use std::{collections::BTreeMap, str::FromStr}; #[derive(Debug, Default, Deserialize, Serialize)] pub struct CoinStore { @@ -113,6 +116,31 @@ impl DbAccessUtil { Self::get_value(coin_store_key, state_view) } + pub fn get_fa_store( + account: AccountAddress, + state_view: &impl StateView, + ) -> Option { + let bytes_opt = TStateView::get_state_value_bytes( + &state_view, + &StateKey::resource_group( + &get_apt_primary_store_address(account), + &ObjectGroupResource::struct_tag(), + ), + ) + .expect("account must exist in data store"); + let group: Option>> = bytes_opt + .map(|bytes| bcs::from_bytes(&bytes)) + .transpose() + .unwrap(); + group + .and_then(|g| { + g.get(&FungibleStoreResource::struct_tag()) + .map(|b| bcs::from_bytes(b)) + }) + .transpose() + .unwrap() + } + pub fn get_value( state_key: &StateKey, state_view: &impl StateView, diff --git a/execution/executor-benchmark/src/db_reliable_submitter.rs b/execution/executor-benchmark/src/db_reliable_submitter.rs index d95b8f37e70fa..bae55076b59c3 100644 --- a/execution/executor-benchmark/src/db_reliable_submitter.rs +++ b/execution/executor-benchmark/src/db_reliable_submitter.rs @@ -29,11 +29,14 @@ impl ReliableTransactionSubmitter for DbReliableTransactionSubmitter { async fn get_account_balance(&self, account_address: AccountAddress) -> Result { let db_state_view = self.db.reader.latest_state_checkpoint_view().unwrap(); let sender_coin_store_key = DbAccessUtil::new_state_key_aptos_coin(account_address); - let sender_coin_store = - DbAccessUtil::get_db_value::(&sender_coin_store_key, &db_state_view)? - .unwrap(); + let coin = DbAccessUtil::get_db_value::(&sender_coin_store_key, &db_state_view)? + .map(|x| x.coin) + .unwrap_or(0); + let fa = DbAccessUtil::get_fa_store(account_address, &db_state_view) + .map(|x| x.balance()) + .unwrap_or(0); - Ok(sender_coin_store.coin) + Ok(coin + fa) } async fn query_sequence_number(&self, address: AccountAddress) -> Result { diff --git a/execution/executor-test-helpers/src/integration_test_impl.rs b/execution/executor-test-helpers/src/integration_test_impl.rs index 7b0b08ba157be..e5608ec0e9ed0 100644 --- a/execution/executor-test-helpers/src/integration_test_impl.rs +++ b/execution/executor-test-helpers/src/integration_test_impl.rs @@ -11,20 +11,26 @@ use aptos_db::AptosDB; use aptos_executor::block_executor::BlockExecutor; use aptos_executor_types::BlockExecutorTrait; use aptos_sdk::{ - move_types::account_address::AccountAddress, + bcs, + move_types::{ + account_address::AccountAddress, language_storage::StructTag, move_resource::MoveStructType, + }, transaction_builder::TransactionFactory, - types::{AccountKey, LocalAccount}, + types::{get_apt_primary_store_address, AccountKey, LocalAccount}, }; use aptos_storage_interface::{ state_view::{DbStateViewAtVersion, VerifiedStateViewAtVersion}, DbReaderWriter, }; use aptos_types::{ - account_config::{aptos_test_root_address, AccountResource, CoinStoreResource}, + account_config::{ + aptos_test_root_address, AccountResource, CoinStoreResource, FungibleStoreResource, + ObjectGroupResource, + }, block_metadata::BlockMetadata, chain_id::ChainId, ledger_info::LedgerInfo, - state_store::{MoveResourceExt, StateView}, + state_store::{state_key::StateKey, MoveResourceExt, StateView}, test_helpers::transaction_test_helpers::{block, TEST_BLOCK_EXECUTOR_ONCHAIN_CONFIG}, transaction::{ signature_verified_transaction::{ @@ -39,7 +45,7 @@ use aptos_types::{ }; use aptos_vm::aptos_vm::AptosVMBlockExecutor; use rand::SeedableRng; -use std::{path::Path, sync::Arc}; +use std::{collections::BTreeMap, path::Path, sync::Arc}; pub fn test_execution_with_storage_impl() -> Arc { let path = aptos_temppath::TempPath::new(); @@ -403,6 +409,28 @@ pub fn get_account_balance(state_view: &dyn StateView, address: &AccountAddress) CoinStoreResource::::fetch_move_resource(state_view, address) .unwrap() .map_or(0, |coin_store| coin_store.coin()) + + { + let bytes_opt = state_view + .get_state_value_bytes(&StateKey::resource_group( + &get_apt_primary_store_address(*address), + &ObjectGroupResource::struct_tag(), + )) + .expect("account must exist in data store"); + + let group: Option>> = bytes_opt + .map(|bytes| bcs::from_bytes(&bytes)) + .transpose() + .unwrap(); + group + .and_then(|g| { + g.get(&FungibleStoreResource::struct_tag()) + .map(|b| bcs::from_bytes(b)) + }) + .transpose() + .unwrap() + .map(|x: FungibleStoreResource| x.balance()) + .unwrap_or(0) + } } pub fn verify_account_balance(balance: u64, f: F) -> Result<()> diff --git a/execution/executor/tests/db_bootstrapper_test.rs b/execution/executor/tests/db_bootstrapper_test.rs index 6ec37d8c30048..5491730686b68 100644 --- a/execution/executor/tests/db_bootstrapper_test.rs +++ b/execution/executor/tests/db_bootstrapper_test.rs @@ -15,18 +15,19 @@ use aptos_executor_test_helpers::{ bootstrap_genesis, gen_ledger_info_with_sigs, get_test_signed_transaction, }; use aptos_executor_types::BlockExecutorTrait; +use aptos_sdk::types::get_apt_primary_store_address; use aptos_storage_interface::{state_view::LatestDbStateCheckpointView, DbReaderWriter}; use aptos_temppath::TempPath; use aptos_types::{ account_address::AccountAddress, account_config::{ - aptos_test_root_address, new_block_event_key, CoinStoreResource, NewBlockEvent, - NEW_EPOCH_EVENT_V2_MOVE_TYPE_TAG, + aptos_test_root_address, new_block_event_key, CoinStoreResource, FungibleStoreResource, + NewBlockEvent, ObjectGroupResource, NEW_EPOCH_EVENT_V2_MOVE_TYPE_TAG, }, contract_event::ContractEvent, event::EventHandle, on_chain_config::{ConfigurationResource, OnChainConfig, ValidatorSet}, - state_store::{state_key::StateKey, MoveResourceExt}, + state_store::{state_key::StateKey, MoveResourceExt, TStateView}, test_helpers::transaction_test_helpers::{block, TEST_BLOCK_EXECUTOR_ONCHAIN_CONFIG}, transaction::{authenticator::AuthenticationKey, ChangeSet, Transaction, WriteSetPayload}, trusted_state::TrustedState, @@ -36,9 +37,12 @@ use aptos_types::{ AptosCoinType, }; use aptos_vm::aptos_vm::AptosVMBlockExecutor; -use move_core_types::{language_storage::TypeTag, move_resource::MoveStructType}; +use move_core_types::{ + language_storage::{StructTag, TypeTag}, + move_resource::MoveStructType, +}; use rand::SeedableRng; -use std::sync::Arc; +use std::{collections::BTreeMap, sync::Arc}; #[test] fn test_empty_db() { @@ -174,8 +178,32 @@ fn get_balance(account: &AccountAddress, db: &DbReaderWriter) -> u64 { let db_state_view = db.reader.latest_state_checkpoint_view().unwrap(); CoinStoreResource::::fetch_move_resource(&db_state_view, account) .unwrap() - .unwrap() - .coin() + .map(|x| x.coin()) + .unwrap_or(0) + + { + let bytes_opt = TStateView::get_state_value_bytes( + &db_state_view, + &StateKey::resource_group( + &get_apt_primary_store_address(*account), + &ObjectGroupResource::struct_tag(), + ), + ) + .expect("account must exist in data store"); + + let group: Option>> = bytes_opt + .map(|bytes| bcs::from_bytes(&bytes)) + .transpose() + .unwrap(); + group + .and_then(|g| { + g.get(&FungibleStoreResource::struct_tag()) + .map(|b| bcs::from_bytes(b)) + }) + .transpose() + .unwrap() + .map(|x: FungibleStoreResource| x.balance()) + .unwrap_or(0) + } } fn get_configuration(db: &DbReaderWriter) -> ConfigurationResource { @@ -276,7 +304,7 @@ fn test_new_genesis() { assert_eq!(trusted_state.version(), 6); // Effect of bootstrapping reflected. - assert_eq!(get_balance(&account1, &db), 100_000_000); + assert_eq!(get_balance(&account1, &db), 300_000_000); // State before new genesis accessible. assert_eq!(get_balance(&account2, &db), 200_000_000); diff --git a/execution/executor/tests/internal_indexer_test.rs b/execution/executor/tests/internal_indexer_test.rs index 13d03f8092693..69405689b4385 100644 --- a/execution/executor/tests/internal_indexer_test.rs +++ b/execution/executor/tests/internal_indexer_test.rs @@ -185,7 +185,7 @@ fn test_db_indexer_data() { ) .unwrap(); let core_kv_res: Vec<_> = core_kv_iter.collect(); - assert_eq!(core_kv_res.len(), 5); + assert_eq!(core_kv_res.len(), 4); let address_one_kv_iter = db_indexer .get_prefixed_state_value_iterator( &StateKeyPrefix::from(AccountAddress::from_hex_literal("0x1").unwrap()), diff --git a/sdk/src/types.rs b/sdk/src/types.rs index 941cdf0a4c55e..18260634ff358 100644 --- a/sdk/src/types.rs +++ b/sdk/src/types.rs @@ -112,7 +112,7 @@ pub struct LocalAccount { pub fn get_apt_primary_store_address(address: AccountAddress) -> AccountAddress { let mut bytes = address.to_vec(); - bytes.append(&mut AccountAddress::ONE.to_vec()); + bytes.append(&mut AccountAddress::TEN.to_vec()); bytes.push(0xFC); AccountAddress::from_bytes(aptos_crypto::hash::HashValue::sha3_256_of(&bytes).to_vec()).unwrap() } diff --git a/types/src/account_address.rs b/types/src/account_address.rs index c0c4aab5b122f..7848e1f998abc 100644 --- a/types/src/account_address.rs +++ b/types/src/account_address.rs @@ -82,6 +82,13 @@ impl FromStr for AccountAddressWithChecks { } } +pub fn get_apt_primary_store_address(address: AccountAddress) -> AccountAddress { + let mut bytes = address.to_vec(); + bytes.append(&mut AccountAddress::TEN.to_vec()); + bytes.push(0xFC); + AccountAddress::from_bytes(aptos_crypto::hash::HashValue::sha3_256_of(&bytes).to_vec()).unwrap() +} + impl From for AccountAddressWithChecks { fn from(addr: AccountAddress) -> Self { AccountAddressWithChecks(addr) diff --git a/types/src/on_chain_config/aptos_features.rs b/types/src/on_chain_config/aptos_features.rs index 19ba7b7d1fb18..feb8aa304e401 100644 --- a/types/src/on_chain_config/aptos_features.rs +++ b/types/src/on_chain_config/aptos_features.rs @@ -164,6 +164,7 @@ impl FeatureFlag { FeatureFlag::COIN_TO_FUNGIBLE_ASSET_MIGRATION, FeatureFlag::OBJECT_NATIVE_DERIVED_ADDRESS, FeatureFlag::DISPATCHABLE_FUNGIBLE_ASSET, + FeatureFlag::NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE, FeatureFlag::REMOVE_DETAILED_ERROR_FROM_HASH, FeatureFlag::CONCURRENT_FUNGIBLE_ASSETS, FeatureFlag::AGGREGATOR_V2_IS_AT_LEAST_API,