Skip to content

feat(rpc): add tempo_simulateV1 with TIP-20 token metadata enrichment#3449

Open
decofe wants to merge 7 commits intomainfrom
georgios/tempo-simulate-v1
Open

feat(rpc): add tempo_simulateV1 with TIP-20 token metadata enrichment#3449
decofe wants to merge 7 commits intomainfrom
georgios/tempo-simulate-v1

Conversation

@decofe
Copy link
Copy Markdown
Member

@decofe decofe commented Apr 3, 2026

Adds tempo_simulateV1 RPC method that wraps eth_simulateV1 and enriches the response with TIP-20 token metadata (name, symbol, decimals, currency) for all tokens appearing in Transfer event logs. This eliminates the second roundtrip the wallet app needs to fetch token symbols/decimals after simulation.

The wallet currently calls eth_simulateV1 with traceTransfers: true to get balance diffs as synthetic Transfer logs, then makes separate calls for each token's metadata. tempo_simulateV1 returns both in a single response:

{
  "blocks": [ /* standard eth_simulateV1 blocks */ ],
  "tokenMetadata": {
    "0x20c0...": {
      "name": "Path USD",
      "symbol": "pUSD",
      "decimals": 6,
      "currency": "USD"
    }
  }
}

Callable from viem as client.request({ method: 'tempo_simulateV1', params: [...] }).

Prompted by: georgios

Adds `tempo_simulateV1` RPC method that wraps standard `eth_simulateV1`
and enriches the response with TIP-20 token metadata (name, symbol,
decimals, currency) for all tokens appearing in Transfer event logs.
Eliminates the second roundtrip the wallet needs to fetch token info
after simulation.

Co-authored-by: Georgios Konstantopoulos <17802178+gakonst@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d5428-5f7d-7428-ad0e-ab26a32589b2
decofe and others added 2 commits April 3, 2026 18:53
Pre-extract TIP-20 addresses from request call targets and resolve
metadata concurrently with the simulation via tokio::join!. Only
tokens that appear in simulation logs but weren't in the prefetched
set trigger a second (small) metadata lookup.

Co-Authored-By: Georgios Konstantopoulos <17802178+gakonst@users.noreply.github.com>
Decimals are always 6 for TIP-20 tokens — no need to read from storage.

Co-Authored-By: Georgios Konstantopoulos <17802178+gakonst@users.noreply.github.com>
Comment on lines +70 to +72
pub struct TempoSimulate<EthApi> {
eth_api: EthApi,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider using a cache since TIP20 metadata is immutable and most calls will likely target set of frequently used tokens. Just a note for the future we can do this in a follow-on PR.

decofe and others added 2 commits April 3, 2026 19:53
- Use tempo_contracts::precompiles::DECIMALS instead of local const
- Move decimals to top-level response (constant across all TIP-20 tokens)
- Use HashSet for extra token addresses instead of Vec + sort/dedup

Co-Authored-By: 0xKitsune <77890308+0xKitsune@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d54e7-2118-72eb-aa66-24969aad6efc
tempo-contracts was only in dev-dependencies — moved to dependencies
so tempo_contracts::precompiles::DECIMALS resolves. Merged duplicate
reth_provider imports for nightly fmt.

Co-authored-by: 0xKitsune <77890308+0xKitsune@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d54e7-2118-72eb-aa66-24969aad6efc
Comment on lines +50 to +51
#[serde(with = "alloy_serde::quantity")]
pub decimals: u8,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to include decimals if this is always 6 decimals for all TIP20s?

Uses state_at_block_id_or_latest(block) instead of latest_state() so
token metadata is read from the same block the simulation targets.
Derives hardfork spec from the target block's timestamp instead of
u64::MAX.

Co-authored-by: 0xKitsune <77890308+0xKitsune@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d54e7-2118-72eb-aa66-24969aad6efc
Copy link
Copy Markdown
Contributor

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for obtaining

   "0x20c0...": {
      "name": "Path USD",
      "symbol": "pUSD",
      "decimals": 6,
      "currency": "USD"
    }

this doesnt really make a lot of sense imo, because all of these are immutable, so it would make more sense to cache these client side imo

let token = TempoToken::new(eth_api.clone());
let eth_ext = TempoEthExt::new(eth_api);
let eth_ext = TempoEthExt::new(eth_api.clone());
let simulate = TempoSimulate::new(eth_api);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we probably want this to not be enabled by default? same for token namespace and eth_ext

@gakonst
Copy link
Copy Markdown
Contributor

gakonst commented Apr 4, 2026

Can we figure out a way to merge this in with or without cache by Monday EOD? Impacts wallet performance, I understand the concern that we should just cache it if u guys can take it over

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.

5 participants