fix: sim config for triggered txs#1373
Conversation
📝 WalkthroughWalkthroughThe PR propagates simulation configuration metadata through the transaction processing API, simplifies transaction type label rendering by removing contract snapshot-based deployment detection, extends mock response handling to support default values and format-specific transformations, and applies formatting improvements to health check imports. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
b2461c3 to
12b41e4
Compare
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @backend/node/llm.lua:
- Around line 217-234: When mapped_prompt.format == "json" and mock_data.data is
a string, protect the call to lib.rs.json_parse by wrapping it in a safe
error-handling path (e.g., pcall/xpcall) so parse failures do not raise an
unhandled error; on failure set data_value to a safe fallback (nil or the
original string) and surface/log the parse error via your logger (or attach an
error field) so callers of data_value can handle invalid mock JSON gracefully;
update the branch that currently assigns data_value =
lib.rs.json_parse(mock_data.data) to use this guarded parse and fallback
behavior while keeping existing behavior when parsing succeeds.
🧹 Nitpick comments (2)
explorer/src/components/TransactionTypeLabel.tsx (1)
7-45: Clean refactor with improved maintainability.The switch-based approach is cleaner and the backend type documentation is helpful.
Consider using a const enum or object mapping for the transaction types to improve type safety and eliminate magic numbers:
✨ Optional: Type-safe transaction type constants
// Could be defined in a shared types/constants file export const TRANSACTION_TYPES = { SEND: 0, DEPLOY_CONTRACT: 1, RUN_CONTRACT: 2, UPGRADE_CONTRACT: 3, } as const; export type TransactionType = typeof TRANSACTION_TYPES[keyof typeof TRANSACTION_TYPES];This would allow the switch cases to use
TRANSACTION_TYPES.SENDinstead of0, making the code self-documenting and reducing the risk of typos. Low priority since the inline comments already document the mapping.backend/protocol_rpc/health.py (1)
535-535: Consider adding return type hint for consistency.The
metrics()function is missing a return type hint, while other health endpoint functions in this file properly annotate their return types. As per coding guidelines, type hints should be included in all Python code.📝 Suggested addition
-async def metrics(): +async def metrics() -> Response: """Return worker metrics for autoscaling in Prometheus format."""
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
backend/consensus/base.pybackend/node/llm.luabackend/protocol_rpc/health.pyexplorer/src/app/transactions/[hash]/components/OverviewTab.tsxexplorer/src/app/transactions/[hash]/page.tsxexplorer/src/components/TransactionTable.tsxexplorer/src/components/TransactionTypeLabel.tsxexplorer/src/lib/transactionUtils.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use ESLint and Prettier for TypeScript/JavaScript code formatting and linting with strict mode enabled
Files:
explorer/src/app/transactions/[hash]/components/OverviewTab.tsxexplorer/src/lib/transactionUtils.tsexplorer/src/components/TransactionTable.tsxexplorer/src/app/transactions/[hash]/page.tsxexplorer/src/components/TransactionTypeLabel.tsx
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Target Python 3.12, use 4-space indentation, and rely on Black via pre-commit for formatting consistency
**/*.py: Apply Black formatter for Python code formatting
Include type hints in all Python code
Files:
backend/consensus/base.pybackend/protocol_rpc/health.py
backend/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Align backend filenames with their behavior (e.g.,
validators/llm_validator.py) and mirror that pattern in tests
Files:
backend/consensus/base.pybackend/protocol_rpc/health.py
backend/consensus/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
Implement validator rotation using VRF (Verifiable Random Function) in the consensus system
Files:
backend/consensus/base.py
🧠 Learnings (1)
📚 Learning: 2025-08-14T18:56:08.197Z
Learnt from: epsjunior
Repo: genlayerlabs/genlayer-studio PR: 1282
File: frontend/src/hooks/useContractQueries.ts:80-81
Timestamp: 2025-08-14T18:56:08.197Z
Learning: In frontend/src/hooks/useContractQueries.ts, the fetchContractSchema catch block throws error.details directly to maintain existing production behavior. The previous extractErrorMessage helper function was removed to eliminate unused code, but the error handling pattern remains the same as what was working in production.
Applied to files:
explorer/src/app/transactions/[hash]/components/OverviewTab.tsxexplorer/src/lib/transactionUtils.tsexplorer/src/components/TransactionTable.tsxexplorer/src/app/transactions/[hash]/page.tsx
🧬 Code graph analysis (5)
explorer/src/app/transactions/[hash]/components/OverviewTab.tsx (2)
explorer/src/components/InfoRow.tsx (1)
InfoRow(12-24)explorer/src/components/TransactionTypeLabel.tsx (1)
TransactionTypeLabel(7-46)
backend/consensus/base.py (1)
backend/node/types.py (2)
to_dict(147-162)to_dict(202-229)
explorer/src/components/TransactionTable.tsx (1)
explorer/src/components/TransactionTypeLabel.tsx (1)
TransactionTypeLabel(7-46)
explorer/src/app/transactions/[hash]/page.tsx (4)
explorer/src/components/TransactionTable.tsx (1)
TransactionTypeLabel(221-221)explorer/src/components/TransactionTypeLabel.tsx (1)
TransactionTypeLabel(7-46)explorer/src/components/index.ts (1)
TransactionTypeLabel(11-11)hardhat/scripts/restore.js (1)
tx(82-82)
explorer/src/components/TransactionTypeLabel.tsx (2)
explorer/src/components/TransactionTable.tsx (1)
TransactionTypeLabel(221-221)explorer/src/components/index.ts (1)
TransactionTypeLabel(11-11)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: backend-unit-tests
🔇 Additional comments (8)
explorer/src/lib/transactionUtils.ts (1)
1-1: LGTM!The import cleanup is correct—removing
NewConsensusHistoryalong with the deletedisContractDeployfunction keeps the imports minimal and aligned with actual usage.explorer/src/components/TransactionTable.tsx (1)
123-123: LGTM!The updated prop usage is consistent with the refactored
TransactionTypeLabelAPI, which now relies solely on the backend-providedtypefield for rendering the appropriate label.explorer/src/app/transactions/[hash]/page.tsx (1)
115-115: LGTM!Consistent with the
TransactionTypeLabelAPI update across the codebase.explorer/src/app/transactions/[hash]/components/OverviewTab.tsx (1)
24-24: LGTM!The simplified
TransactionTypeLabelusage is consistent with the broader refactor.backend/node/llm.lua (1)
47-65: LGTM! Default mock response implementation is clean.The use of an empty string key as a sentinel for the default value is a reasonable convention. The logic correctly prioritizes specific matches over the default fallback.
backend/consensus/base.py (1)
3762-3766: LGTM! Correctly propagates sim_config to triggered transactions.This change properly inherits the simulation configuration for child transactions, enabling mocking capabilities for contract-to-contract calls in localnet. The pattern is consistent with how other configuration values (like
leader_only,num_of_initial_validators,config_rotation_rounds) are cascaded. TheTransactionsProcessor.insert_transactionmethod correctly accepts thesim_configparameter.backend/protocol_rpc/health.py (2)
540-545: LGTM! Import reformatting improves readability.The multi-line import format aligns with Black's formatting conventions and improves code readability.
566-568: LGTM! Calculation reformatting improves readability.The multi-line format makes the autoscaling logic clearer while preserving the semantic meaning.
|
Added to #1377 |


Fixes DXP-729
What
Why
Testing done
Decisions made
Checks
Reviewing tips
User facing release notes
Summary by CodeRabbit
Release Notes
Bug Fixes
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.