Repository navigation
fix(node): use timezone-aware datetime in deploy_contract fallback - #1776
Alicepoltora wants to merge 2 commits into
Conversation
…e-aware datetime.now(timezone.utc)
datetime.utcnow() was removed in Python 3.12 and returned a naive datetime
(no timezone). _format_created_at() should emit ISO 8601 strings that carry
timezone info (+00:00) so the upstream metrics API can parse the offset
consistently with the rest of Studio.
The change replaces:
datetime.utcnow().isoformat()
with:
datetime.now(timezone.utc).isoformat()
Regression tests verify the returned string contains a timezone offset.
_node.deploy_contract() uses _date_from_str(transaction_created_at) to parse the override timestamp, and when that returns None falls back to datetime.datetime.now(). datetime.datetime.now() returns a **naive** datetime (no timezone). _run_genvm() asserts before sending the datetime to the GenVM host, so the naive fallback would trigger an AssertionError as soon as any deploy request omits a sim_config.genvm_datetime override. Replace datetime.datetime.now() with datetime.datetime.now(tz=datetime.timezone.utc) so the fallback always carries a +00:00 offset. A regression test verifies the path passes a tz-aware datetime into _run_genvm even when transaction_created_at is None.
|
This PR targeted I retargeted it to |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Problem
deploy_contract()inbackend/node/base.pyparsestransaction_created_atvia_date_from_str(). When that returnsNone(the common case when the caller does not supply asim_config.genvm_datetimeoverride), it falls back todatetime.datetime.now()— a naive datetime with no timezone._run_genvm()(called immediately after) assertstransaction_datetime.tzinfo is not Nonebefore sending the datetime to the GenVM host. The naive fallback therefore triggers anAssertionErroron anyeth_sendRawTransaction/ deploy request that does not include asim_configwith agenvm_datetimeoverride.Fix
Replace
datetime.datetime.now()withdatetime.datetime.now(tz=datetime.timezone.utc)so the fallback always carries a+00:00offset.Tests
tests/unit/test_leader_llm_recovery.py:test_deploy_contract_fallback_is_timezone_aware— passes a tz-aware datetime into_run_genvmeven whentransaction_created_atisNone. Regression fails on naive-datetime code path.Summary by CodeRabbit