{"record":{"id":"1541b075a3d50c51","repo":"nautechsystems/nautilus_trader","slug":"a-backtestnode-is-required-for-the-bars-with-fills","errorCode":null,"errorMessage":"A BacktestNode is required for the bars_with_fills chart","messagePattern":"A BacktestNode is required for the bars_with_fills chart","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/nautilus_trader/analysis/tearsheet.py","lineNumber":514,"sourceCode":"    def generate_fills_report(self) -> pd.DataFrame:\n        return self._node.generate_fills_report(self._run_config_id)\n\n\ndef _create_tearsheet_from_result(\n    result: BacktestResult,\n    node: BacktestNode | None,\n    run_config_id: str | None,\n    currency: Currency | None,\n    output_path: str | None,\n    title: str,\n    config: TearsheetConfig | None,\n    benchmark_returns: pd.Series | None,\n    benchmark_name: str,\n) -> str | None:\n    resolved_run_config_id = run_config_id or result.run_config_id\n    needs_engine = config is not None and \"bars_with_fills\" in config.chart_names\n    if needs_engine and node is None:\n        raise ValueError(\"A BacktestNode is required for the bars_with_fills chart\")\n    if node is not None and resolved_run_config_id is None:\n        raise ValueError(\"run_config_id is required when a BacktestNode is provided\")\n    if node is not None and resolved_run_config_id is not None:\n        _validate_result_node_state(node, resolved_run_config_id)\n\n    engine_view = (\n        _BacktestNodeEngineView(node, resolved_run_config_id)\n        if node is not None and resolved_run_config_id is not None\n        else None\n    )\n    returns = _result_returns_series(result)\n    run_info = _result_run_info(result)\n    account_info = _result_account_info(result, node, resolved_run_config_id, currency)\n\n    if title == \"NautilusTrader Backtest Results\":\n        run_started = _format_optional_iso8601(result.run_started)\n        title = f\"<b>NautilusTrader</b> v{NAUTILUS_VERSION} - Backtest Results\"\n        title += f\"<br><sub>Run started: {run_started}</sub>\"","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/python/nautilus_trader/analysis/tearsheet.py#L496-L532","documentation":"Thrown when the proxy entry's `target_code_hash` fails `B256::from_str`, i.e. it is not a valid 32-byte hex string. This hash pins the expected runtime bytecode of the implementation contract behind the proxy.","triggerScenarios":"Manifest validation (verification.rs:1298) parses a proxy whose `target_code_hash` is malformed — wrong length, non-hex characters, empty string, or a value of a different hash type/length.","commonSituations":"Copying the proxy's own code hash instead of the implementation's; pasting a truncated keccak256 output; leaving the field empty in a template proxy entry; using a hash computed from creation bytecode rather than deployed runtime code.","solutions":["Set `target_code_hash` to the full 0x + 64-hex-char keccak256 hash of the implementation contract's deployed runtime bytecode.","Compute the hash from eth_getCode(target_address) if the compiled artifact is unavailable.","Ensure the hash corresponds to the same implementation version that target_address points to."],"exampleFix":"// before (manifest.json)\n\"target_code_hash\": \"0xabc123\"\n// after (manifest.json)\n\"target_code_hash\": \"0x7c2e487a1f3d...\" // 64 hex chars, keccak256 of implementation runtime code","handlingStrategy":"validation","validationCode":"fn valid_b256(s: &str) -> bool { use alloy_primitives::B256; s.len() == 66 && B256::from_str(s).is_ok() } // apply to proxy.target_code_hash","typeGuard":"fn parse_target_hash(s: &str) -> Option<B256> { use alloy_primitives::B256; B256::from_str(s).ok() }","tryCatchPattern":"let target_hash = B256::from_str(&proxy.target_code_hash).map_err(|_| anyhow!(\"invalid target_code_hash for {}\", proxy.target_address))?;","preventionTips":["Hash the implementation's deployed runtime code (eth_getCode), not creation bytecode","Copy the hash programmatically from build artifacts","Recompute the hash whenever the implementation is redeployed"],"tags":["validation","manifest","proxy","hash","hex-parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}