fix(data): send NEAR view calls to their own endpoints

The node the scan will follow tracks only intents.near's shard, and the token
contracts it asks about — qtc.omft.near for supply, every counter token for
ft_metadata — live on other shards, which such a node cannot answer for.
Views are a few an hour, so they go to `view_urls`, FastNEAR by default, and
the per-block reads stay on `rpc_urls`.

Refs #27

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pkwBsR54NRmZyU4QVhvfj
This commit is contained in:
2026-10-03 11:30:35 +03:00
co-authored by Claude Opus 5.5
parent 49f4d4b69b
commit 6279b8fcf7
4 changed files with 29 additions and 5 deletions
+4 -1
View File
@@ -138,7 +138,10 @@ max_gap_fill_blocks = 5000
# `start_height` is how far back the backfill walks. Nothing can trade before the
# token holds any supply on NEAR, and on 2026-10-03 `qtc.omft.near` held none, so
# the height at which this is first enabled is a sound floor while that stays
# true. `rpc_urls` should name our node; the archive covers anything older.
# true. `rpc_urls` should name our node; the archive covers anything older, and
# view calls (supply, metadata) stay on FastNEAR via the `view_urls` default,
# because a node tracking only intents.near's shard cannot answer for the token
# contracts, which live on others.
# Enabling it also means deleting the assertion in config.rs's
# `the_committed_config_parses_and_leaves_intents_off`.
#
+10 -1
View File
@@ -217,6 +217,12 @@ pub struct IntentsConfig {
/// Archival NEAR JSON-RPC endpoints, for anything older.
#[serde(default = "default_near_archive")]
pub archive_urls: Vec<String>,
/// Endpoints for view calls — token supply, balances, metadata. Separate
/// from `rpc_urls` because a node tracking one shard cannot answer for an
/// account on another, and the token contracts mostly are. A few calls an
/// hour, so a public endpoint's rate limit is no constraint.
#[serde(default = "default_near_rpc")]
pub view_urls: Vec<String>,
/// 1Click's API, read only for whether it lists the asset. Never for a
/// price: a quote is an offer, not a trade.
#[serde(default = "default_oneclick")]
@@ -365,7 +371,10 @@ impl Config {
intents.asset
);
}
if intents.rpc_urls.is_empty() || intents.archive_urls.is_empty() {
if intents.rpc_urls.is_empty()
|| intents.archive_urls.is_empty()
|| intents.view_urls.is_empty()
{
anyhow::bail!(
"chain `{}` tracks intents but names no NEAR rpc or archive endpoint",
chain.id
+1
View File
@@ -68,6 +68,7 @@ pub fn spawn(chain: Arc<ChainRuntime>, store: Store) {
let near = match NearClient::new(
config.rpc_urls.clone(),
config.archive_urls.clone(),
config.view_urls.clone(),
NEAR_TIMEOUT,
) {
Ok(n) => n,
+14 -3
View File
@@ -82,11 +82,19 @@ pub struct ShardLayout {
pub shard_ids: Vec<u64>,
}
/// Live and archival NEAR endpoints.
/// Live, archival and view NEAR endpoints.
///
/// Three, because they are three different questions. The live endpoint follows
/// one shard and may be our own node tracking nothing else; the archive holds
/// what the live one has dropped; and a view call is about whichever account it
/// names, which on a one-shard node is usually on a shard it does not hold —
/// `qtc.omft.near` is not on `intents.near`'s. Views are a handful an hour, so a
/// throttled public endpoint serves them comfortably.
#[derive(Debug, Clone)]
pub struct NearClient {
live: RpcClient,
archive: RpcClient,
views: RpcClient,
}
/// What a NEAR node calls "I have no such block", in its error's `cause.name`.
@@ -103,15 +111,18 @@ fn unknown(e: &DataError) -> bool {
}
impl NearClient {
/// A client over `live` endpoints, falling back to `archive` ones.
/// A client over `live` endpoints, falling back to `archive` ones, with
/// view calls sent to `views`.
pub fn new(
live: Vec<String>,
archive: Vec<String>,
views: Vec<String>,
timeout: Duration,
) -> Result<Self, DataError> {
Ok(Self {
live: RpcClient::with_endpoints(live, timeout)?,
archive: RpcClient::with_endpoints(archive, timeout)?,
views: RpcClient::with_endpoints(views, timeout)?,
})
}
@@ -274,7 +285,7 @@ impl NearClient {
) -> Result<Value, DataError> {
use base64::Engine as _;
let result = self
.live
.views
.call(
"query",
json!({