From 9a4ca3adc77ab783ecba86fb3a4f2dd001915e6b Mon Sep 17 00:00:00 2001 From: bowenyang007 Date: Tue, 4 Mar 2025 11:16:12 -0800 Subject: [PATCH 1/4] add tests --- .../generated_transactions.rs | 19 +- .../6643353707_fa_transfer_events_v2.json} | 94 ++++---- .../6643353877_fa_transfer_2.json | 228 ++++++++++++++++++ .../indexer-transaction-generator/README.md | 26 +- .../imported_transactions.yaml | 4 +- .../src/config.rs | 21 +- 6 files changed, 325 insertions(+), 67 deletions(-) rename ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/{imported_devnet_txns/78753811_coin_transfer_with_v2_events.json => imported_testnet_txns/6643353707_fa_transfer_events_v2.json} (54%) create mode 100644 ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_testnet_txns/6643353877_fa_transfer_2.json diff --git a/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/generated_transactions.rs b/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/generated_transactions.rs index 8c3c6d42a0e3e..de5728fd12589 100644 --- a/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/generated_transactions.rs +++ b/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/generated_transactions.rs @@ -377,6 +377,11 @@ pub const IMPORTED_TESTNET_TXNS_5992795934_FA_ACTIVITIES: &[u8] = include_bytes! pub const IMPORTED_TESTNET_TXNS_6616059810_ACCOUNT_ABSTRACTION_AUTHENTICATOR: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/json_transactions/imported_testnet_txns/6616059810_account_abstraction_authenticator.json")); +pub const IMPORTED_TESTNET_TXNS_6643353877_FA_TRANSFER_2: &[u8] = include_bytes!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/src/json_transactions/imported_testnet_txns/6643353877_fa_transfer_2.json" +)); + pub const IMPORTED_TESTNET_TXNS_6617300504_ACCOUNT_RESTORATION_VERIFIED_KEY_ROTATION_TO_MULTI_ED_TXN: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/json_transactions/imported_testnet_txns/6617300504_account_restoration_verified_key_rotation_to_multi_ed_txn.json")); pub const IMPORTED_TESTNET_TXNS_4462417704_SECONDARY_STORE_BURNT: &[u8] = include_bytes!(concat!( @@ -415,6 +420,11 @@ pub const IMPORTED_TESTNET_TXNS_1_GENESIS: &[u8] = include_bytes!(concat!( "/src/json_transactions/imported_testnet_txns/1_genesis.json" )); +pub const IMPORTED_TESTNET_TXNS_6643353707_FA_TRANSFER_EVENTS_V2: &[u8] = include_bytes!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/src/json_transactions/imported_testnet_txns/6643353707_fa_transfer_events_v2.json" +)); + pub const IMPORTED_TESTNET_TXNS_769222973_MULTISIG: &[u8] = include_bytes!(concat!( env!("CARGO_MANIFEST_DIR"), "/src/json_transactions/imported_testnet_txns/769222973_multisig.json" @@ -435,6 +445,7 @@ pub const ALL_IMPORTED_TESTNET_TXNS: &[&[u8]] = &[ IMPORTED_TESTNET_TXNS_646928741_NO_EVENTS, IMPORTED_TESTNET_TXNS_5992795934_FA_ACTIVITIES, IMPORTED_TESTNET_TXNS_6616059810_ACCOUNT_ABSTRACTION_AUTHENTICATOR, + IMPORTED_TESTNET_TXNS_6643353877_FA_TRANSFER_2, IMPORTED_TESTNET_TXNS_6617300504_ACCOUNT_RESTORATION_VERIFIED_KEY_ROTATION_TO_MULTI_ED_TXN, IMPORTED_TESTNET_TXNS_4462417704_SECONDARY_STORE_BURNT, IMPORTED_TESTNET_TXNS_2646510387_CONCURRENT_FA, @@ -443,6 +454,7 @@ pub const ALL_IMPORTED_TESTNET_TXNS: &[&[u8]] = &[ IMPORTED_TESTNET_TXNS_5523474016_VALIDATOR_TXN, IMPORTED_TESTNET_TXNS_2_NEW_BLOCK_EVENT, IMPORTED_TESTNET_TXNS_1_GENESIS, + IMPORTED_TESTNET_TXNS_6643353707_FA_TRANSFER_EVENTS_V2, IMPORTED_TESTNET_TXNS_769222973_MULTISIG, IMPORTED_TESTNET_TXNS_1200394037_FA_V2_FROZEN_EVENT, IMPORTED_TESTNET_TXNS_6617355090_MULTI_ED_TXN, @@ -453,18 +465,11 @@ pub const IMPORTED_DEVNET_TXNS_19922017_TOKEN_V1_OFFER_CLAIM: &[u8] = include_by "/src/json_transactions/imported_devnet_txns/19922017_token_v1_offer_claim.json" )); -pub const IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS: &[u8] = - include_bytes!(concat!( - env!("CARGO_MANIFEST_DIR"), - "/src/json_transactions/imported_devnet_txns/78753811_coin_transfer_with_v2_events.json" - )); - pub const IMPORTED_DEVNET_TXNS_78753832_TOKEN_V2_MINT_TRANSFER_WITH_V2_EVENTS: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/json_transactions/imported_devnet_txns/78753832_token_v2_mint_transfer_with_v2_events.json")); pub const IMPORTED_DEVNET_TXNS_78753831_TOKEN_V1_MINT_TRANSFER_WITH_V2_EVENTS: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/json_transactions/imported_devnet_txns/78753831_token_v1_mint_transfer_with_v2_events.json")); pub const ALL_IMPORTED_DEVNET_TXNS: &[&[u8]] = &[ IMPORTED_DEVNET_TXNS_19922017_TOKEN_V1_OFFER_CLAIM, - IMPORTED_DEVNET_TXNS_78753811_COIN_TRANSFER_WITH_V2_EVENTS, IMPORTED_DEVNET_TXNS_78753832_TOKEN_V2_MINT_TRANSFER_WITH_V2_EVENTS, IMPORTED_DEVNET_TXNS_78753831_TOKEN_V1_MINT_TRANSFER_WITH_V2_EVENTS, ]; diff --git a/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_devnet_txns/78753811_coin_transfer_with_v2_events.json b/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_testnet_txns/6643353707_fa_transfer_events_v2.json similarity index 54% rename from ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_devnet_txns/78753811_coin_transfer_with_v2_events.json rename to ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_testnet_txns/6643353707_fa_transfer_events_v2.json index da8144a60cee1..f4ec54577b2f4 100644 --- a/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_devnet_txns/78753811_coin_transfer_with_v2_events.json +++ b/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_testnet_txns/6643353707_fa_transfer_events_v2.json @@ -1,23 +1,23 @@ { "timestamp": { - "seconds": "1733169023", - "nanos": 607104000 + "seconds": "1741114383", + "nanos": 413677000 }, - "version": "78753811", + "version": "6643353707", "info": { - "hash": "78AycFoduM5wZDbsCsMjZ5x7xaGmYUYsGwGWcTJ7QLs=", - "stateChangeHash": "Oy7P0tj9JFVYUm0rfxkF4dIkCLPbG98l8Wjd0k+jLyY=", - "eventRootHash": "z0ZIe1JzEBtGyo6IUKVuxoGa98vP7xPhLSsnVInQ4PQ=", - "gasUsed": "7", + "hash": "N/dR7dI4jO6UQMNRBXt+vEPWVvq4sH0YUKN/9sln+Ls=", + "stateChangeHash": "kjgxYTOpd0KzSpJJjrYrXzq7Y0ZUUifyews5Y0b6BoY=", + "eventRootHash": "EVju5AtGEVQAZ8Zr25HBykkdQ6ivcSJ4jc7qQst0ELc=", + "gasUsed": "11", "success": true, "vmStatus": "Executed successfully", - "accumulatorRootHash": "aw9XZJK27gS1QOlm1zD+Qt+A7vyNPuhlmFf/lz7VuHk=", + "accumulatorRootHash": "dsFfOAkJc677q4pxGzJ9KJb6pSqZR7UriAIyMcP+SYE=", "changes": [ { "type": "TYPE_WRITE_RESOURCE", "writeResource": { - "address": "0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0", - "stateKeyHash": "H+BsjnXgnvstj69e0KbR9VL8YyGz6eyuZ5aBlMtTaYw=", + "address": "0xbb3e0c3db6ab22cf18b8b0c6a2efd5b2304902b2a51f6338951e85938081b78", + "stateKeyHash": "Yl01Ha6O1tnlctC+O6ywig1fku8xfwKNyzcQjRfKqao=", "type": { "address": "0x1", "module": "coin", @@ -34,14 +34,14 @@ ] }, "typeStr": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": "{\"coin\":{\"value\":\"2\"},\"deposit_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0\",\"creation_num\":\"2\"}}},\"frozen\":false,\"withdraw_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0\",\"creation_num\":\"3\"}}}}" + "data": "{\"coin\":{\"value\":\"2644421640\"},\"deposit_events\":{\"counter\":\"18\",\"guid\":{\"id\":{\"addr\":\"0xbb3e0c3db6ab22cf18b8b0c6a2efd5b2304902b2a51f6338951e85938081b78\",\"creation_num\":\"2\"}}},\"frozen\":false,\"withdraw_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xbb3e0c3db6ab22cf18b8b0c6a2efd5b2304902b2a51f6338951e85938081b78\",\"creation_num\":\"3\"}}}}" } }, { "type": "TYPE_WRITE_RESOURCE", "writeResource": { - "address": "0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c", - "stateKeyHash": "GyEDoNkbSkI/rXXhfOPJk7mOq/wyMbpwiE2mga8YbF4=", + "address": "0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23", + "stateKeyHash": "hGvASsdjmrfHJ4FLx+IjGeebk8RHxH4co+0mNuhZCFg=", "type": { "address": "0x1", "module": "coin", @@ -58,21 +58,21 @@ ] }, "typeStr": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", - "data": "{\"coin\":{\"value\":\"34464975541459\"},\"deposit_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c\",\"creation_num\":\"2\"}}},\"frozen\":false,\"withdraw_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c\",\"creation_num\":\"3\"}}}}" + "data": "{\"coin\":{\"value\":\"266941379180\"},\"deposit_events\":{\"counter\":\"33\",\"guid\":{\"id\":{\"addr\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"creation_num\":\"2\"}}},\"frozen\":false,\"withdraw_events\":{\"counter\":\"8\",\"guid\":{\"id\":{\"addr\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"creation_num\":\"3\"}}}}" } }, { "type": "TYPE_WRITE_RESOURCE", "writeResource": { - "address": "0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c", - "stateKeyHash": "f20QhQxKQpYq+vQlsCOfyelvFcaXWS1sF9rP0ilbwAk=", + "address": "0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23", + "stateKeyHash": "IaK8Fqgq1wt8eWZqUAtaMTY927ZwPM9olf/B7htmpaY=", "type": { "address": "0x1", "module": "account", "name": "Account" }, "typeStr": "0x1::account::Account", - "data": "{\"authentication_key\":\"0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c\",\"coin_register_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c\",\"creation_num\":\"0\"}}},\"guid_creation_num\":\"8\",\"key_rotation_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c\",\"creation_num\":\"1\"}}},\"rotation_capability_offer\":{\"for\":{\"vec\":[]}},\"sequence_number\":\"2195678\",\"signer_capability_offer\":{\"for\":{\"vec\":[]}}}" + "data": "{\"authentication_key\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"coin_register_events\":{\"counter\":\"3\",\"guid\":{\"id\":{\"addr\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"creation_num\":\"0\"}}},\"guid_creation_num\":\"8\",\"key_rotation_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"creation_num\":\"1\"}}},\"rotation_capability_offer\":{\"for\":{\"vec\":[]}},\"sequence_number\":\"21\",\"signer_capability_offer\":{\"for\":{\"vec\":[]}}}" } }, { @@ -84,26 +84,26 @@ "data": { "key": "\"0x619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935\"", "keyType": "address", - "value": "\"18447249875628517278\"", + "value": "\"29211453233470568180\"", "valueType": "u128" } } } ] }, - "epoch": "63", - "blockHeight": "10811317", + "epoch": "22222", + "blockHeight": "437887148", "type": "TRANSACTION_TYPE_USER", "sizeInfo": { - "transactionBytes": 311, + "transactionBytes": 326, "eventSizeInfo": [ { - "typeTagBytes": 52, - "totalBytes": 119 + "typeTagBytes": 53, + "totalBytes": 109 }, { - "typeTagBytes": 51, - "totalBytes": 118 + "typeTagBytes": 52, + "totalBytes": 108 }, { "typeTagBytes": 63, @@ -131,12 +131,12 @@ }, "user": { "request": { - "sender": "0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c", - "sequenceNumber": "2195677", - "maxGasAmount": "2000000", + "sender": "0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23", + "sequenceNumber": "20", + "maxGasAmount": "22", "gasUnitPrice": "100", "expirationTimestampSecs": { - "seconds": "1733169083" + "seconds": "1741114473" }, "payload": { "type": "TYPE_ENTRY_FUNCTION_PAYLOAD", @@ -144,9 +144,9 @@ "function": { "module": { "address": "0x1", - "name": "coin" + "name": "aptos_account" }, - "name": "transfer" + "name": "transfer_coins" }, "typeArguments": [ { @@ -159,50 +159,54 @@ } ], "arguments": [ - "\"0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0\"", - "\"1\"" + "\"0xbb3e0c3db6ab22cf18b8b0c6a2efd5b2304902b2a51f6338951e85938081b78\"", + "\"1000000000\"" ], - "entryFunctionIdStr": "0x1::coin::transfer" + "entryFunctionIdStr": "0x1::aptos_account::transfer_coins" } }, "signature": { "type": "TYPE_ED25519", "ed25519": { - "publicKey": "vRgtbj9K0drw2U5T2q7OY+vVcdio4AmKAqTAtOzHyZ4=", - "signature": "q+BUcKerXUuzrATrJomw74pTkK8WzRrGUa8kzxlvo/Fa8xjpEZprvsfFODGcK3+/Rd/bYX/44JzGLTvBnICzCQ==" + "publicKey": "pMxKgD1h6JmAglo3lDvUYMzgVU6UZDNk5t97SLII9Mo=", + "signature": "wjOFyWR1OteDn1EPfs0xYDZV2+4MrG+au7g6PKttoH/IUEYNW58gWnV5xoB8HB5H7quj+d9dkfROwqNDg7uuAw==" } } }, "events": [ { "key": { - "accountAddress": "0x0" + "creationNumber": "3", + "accountAddress": "0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23" }, + "sequenceNumber": "7", "type": { "type": "MOVE_TYPES_STRUCT", "struct": { "address": "0x1", "module": "coin", - "name": "CoinWithdraw" + "name": "WithdrawEvent" } }, - "typeStr": "0x1::coin::CoinWithdraw", - "data": "{\"account\":\"0xe93dcd3dd5febf8d72bf8d33e1d85a6115300fedfe055c062834d264f103ce4c\",\"amount\":\"1\",\"coin_type\":\"0x1::aptos_coin::AptosCoin\"}" + "typeStr": "0x1::coin::WithdrawEvent", + "data": "{\"amount\":\"1000000000\"}" }, { "key": { - "accountAddress": "0x0" + "creationNumber": "2", + "accountAddress": "0x0bb3e0c3db6ab22cf18b8b0c6a2efd5b2304902b2a51f6338951e85938081b78" }, + "sequenceNumber": "17", "type": { "type": "MOVE_TYPES_STRUCT", "struct": { "address": "0x1", "module": "coin", - "name": "CoinDeposit" + "name": "DepositEvent" } }, - "typeStr": "0x1::coin::CoinDeposit", - "data": "{\"account\":\"0x74512d8383e6857a9a587012c44ad98420cbc713301714402611d7f87a7f4fe0\",\"amount\":\"1\",\"coin_type\":\"0x1::aptos_coin::AptosCoin\"}" + "typeStr": "0x1::coin::DepositEvent", + "data": "{\"amount\":\"1000000000\"}" }, { "key": { @@ -217,7 +221,7 @@ } }, "typeStr": "0x1::transaction_fee::FeeStatement", - "data": "{\"execution_gas_units\":\"4\",\"io_gas_units\":\"4\",\"storage_fee_octas\":\"0\",\"storage_fee_refund_octas\":\"0\",\"total_charge_gas_units\":\"7\"}" + "data": "{\"execution_gas_units\":\"5\",\"io_gas_units\":\"6\",\"storage_fee_octas\":\"0\",\"storage_fee_refund_octas\":\"0\",\"total_charge_gas_units\":\"11\"}" } ] } diff --git a/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_testnet_txns/6643353877_fa_transfer_2.json b/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_testnet_txns/6643353877_fa_transfer_2.json new file mode 100644 index 0000000000000..ba04d2860fe7a --- /dev/null +++ b/ecosystem/indexer-grpc/indexer-test-transactions/src/json_transactions/imported_testnet_txns/6643353877_fa_transfer_2.json @@ -0,0 +1,228 @@ +{ + "timestamp": { + "seconds": "1741114401", + "nanos": 619214000 + }, + "version": "6643353877", + "info": { + "hash": "qkAQTWZHCbQtpwwIGLa4mnrIQnhZMYlaXoBpKNxQhfg=", + "stateChangeHash": "5Nuwih+Gm9jpis5TJm7My6C4oOh1hWQRXJgHDkhUZPQ=", + "eventRootHash": "Z3OqtJJ8Xufw0RIh2kDTkuVp8dnL9GYlfKrh0l0VIGA=", + "gasUsed": "11", + "success": true, + "vmStatus": "Executed successfully", + "accumulatorRootHash": "73NEMsV2o+DYoHQzu8/KuOU/mdQ03rrE6+mKjEUExaQ=", + "changes": [ + { + "type": "TYPE_WRITE_RESOURCE", + "writeResource": { + "address": "0x60d4a83b62a6bfa828c6c555ea40b4a67a4b683f0ec559c3d85d796166455e3a", + "stateKeyHash": "Wsm/+n8m0n0+lh+1YIWRJYEUzRN1zEPdt/Wu5dKXCxc=", + "type": { + "address": "0x1", + "module": "coin", + "name": "CoinStore", + "genericTypeParams": [ + { + "type": "MOVE_TYPES_STRUCT", + "struct": { + "address": "0x1", + "module": "aptos_coin", + "name": "AptosCoin" + } + } + ] + }, + "typeStr": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", + "data": "{\"coin\":{\"value\":\"1667100170\"},\"deposit_events\":{\"counter\":\"9\",\"guid\":{\"id\":{\"addr\":\"0x60d4a83b62a6bfa828c6c555ea40b4a67a4b683f0ec559c3d85d796166455e3a\",\"creation_num\":\"2\"}}},\"frozen\":false,\"withdraw_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0x60d4a83b62a6bfa828c6c555ea40b4a67a4b683f0ec559c3d85d796166455e3a\",\"creation_num\":\"3\"}}}}" + } + }, + { + "type": "TYPE_WRITE_RESOURCE", + "writeResource": { + "address": "0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23", + "stateKeyHash": "hGvASsdjmrfHJ4FLx+IjGeebk8RHxH4co+0mNuhZCFg=", + "type": { + "address": "0x1", + "module": "coin", + "name": "CoinStore", + "genericTypeParams": [ + { + "type": "MOVE_TYPES_STRUCT", + "struct": { + "address": "0x1", + "module": "aptos_coin", + "name": "AptosCoin" + } + } + ] + }, + "typeStr": "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>", + "data": "{\"coin\":{\"value\":\"265941378080\"},\"deposit_events\":{\"counter\":\"33\",\"guid\":{\"id\":{\"addr\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"creation_num\":\"2\"}}},\"frozen\":false,\"withdraw_events\":{\"counter\":\"9\",\"guid\":{\"id\":{\"addr\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"creation_num\":\"3\"}}}}" + } + }, + { + "type": "TYPE_WRITE_RESOURCE", + "writeResource": { + "address": "0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23", + "stateKeyHash": "IaK8Fqgq1wt8eWZqUAtaMTY927ZwPM9olf/B7htmpaY=", + "type": { + "address": "0x1", + "module": "account", + "name": "Account" + }, + "typeStr": "0x1::account::Account", + "data": "{\"authentication_key\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"coin_register_events\":{\"counter\":\"3\",\"guid\":{\"id\":{\"addr\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"creation_num\":\"0\"}}},\"guid_creation_num\":\"8\",\"key_rotation_events\":{\"counter\":\"0\",\"guid\":{\"id\":{\"addr\":\"0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23\",\"creation_num\":\"1\"}}},\"rotation_capability_offer\":{\"for\":{\"vec\":[]}},\"sequence_number\":\"22\",\"signer_capability_offer\":{\"for\":{\"vec\":[]}}}" + } + }, + { + "type": "TYPE_WRITE_TABLE_ITEM", + "writeTableItem": { + "stateKeyHash": "bkso1A+YoQamUWNTCSTA3LQME0nTqpFdEItNbPwd2xk=", + "handle": "0x1b854694ae746cdbd8d44186ca4929b2b337df21d1c74633be19b2710552fdca", + "key": "0x0619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935", + "data": { + "key": "\"0x619dc29a0aac8fa146714058e8dd6d2d0f3bdf5f6331907bf91f3acd81e6935\"", + "keyType": "address", + "value": "\"29211453233480214540\"", + "valueType": "u128" + } + } + } + ] + }, + "epoch": "22222", + "blockHeight": "437887218", + "type": "TRANSACTION_TYPE_USER", + "sizeInfo": { + "transactionBytes": 326, + "eventSizeInfo": [ + { + "typeTagBytes": 53, + "totalBytes": 109 + }, + { + "typeTagBytes": 52, + "totalBytes": 108 + }, + { + "typeTagBytes": 63, + "totalBytes": 103 + } + ], + "writeOpSizeInfo": [ + { + "keyBytes": 138, + "valueBytes": 105 + }, + { + "keyBytes": 138, + "valueBytes": 105 + }, + { + "keyBytes": 84, + "valueBytes": 147 + }, + { + "keyBytes": 66, + "valueBytes": 16 + } + ] + }, + "user": { + "request": { + "sender": "0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23", + "sequenceNumber": "21", + "maxGasAmount": "22", + "gasUnitPrice": "100", + "expirationTimestampSecs": { + "seconds": "1741114491" + }, + "payload": { + "type": "TYPE_ENTRY_FUNCTION_PAYLOAD", + "entryFunctionPayload": { + "function": { + "module": { + "address": "0x1", + "name": "aptos_account" + }, + "name": "transfer_coins" + }, + "typeArguments": [ + { + "type": "MOVE_TYPES_STRUCT", + "struct": { + "address": "0x1", + "module": "aptos_coin", + "name": "AptosCoin" + } + } + ], + "arguments": [ + "\"0x60d4a83b62a6bfa828c6c555ea40b4a67a4b683f0ec559c3d85d796166455e3a\"", + "\"1000000000\"" + ], + "entryFunctionIdStr": "0x1::aptos_account::transfer_coins" + } + }, + "signature": { + "type": "TYPE_ED25519", + "ed25519": { + "publicKey": "pMxKgD1h6JmAglo3lDvUYMzgVU6UZDNk5t97SLII9Mo=", + "signature": "QUANnJtBkoA4pmwSiYrqHmL8Pmo+A82Oe7JHkUdV7ua+LQf0ykK0+6QQmJGpok6fYtxqCOpKU8D8u09XgnGtAA==" + } + } + }, + "events": [ + { + "key": { + "creationNumber": "3", + "accountAddress": "0xa3896acd8c1aac027f776bcdc2fce50886c55b15b390cae76dc291c149a8dd23" + }, + "sequenceNumber": "8", + "type": { + "type": "MOVE_TYPES_STRUCT", + "struct": { + "address": "0x1", + "module": "coin", + "name": "WithdrawEvent" + } + }, + "typeStr": "0x1::coin::WithdrawEvent", + "data": "{\"amount\":\"1000000000\"}" + }, + { + "key": { + "creationNumber": "2", + "accountAddress": "0x60d4a83b62a6bfa828c6c555ea40b4a67a4b683f0ec559c3d85d796166455e3a" + }, + "sequenceNumber": "8", + "type": { + "type": "MOVE_TYPES_STRUCT", + "struct": { + "address": "0x1", + "module": "coin", + "name": "DepositEvent" + } + }, + "typeStr": "0x1::coin::DepositEvent", + "data": "{\"amount\":\"1000000000\"}" + }, + { + "key": { + "accountAddress": "0x0" + }, + "type": { + "type": "MOVE_TYPES_STRUCT", + "struct": { + "address": "0x1", + "module": "transaction_fee", + "name": "FeeStatement" + } + }, + "typeStr": "0x1::transaction_fee::FeeStatement", + "data": "{\"execution_gas_units\":\"5\",\"io_gas_units\":\"6\",\"storage_fee_octas\":\"0\",\"storage_fee_refund_octas\":\"0\",\"total_charge_gas_units\":\"11\"}" + } + ] + } +} \ No newline at end of file diff --git a/ecosystem/indexer-grpc/indexer-transaction-generator/README.md b/ecosystem/indexer-grpc/indexer-transaction-generator/README.md index d3e82b114f478..20b1ac85fa476 100644 --- a/ecosystem/indexer-grpc/indexer-transaction-generator/README.md +++ b/ecosystem/indexer-grpc/indexer-transaction-generator/README.md @@ -4,27 +4,31 @@ This tool is to generate transactions for testing purposes. ## Usage -Under the root folder, i.e., `aptos-core`, run +Under the root folder, i.e., `aptos-core`, run the follow command. This will default to importing transactions for all networks. ```bash -cargo run -p aptos-indexer-transaction-generator -- \ - --testing-folder ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions \ - --output-folder ecosystem/indexer-grpc/indexer-test-transactions/src +cargo run -p aptos-indexer-transaction-generator -- --testing-folder ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions --output-folder ecosystem/indexer-grpc/indexer-test-transactions/src ``` -**You can also use absolute path, run (using binary as an example)** +You can optionally specify the mode, e.g. for script mode ```bash -./aptos-indexer-transaction-generator \ - --testing-folder /your/aptos-core/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions \ - --output-folder /tmp/ttt +cargo run -p aptos-indexer-transaction-generator -- --testing-folder ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions --output-folder ecosystem/indexer-grpc/indexer-test-transactions/src --mode script ``` -### Command-Line Options +Or network, e.g. mainnet - - `mode`: (Optional) Specify the mode of operation for the indexer. Possible values are `import` and `script`. Default is `import`. +```bash +cargo run -p aptos-indexer-transaction-generator -- --testing-folder ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions --output-folder ecosystem/indexer-grpc/indexer-test-transactions/src --network mainnet +``` + +Or testnet + +```bash +cargo run -p aptos-indexer-transaction-generator -- --testing-folder ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions --output-folder ecosystem/indexer-grpc/indexer-test-transactions/src --network testnet +``` -### Config Overview +### Config overview Your testing folder should contain: - One file called `testing_accounts.yaml`, which contains testing accounts used. diff --git a/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/imported_transactions.yaml b/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/imported_transactions.yaml index 8bbb07be1f5a3..06c4efbcd409e 100644 --- a/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/imported_transactions.yaml +++ b/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/imported_transactions.yaml @@ -2,7 +2,7 @@ testnet: # Transaction Stream endpoint addresss. transaction_stream_endpoint: https://grpc.testnet.aptoslabs.com:443 # (Optional) The key to use with developers.aptoslabs.com - api_key: TESTNET_API_KEY + api_key: aptoslabs_F8W1c58BmDB_LM3hb87W79AqLcBPr4ErzY1V2AitQ2Bts # A map from versions to dump and their output names. versions_to_import: # naming: @@ -22,6 +22,8 @@ testnet: 4462417704: 4462417704_secondary_store_burnt 646928741: 646928741_no_events 769222973: 769222973_multisig + 6643353707: 6643353707_fa_transfer_events_v2 + 6643353877: 6643353877_fa_transfer_2 # account restoration processor 6617300504: 6617300504_account_restoration_verified_key_rotation_to_multi_ed_txn diff --git a/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs b/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs index 7a82ecbd57912..6b9ccc55c418d 100644 --- a/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs +++ b/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs @@ -66,6 +66,10 @@ pub struct IndexerCliArgs { /// Mode of operation for the indexer. #[clap(long, default_value_t = Mode::Import, value_parser = Mode::from_str)] pub mode: Mode, + + /// Leave this blank if want all the networks + #[clap(long)] + pub network: Option, } impl IndexerCliArgs { @@ -93,7 +97,7 @@ impl IndexerCliArgs { serde_yaml::from_str(&imported_transactions_config_raw)?; imported_transactions_config - .validate_and_run(&output_folder) + .validate_and_run(&output_folder, &self.network) .await .context("Importing transactions failed.")?; } @@ -258,12 +262,22 @@ impl TransactionImporterConfig { Ok(()) } - pub async fn validate_and_run(&self, output_path: &Path) -> anyhow::Result<()> { + pub async fn validate_and_run( + &self, + output_path: &Path, + network: &Option, + ) -> anyhow::Result<()> { // Validate the configuration. self.validate()?; // Run the transaction importer for each network. for (network_name, network_config) in self.configs.iter() { + // If network is specified, only run the transaction importer for the specified network. + if let Some(network) = network { + if network != network_name { + continue; + } + } // Modify the output path by appending the network name to the base path let modified_output_path = match network_name.as_str() { "mainnet" => output_path.join(IMPORTED_MAINNET_TXNS), @@ -364,7 +378,7 @@ mod tests { // create a temporary folder for the output. let tempfile = tempfile::tempdir().unwrap(); let result = transaction_generator_config - .validate_and_run(tempfile.path()) + .validate_and_run(tempfile.path(), None) .await; assert!(result.is_err()); } @@ -402,6 +416,7 @@ mod tests { testing_folder: tempfile.path().to_path_buf(), output_folder, mode: Mode::Script, + network: None, }; let result = indexer_cli_args.run().await; assert!(result.is_err()); From a9957d8bc1fc9b86ca7fa986540ba150ea7fc8f8 Mon Sep 17 00:00:00 2001 From: bowenyang007 Date: Tue, 4 Mar 2025 15:51:40 -0800 Subject: [PATCH 2/4] oops --- .../imported_transactions/imported_transactions.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/imported_transactions.yaml b/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/imported_transactions.yaml index 06c4efbcd409e..dff4d71056a0e 100644 --- a/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/imported_transactions.yaml +++ b/ecosystem/indexer-grpc/indexer-transaction-generator/imported_transactions/imported_transactions.yaml @@ -2,7 +2,7 @@ testnet: # Transaction Stream endpoint addresss. transaction_stream_endpoint: https://grpc.testnet.aptoslabs.com:443 # (Optional) The key to use with developers.aptoslabs.com - api_key: aptoslabs_F8W1c58BmDB_LM3hb87W79AqLcBPr4ErzY1V2AitQ2Bts + api_key: TESTNET_API_KEY # A map from versions to dump and their output names. versions_to_import: # naming: From f8a1d81088caaf1cff1ed7f39be4263cdc0f26f0 Mon Sep 17 00:00:00 2001 From: bowenyang007 Date: Tue, 4 Mar 2025 16:32:46 -0800 Subject: [PATCH 3/4] fix lint --- .../indexer-grpc/indexer-transaction-generator/src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs b/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs index 6b9ccc55c418d..07a8c1e78e02b 100644 --- a/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs +++ b/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs @@ -97,7 +97,7 @@ impl IndexerCliArgs { serde_yaml::from_str(&imported_transactions_config_raw)?; imported_transactions_config - .validate_and_run(&output_folder, &self.network) + .validate_and_run(&output_folder, self.network.clone()) .await .context("Importing transactions failed.")?; } @@ -265,7 +265,7 @@ impl TransactionImporterConfig { pub async fn validate_and_run( &self, output_path: &Path, - network: &Option, + network: Option, ) -> anyhow::Result<()> { // Validate the configuration. self.validate()?; From ba63c8b8f0d41b02fed23a5cf5982404c5eda195 Mon Sep 17 00:00:00 2001 From: bowenyang007 Date: Tue, 4 Mar 2025 16:55:06 -0800 Subject: [PATCH 4/4] fix lint --- .../indexer-grpc/indexer-transaction-generator/src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs b/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs index 07a8c1e78e02b..2fcda2b444d60 100644 --- a/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs +++ b/ecosystem/indexer-grpc/indexer-transaction-generator/src/config.rs @@ -273,7 +273,7 @@ impl TransactionImporterConfig { // Run the transaction importer for each network. for (network_name, network_config) in self.configs.iter() { // If network is specified, only run the transaction importer for the specified network. - if let Some(network) = network { + if let Some(network) = &network { if network != network_name { continue; }