-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support test file creation as a part of test txn generation #15688
base: 12-03-allow_specifying_account_address_at_config_level_instead_of_random_assignment
Are you sure you want to change the base?
Conversation
⏱️ 1h 28m total CI duration on this PR
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
/** | ||
* Adds a directory of JSON files to the transaction code builder. | ||
* | ||
* @param src_dir: The source directory containing the JSON files | ||
* @param dir_name: The name of the directory to be created in the `json_transactions` directory | ||
* @param module_name: The name of the module to be used in the constant names | ||
* @param generate_name_function: Whether to generate a transaction name lookup function | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function documentation parameters don't match the actual function signature. The current parameters src_dir
and dir_name
should be replaced with json_dir
. The parameter descriptions should also be simplified to match the actual functionality - this function processes an existing directory of JSON files rather than creating new directories.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
d434b0a
to
e60d566
Compare
match fs::write(dest_path, code) { | ||
Ok(_) => println!("Successfully generated the transactions code."), | ||
Err(e) => println!("Failed to generate the transactions code for dest_path:{:?}, {:?}", dest_path, e), | ||
} | ||
Ok(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error from fs::write
is being silently converted to success. To properly handle failures, replace the match
with:
fs::write(dest_path, code).context("Failed to write transactions code")?;
This ensures errors propagate up the call stack while preserving the error context.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
For the |
The overall approach makes sense: we decouple the json and the code. Only one question regarding to the incompatibility: If jsons are on an older version(say we have 5 jsons) and the code is on a newer version(say we import 6 txns), is it possible to notify/show the users to upgrade to resolve? it looks like current behavior is compilation error.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file actually belong inside of indexer-transaction-generator
since it's part of transaction generation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason why I left it here is that the I thought we wanted to keep the json files in the aptos-core for the internal usage. so the process of adding new txn for processor testing remains the same, where we would have to update the cargo.toml in the processor repo with the latest commit hash for the internal use. And, we don't have to pass in the new CLI args create_rust_file
and rust_file
then it won't try to create a generate_transaction.rs in the processor repo
pub rust_file: Option<PathBuf>, | ||
|
||
#[clap(short, long)] | ||
pub create_rust_file: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this flag going to be false? I think we'd always want to update the Rust file if there are new or changed transactions.
|
||
/// Path to the rust file to generate the transactions code. | ||
#[clap(long)] | ||
pub rust_file: Option<PathBuf>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we reuse output_folder
as the path to store the Rust file?
I don’t think compatibility is an issue in this scenario, because we’re assuming each user relies on their own dedicated set of test transactions. but maybe we can discuss whether we should provide a fixed set of test transactions for them and store the jsons in the processor repo with the tests @rtso I agree that it makes sense to have the json files and generated rust file in the same place for debuggability, etc. |
#[clap(long)] | ||
pub rust_file: Option<PathBuf>, | ||
|
||
#[clap(short, long)] | ||
pub create_rust_file: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add default values to the new fields to maintain backward compatibility with existing tests: #[clap(long, default_value = "false")] for create_rust_file and keep rust_file as Option
Spotted by Graphite Reviewer (based on CI logs)
Is this helpful? React 👍 or 👎 to let us know.
[build-dependencies] | ||
aptos-indexer-transaction-generator = { workspace = true } | ||
aptos-protos ={ workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dependencies aptos-protos and serde_json need to be moved back to [dependencies] section while keeping them in [build-dependencies] since they are needed both at build time and runtime. The current configuration causes compilation errors because these dependencies are not available at runtime.
Spotted by Graphite Reviewer (based on CI logs)
Is this helpful? React 👍 or 👎 to let us know.
9f51332
to
5cad83d
Compare
e60d566
to
cf9f9c7
Compare
5cad83d
to
4ff0a0c
Compare
cf9f9c7
to
3822921
Compare
3822921
to
3b82607
Compare
@@ -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_Yq2BZM4pCY9_GU1vCq1XwB2NdU2Z8AENXnvKdwSiqF3YQ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the API key from source control to prevent security risks. Consider replacing it with a placeholder like TESTNET_API_KEY
and loading the actual value from environment variables at runtime. This follows security best practices for handling sensitive credentials.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
Description
Currently, external Indexer SDK users who want to test transactions must either maintain their own branch of aptos-core to avoid conflicts or copy our script into their test or processor repositories. This workflow can be confusing, so I’ve updated the transaction generation process to include the conversion step (from proto json to a rust file containing const variables) via new CLI arguments.
Existing Process:
New Process:
How Has This Been Tested?
locally tested
Key Areas to Review
Type of Change
Which Components or Systems Does This Change Impact?
Checklist