-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Improve terminal logs #1283
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
base: main
Are you sure you want to change the base?
Conversation
This commit addresses several issues related to transaction processing and logging within the system. - It prevents errors when updating transaction statuses or consensus data after snapshot restores by skipping updates for non-existent transactions. - It enhances nonce handling by fetching the actual nonce from Hardhat, ensuring synchronization with the blockchain. If not connected it falls back to existing method. - It improves error handling during transaction forwarding, raising exceptions for nonce errors. - It truncates large transaction fields and contract states in logs (calldata, contract_code, state) unless in DEBUG mode, reducing log size and improving readability. - It updates gas estimation to use zkSync Era's gas limit and updates hardhat config to be the same. - It ensures LLM and Web modules are shutdown correctly and gracefully. - It updates the models to use the latest versions of openai, google, xai, anthropic and heuristai.
This commit addresses several issues related to transaction processing and overall system stability: - Enhances transaction count retrieval by normalizing addresses, fetching from RPC with pending state, and gracefully falling back to the database. Includes error handling for RPC connection issues. - Prevents errors when updating appeal processing time by checking for null `timestamp_appeal` values. - Implements more robust process termination for LLM and Web modules, ensuring cleanup and preventing resource leaks. - Adds custom exception classes for nonce errors in the Consensus Service, improving error handling and reporting. - Expands allowed LLM models in provider schemas. These changes improve the reliability and accuracy of transaction-related operations and enhance the system's resilience to external factors.
This commit adds support for forwarding Ethereum-related methods (eth_*) within batch JSON-RPC requests to a Hardhat instance. Previously, batch requests containing eth_ methods were not handled correctly. This change ensures that such requests are forwarded to Hardhat for processing. Non-eth_ methods within batch requests are handled by Flask-JSONRPC. This allows interaction with Hardhat using batch requests. Error handling is also implemented, now if forwarding to Hardhat fails, an error response is returned to the client.
Removes deprecated and unused provider configurations to streamline the available options. Updates the RPC endpoint generator to improve handling of batch requests, including more robust error handling and logging, and ensures that requests are correctly forwarded to Hardhat when appropriate and not handled locally. Also includes bug fixes for nonce checking in consensus service Adds unit tests for batch request handling, consensus service nonce exceptions, and transaction processor improvements BREAKING CHANGE: Removes heuristai_mistralaimixtral-8x22b-instruct, xai_grok-3-mini, and xai_grok-4-0709 providers
WalkthroughAdds a comprehensive decoding pipeline to MessageHandler for logs, including base64/GenVM/context-aware decoding, JSON-aware traversal, and serialization safeguards. Updates truncation to operate post-decoding with a higher limit. Introduces numerous private helpers. Adds extensive unit tests covering edge cases, nested structures, and JSON-serializable outputs. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Logger/Emitter
participant MH as MessageHandler
participant Dec as _decode_value
participant Key as _decode_by_key/_decode_bytes_by_key
participant JSON as _try_decode_json_with_data_fields
participant GV as _try_decode_as_genvm
participant TXT as _try_decode_as_text
participant FB as _fallback_encoding
Caller->>MH: handle_log(data)
MH->>Dec: _decode_value(data)
Dec->>Dec: recurse(dicts/lists)
Dec->>Key: apply key/context rules
alt JSON string with data fields
Dec->>JSON: parse and decode embedded data
JSON-->>Dec: decoded object/string
end
alt bytes-like content
Key->>GV: try GenVM decode
GV-->>Key: success/failure
opt not GenVM / unreadable
Key->>TXT: try text decode
TXT-->>Key: readable text or None
alt no readable text
Key->>FB: hex/base64 fallback
FB-->>Key: encoded string
end
end
end
Dec-->>MH: decoded structure
MH->>MH: _apply_log_level_truncation(max_length=200)
MH-->>Caller: truncated, decoded log
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
graph TD
A["_log_message()<br/>(line 66)"] --> B["_apply_log_level_truncation()<br/>(line 340)"]
B --> C["_decode_value()<br/>(line 97)"]
B --> D["_convert_non_serializable_objects()<br/>(line 316)"]
C --> E["_decode_by_key()<br/>(line 126)"]
C --> F["_try_decode_json_with_data_fields()<br/>(line 267)"]
E --> G["_decode_bytes_by_key()<br/>(line 134)"]
F --> H["_decode_json_data_fields()<br/>(line 282)"]
G --> I["_decode_storage_slot()<br/>(line 205)"]
G --> J["_is_storage_slot_key()<br/>(line 188)"]
I --> K["_try_decode_as_genvm()<br/>(line 222)"]
I --> L["_try_decode_as_text()<br/>(line 241)"]
I --> M["_fallback_encoding()<br/>(line 249)"]
L --> N["_is_readable_text()<br/>(line 256)"]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#fff3e0
style D fill:#fff3e0
|


Fixes #DXP-465
What
MessageHandlerclass._apply_log_level_truncationto include decoding logic for better log readability.Why
To add more value to the user by making the logs readable.
Testing done
Decisions made
Decided to only decode the contract code inside the contract state. The contract variables are not decoded because we need to know the mapping of the state variable to a hashed key and then know the type from the contract code to successfully decode it (e.g. is it a signed or unsigned int). If needed we can do this in another PR.
Checks
Reviewing tips
User facing release notes
Added data decoding in logging for better readability and debugging.
Summary by CodeRabbit
New Features
Bug Fixes
Tests