Skip to content

Conversation

@Troublor
Copy link
Collaborator

Summary

Add the oracle hint mechanism for Rex2, enabling on-chain contracts to signal the off-chain oracle service about upcoming data needs.

Changes

  • Add sendHint(bytes32 topic, bytes data) function to Oracle contract (v1.1.0)
  • Add Hint(bytes32 indexed topic, bytes data) event for signaling oracle service
  • Add on_hint callback to OracleEnv trait for receiving hints
  • Intercept Hint events in EVM host and decode ABI-encoded bytes data
  • Deploy v1.1.0 oracle bytecode on Rex2 activation (upgrade from v1.0.0)
  • Add comprehensive tests for the hint mechanism

How It Works

  1. Contracts call Oracle.sendHint(topic, data) to emit a Hint event
  2. The EVM intercepts these events from the oracle contract address
  3. The hint is forwarded to the oracle service via OracleEnv::on_hint
  4. The oracle service can use hints to prefetch or prepare data before it's requested

Test plan

  • test_on_hint_called_on_rex2 - verifies hints work on Rex2
  • test_on_hint_not_called_on_rex1 - verifies hints don't trigger pre-Rex2
  • test_on_hint_not_called_for_non_oracle_contract - verifies only oracle contract triggers hints
  • test_multiple_hints_recorded - verifies multiple hints in one tx
  • test_on_hint_direct_oracle_call - verifies direct calls to oracle work

Add support for the oracle hint mechanism in Rex2:

- Add `sendHint(bytes32 topic, bytes data)` function to Oracle contract (v1.1.0)
- Add `Hint(bytes32 indexed topic, bytes data)` event for signaling oracle service
- Add `on_hint` callback to `OracleEnv` trait for receiving hints
- Intercept Hint events in EVM host and decode ABI-encoded bytes data
- Deploy v1.1.0 oracle bytecode on Rex2 activation (upgrade from v1.0.0)
- Add comprehensive tests for the hint mechanism
@Troublor Troublor changed the title feat: add Rex2 oracle hint mechanism feat: add oracle hint mechanism in Rex2 spec Dec 22, 2025
Update the Hint event from Hint(bytes32 indexed topic, bytes data) to
Hint(address indexed from, bytes32 indexed topic, bytes data).

The 'from' address captures msg.sender, enabling off-chain access control
since it cannot be faked. On-chain access control can be enforced in a
periphery contract which directly calls sendHint.

Changes:
- Oracle.sol: Add indexed 'from' parameter to Hint event
- OracleEnv::on_hint: Add 'from' parameter to trait method
- Host::log: Extract 'from' from topics[1], topic from topics[2]
- Update bytecode, code hash, and event signature hash constants
- Update all related tests
@Troublor Troublor marked this pull request as draft December 23, 2025 09:40
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.

3 participants