Skip to content

Return block timestamp in EVM WriteReportReply - #916

Draft
Krish-vemula wants to merge 2 commits into
mainfrom
feat/evm-write-report-block-timestamp
Draft

Krish-vemula wants to merge 2 commits into
mainfrom
feat/evm-write-report-block-timestamp

Conversation

@Krish-vemula

Copy link
Copy Markdown
Contributor

What

EVM WriteReport now fills in WriteReportReply.block_timestamp (microseconds), matching Aptos and Stellar, for SLO tx-latency tracking.

How

  • All reply paths (prior success, invalid receiver, failed with enough gas, new attempt success/revert) go through replyFromReceipt, so the change is made once there.
  • Receipts and logs carry no timestamp. When the feature is active, we call HeaderByNumber(receipt.BlockNumber) (with WithQuickRetry) and return header.Timestamp * 1_000_000.
  • The feature is gated by FeatureEVMWriteReportBlockTimestampActivePeriod, checked against the execution timestamp. This is the same pattern as the L1 fee flag and the Aptos block timestamp flag.

Behaviour

  • Flag off (default): no extra RPC call and the field is not set, so behaviour is unchanged.
  • Header lookup fails, or the header/timestamp is invalid: the field is omitted and an error is logged. The write does not fail, because the tx is already on-chain.
  • Header hash differs from the receipt's block hash (possible reorg): the timestamp is kept and a warning is logged.
  • Large timestamp: the multiply is guarded against overflow.

Testing

  • New TestReplyFromReceiptBlockTimestamp (table-driven) covers: flag on/off, success and revert, header error, empty header, zero timestamp, missing block number, hash mismatch.
  • TestReplyFromReceiptBlockTimestamp_NilLimiterOmitsTimestamp
  • New TestWriteReportBlockTimestamp_FeatureFlagWiring runs the full EVM.WriteReport flow with the limiter built from cresettings defaults.
  • go test ./... -race passes and golangci-lint reports 0 issues (run against local chainlink-common).

Dependencies

  • Depends on chainlink-common #2554. Bump chainlink-common in chain_capabilities/evm/go.mod once it merges.

Rollout

Set FeatureEVMWriteReportBlockTimestampActivePeriod in CRE settings for each environment to enable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant