-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat/test-codeql. test codeql #146
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
Makefile (2)
49-52
: LGTM! Consider enhancing error handling.The new
check-libmovevm
target is a good addition to ensure the presence of the required shared library file. This can prevent potential runtime errors due to missing libraries.Consider adding error handling in case
api/libmovevm.x86_64.so
doesn't exist. For example:check-libmovevm: @if [ ! -f api/libmovevm.so ]; then \ if [ -f api/libmovevm.x86_64.so ]; then \ cp api/libmovevm.x86_64.so api/libmovevm.so; \ else \ echo "Error: api/libmovevm.x86_64.so not found"; \ exit 1; \ fi; \ fiThis will provide a clear error message if the source file is missing, making debugging easier.
Line range hint
1-55
: Overall, these changes enhance the build and test process.The additions to the Makefile improve the reliability of the build and test process by ensuring that necessary library files are present before running tests. This is a good practice that can prevent potential issues during testing and deployment.
Consider applying similar checks for other critical files in the project to further improve robustness. Also, ensure that the error handling suggestion for the
check-libmovevm
target is implemented to make debugging easier in case of missing files.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- Makefile (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
Makefile (1)
54-55
: LGTM! Good improvement to test reliability.The modification to the
test-go
target, making it depend oncheck-libmovevm
, is a good improvement. This ensures that the required library file is present before running Go tests, which can prevent potential test failures due to missing dependencies.
@beer-1 similar problem with |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
Makefile (2)
49-51
: Consider updating the TODO comment with more context.The comment indicates this is a workaround for CodeQL, but it would be helpful to:
- Add more context about why this symlink is necessary
- Document any potential risks or limitations of this approach
- Add a link to any internal tracking issue
47-58
: Consider investigating root cause of CodeQL symlink requirement.While the current implementation works as a workaround, consider:
- Investigating why CodeQL requires these specific library names
- Exploring if the build process can be updated to generate libraries with the expected names directly
- Documenting the findings to help future maintenance
This could help eliminate the need for symlinks and provide a more robust long-term solution.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
.gitignore
(1 hunks)Makefile
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- .gitignore
🔇 Additional comments (3)
Makefile (3)
47-47
: LGTM: Good dependency ordering in test target.
The addition of check-libs
as a prerequisite ensures that necessary library symlinks exist before running tests, preventing potential test failures.
140-142
: LGTM: Proper cleanup in clean target.
The addition of symlink removal commands ensures proper cleanup, and the use of '@-rm' correctly handles cases where files don't exist.
51-58
: 🛠️ Refactor suggestion
Verify target files exist before creating symlinks.
The current implementation creates symlinks without verifying if the target files exist. This could lead to broken symlinks if the build process fails or files are missing.
Consider adding error handling:
check-libs:
- @if [ ! -f api/$(SHARED_LIB_SRC) ]; then \
+ @if [ ! -f api/$(SHARED_LIB_DST) ]; then \
+ echo "Error: Target file api/$(SHARED_LIB_DST) does not exist" >&2; \
+ exit 1; \
+ fi
+ @if [ ! -f api/$(SHARED_LIB_SRC) ]; then \
ln -s api/$(SHARED_LIB_DST) api/$(SHARED_LIB_SRC); \
fi
- @if [ ! -f api/$(COMPILER_SHARED_LIB_SRC) ]; then \
+ @if [ ! -f api/$(COMPILER_SHARED_LIB_DST) ]; then \
+ echo "Error: Target file api/$(COMPILER_SHARED_LIB_DST) does not exist" >&2; \
+ exit 1; \
+ fi
+ @if [ ! -f api/$(COMPILER_SHARED_LIB_SRC) ]; then \
ln -s api/$(COMPILER_SHARED_LIB_DST) api/$(COMPILER_SHARED_LIB_SRC); \
fi
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
tools/generate-bcs-go/src/main.rs (2)
32-35
: Consider adding error handling for tracer initialization.While the setup is clear and well-documented, consider adding error handling for the tracer initialization to make the code more robust.
- let mut tracer = Tracer::new(TracerConfig::default()); + let mut tracer = Tracer::new(TracerConfig::default()) + .map_err(|e| format!("Failed to initialize tracer: {}", e)) + .expect("Tracer initialization failed");
36-55
: Consider organizing type tracing calls into logical groups.While the implementation is correct, consider grouping related types together with comments to improve readability. For example:
// 2. Trace the main entry point(s) + every enum separately. + // Core types tracer.trace_type::<Identifier>(&samples).unwrap(); tracer.trace_type::<TypeTag>(&samples).unwrap(); tracer.trace_type::<ModuleId>(&samples).unwrap(); tracer.trace_type::<ResourceKey>(&samples).unwrap(); + + // Transaction and execution types tracer.trace_type::<StakingDelta>(&samples).unwrap(); tracer.trace_type::<CosmosMessage>(&samples).unwrap(); // ... rest of the types
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
tools/generate-bcs-go/src/main.rs
(2 hunks)
🔇 Additional comments (2)
tools/generate-bcs-go/src/main.rs (2)
4-4
: LGTM: Import change aligns with new tracing implementation.
The addition of Samples
to the imports is necessary for the updated type tracing mechanism.
36-66
: Verify type coverage completeness.
Let's verify that all necessary types are being traced by checking for any imported but untraced types.
✅ Verification successful
Let me verify if these untraced types actually need tracing by checking their usage context.
All necessary types are being traced correctly
The untraced types found in the imports are utility types used for code generation and tracing infrastructure, not data types that need BCS serialization:
current_dir
,File
: Standard Rust I/O utilitiesCodeGenerator
,CodeGeneratorConfig
,Encoding
: Code generation configurationSamples
,Tracer
,TracerConfig
: Reflection infrastructure
The code correctly traces all the actual Move types that require BCS serialization.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any imported types that aren't being traced
# Get all imported types
echo "Checking for imported but untraced types..."
rg -o "use .+::\{.*\}" tools/generate-bcs-go/src/main.rs | \
sed 's/use //g; s/{//g; s/}//g; s/,/\n/g' | \
sed 's/^[ \t]*//' | \
grep -v "^$" > /tmp/imported_types
# Get all traced types
rg "trace_type::<(\w+)>" tools/generate-bcs-go/src/main.rs | \
sed 's/.*trace_type::<\([^>]*\)>.*/\1/' > /tmp/traced_types
# Compare
echo "Types in imports but not traced:"
grep -v -f /tmp/traced_types /tmp/imported_types || true
Length of output: 607
Script:
#!/bin/bash
# Check how these types are used in the code
echo "Checking usage context of potentially untraced types..."
rg -A 2 -B 2 "std::env::current_dir|fs::File|CodeGenerator|CodeGeneratorConfig|Encoding|Samples|Tracer|TracerConfig" tools/generate-bcs-go/src/main.rs
Length of output: 1162
tools/generate-bcs-go/src/main.rs
Outdated
tracer.trace_type::<Identifier>(&samples).unwrap(); | ||
tracer.trace_type::<TypeTag>(&samples).unwrap(); | ||
tracer.trace_type::<ModuleId>(&samples).unwrap(); | ||
tracer.trace_type::<ResourceKey>(&samples).unwrap(); | ||
tracer.trace_type::<StakingDelta>(&samples).unwrap(); | ||
tracer.trace_type::<CosmosMessage>(&samples).unwrap(); | ||
tracer.trace_type::<Account>(&samples).unwrap(); | ||
tracer.trace_type::<GasUsage>(&samples).unwrap(); | ||
tracer.trace_type::<ExecutionResult>(&samples).unwrap(); | ||
tracer.trace_type::<EntryFunction>(&samples).unwrap(); | ||
tracer.trace_type::<ViewFunction>(&samples).unwrap(); | ||
tracer.trace_type::<ViewOutput>(&samples).unwrap(); | ||
tracer.trace_type::<ModuleBundle>(&samples).unwrap(); | ||
tracer.trace_type::<Script>(&samples).unwrap(); | ||
tracer.trace_type::<Env>(&samples).unwrap(); | ||
tracer.trace_type::<TableInfo>(&samples).unwrap(); | ||
tracer.trace_type::<InitiaVMConfig>(&samples).unwrap(); | ||
tracer.trace_type::<CompilerArguments>(&samples).unwrap(); | ||
tracer.trace_type::<CompilerBuildConfig>(&samples).unwrap(); | ||
tracer | ||
.trace_simple_type::<CompilerCoverageBytecodeOptions>() | ||
.trace_type::<CompilerCoverageBytecodeOptions>(&samples) | ||
.unwrap(); | ||
tracer | ||
.trace_simple_type::<CompilerCoverageSourceOptions>() | ||
.trace_type::<CompilerCoverageSourceOptions>(&samples) | ||
.unwrap(); | ||
tracer | ||
.trace_simple_type::<CompilerCoverageSummaryOptions>() | ||
.trace_type::<CompilerCoverageSummaryOptions>(&samples) | ||
.unwrap(); | ||
tracer.trace_simple_type::<CompilerDocgenOptions>().unwrap(); | ||
tracer.trace_simple_type::<CompilerTestOptions>().unwrap(); | ||
tracer.trace_type::<CompilerDocgenOptions>(&samples).unwrap(); | ||
tracer.trace_type::<CompilerTestOptions>(&samples).unwrap(); |
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.
🛠️ Refactor suggestion
Improve error handling in type tracing.
The current implementation uses unwrap()
for error handling. Consider using a more robust error handling approach:
- tracer.trace_type::<Identifier>(&samples).unwrap();
+ tracer.trace_type::<Identifier>(&samples)
+ .map_err(|e| format!("Failed to trace Identifier: {}", e))?;
Also, consider adding a helper function to reduce repetition:
fn trace_type_with_error<T: serde::Serialize + for<'de> serde::Deserialize<'de>>(
tracer: &mut Tracer,
samples: &Samples,
type_name: &str,
) -> Result<(), String> {
tracer
.trace_type::<T>(samples)
.map_err(|e| format!("Failed to trace {}: {}", type_name, e))
}
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
tools/generate-bcs-go/src/main.rs (2)
30-31
: Add documentation for the samples initialization.While the comment explains that samples are for types with custom deserializers, it would be helpful to add more context about how these samples are used in the type tracing process.
// 1. Record samples for types with custom deserializers. +// Samples provide type information to the tracer for proper serialization format detection. +// This is especially important for types that implement custom serialization. let samples = Samples::new();
34-64
: Consider grouping related types for better organization.The type tracing calls could be organized into logical groups with comments explaining each group's purpose. For example:
// 2. Trace the main entry point(s) + every enum separately. +// Core types tracer.trace_type::<TypeTag>(&samples).unwrap(); tracer.trace_type::<ModuleId>(&samples).unwrap(); tracer.trace_type::<ResourceKey>(&samples).unwrap(); + +// Transaction and execution types tracer.trace_type::<StakingDelta>(&samples).unwrap(); tracer.trace_type::<CosmosMessage>(&samples).unwrap(); tracer.trace_type::<Account>(&samples).unwrap(); // ... continue grouping other types ...
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
tools/generate-bcs-go/src/main.rs
(2 hunks)
🔇 Additional comments (2)
tools/generate-bcs-go/src/main.rs (2)
4-4
: LGTM: Import change aligns with new implementation.
The addition of Samples
to the imports is necessary for the updated type tracing implementation.
34-64
: Previous error handling comment is still applicable.
The previous review comment about improving error handling and reducing repetition through a helper function remains valid.
Description
testing codeql failed.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
Summary by CodeRabbit
New Features
.gitignore
file to improve management of build artifacts and shared libraries.Bug Fixes