Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/cli/src/evm_hypersync_source/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub struct ClientConfig {
pub url: String,
pub api_token: String,
pub http_req_timeout_millis: Option<i64>,
/// Defaults to no retries — see the `From` impl.
pub max_num_retries: Option<i64>,
pub retry_backoff_ms: Option<i64>,
pub retry_base_ms: Option<i64>,
Expand Down Expand Up @@ -39,10 +40,15 @@ impl From<ClientConfig> for hypersync_client::ClientConfig {
.http_req_timeout_millis
.filter(|v| *v >= 0)
.map_or(Cfg::default_http_req_timeout_millis(), |v| v as u64),
// Retries belong to the indexer, not the binary client. Every
// failure the client would swallow — a rate limit above all — has
// to reach SourceManager, which backs off, surfaces the throttling
// in the TUI and can fail over to another source; none of that can
// happen while a retry loop sleeps inside a single napi call.
max_num_retries: config
.max_num_retries
.filter(|v| *v >= 0)
.map_or(Cfg::default_max_num_retries(), |v| v as usize),
.and_then(|v| usize::try_from(v).ok())
.unwrap_or(0),
retry_backoff_ms: config
.retry_backoff_ms
.filter(|v| *v >= 0)
Expand Down
1 change: 0 additions & 1 deletion packages/envio/src/Ecosystem.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type t = {
blockNumberName: string,
blockTimestampName: string,
blockHashName: string,
cleanUpRawEventFieldsInPlace: JSON.t => unit,
/** Method name that the block handler is exposed under on the public
`indexer` object — `"onBlock"` for chain-based ecosystems, `"onSlot"`
for SVM. Centralised here so adding a new ecosystem only requires a
Expand Down
50 changes: 3 additions & 47 deletions packages/envio/src/EventUtils.res
Original file line number Diff line number Diff line change
@@ -1,54 +1,10 @@
// type eventIndex = {
// blockNumber: int,
// logIndex: int,
// }
//

// takes blockNumber, logIndex and packs them into a number with
//32 bits, 16 bits and 16 bits respectively
// Packs blockNumber and logIndex into one number: 32 bits and 16 bits
// respectively. EVM only — it is the `raw_events.event_id` primary value, and
// no other ecosystem writes that table.
let packEventIndex = (~blockNumber, ~logIndex) => {
let blockNumber = blockNumber->BigInt.fromInt
let logIndex = logIndex->BigInt.fromInt
let blockNumber = BigInt.shiftLeft(blockNumber, 16->BigInt.fromInt)

blockNumber->BigInt.bitwiseOr(logIndex)
}

// //Currently not used but keeping in utils
// //using @live flag for dead code analyser
// @live
// let packMultiChainEventIndex = (~timestamp, ~chainId, ~blockNumber, ~logIndex) => {
// let timestamp = timestamp->BigInt.fromInt
// let chainId = chainId->BigInt.fromInt
// let blockNumber = blockNumber->BigInt.fromInt
// let logIndex = logIndex->BigInt.fromInt

// let timestamp = BigInt.shiftLeft(timestamp, 48->BigInt.fromInt)
// let chainId = BigInt.shiftLeft(chainId, 16->BigInt.fromInt)
// let blockNumber = BigInt.shiftLeft(blockNumber, 16->BigInt.fromInt)

// timestamp
// ->BigInt.bitwiseOr(chainId)
// ->BigInt.bitwiseOr(blockNumber)
// ->BigInt.bitwiseOr(logIndex)
// }

// //Currently not used but keeping in utils
// //using @live flag for dead code analyser
// @live
// let unpackEventIndex = (packedEventIndex: bigint) => {
// let blockNumber = packedEventIndex->BigInt.shiftRight(16->BigInt.fromInt)
// let logIndexMask = 65535->BigInt.fromInt
// let logIndex = packedEventIndex->BigInt.bitwiseAnd(logIndexMask)
// {
// blockNumber: blockNumber->BigInt.toString->Int.fromString->Option.getUnsafe,
// logIndex: logIndex->BigInt.toString->Int.fromString->Option.getUnsafe,
// }
// }

// //takes an eventIndex record and returnts a packed event index
// //used in TS tests
// @live
// let packEventIndexFromRecord = (eventIndex: eventIndex) => {
// packEventIndex(~blockNumber=eventIndex.blockNumber, ~logIndex=eventIndex.logIndex)
// }
1 change: 0 additions & 1 deletion packages/envio/src/sources/Evm.res
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ let make = (~logger: Pino.t): Ecosystem.t => {
blockNumberName: "number",
blockTimestampName: "timestamp",
blockHashName: "hash",
cleanUpRawEventFieldsInPlace,
onBlockMethodName: "onBlock",
// EVM filter shape: `{block: {number: {_gte?, _lte?, _every?}}}`.
// The inner range chunk is returned as raw `S.unknown` and parsed a
Expand Down
1 change: 0 additions & 1 deletion packages/envio/src/sources/Fuel.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ let make = (~logger: Pino.t): Ecosystem.t => {
blockNumberName: "height",
blockTimestampName: "time",
blockHashName: "id",
cleanUpRawEventFieldsInPlace,
onBlockMethodName: "onBlock",
// Fuel filter shape: `{block: {height: {_gte?, _lte?, _every?}}}`.
// Inner range chunk parsed by `blockRangeSchema` in `Main.res`.
Expand Down
3 changes: 0 additions & 3 deletions packages/envio/src/sources/HyperSyncClient.res
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type cfg = {
/** Milliseconds to wait for a response before timing out. Default: 30000. */
httpReqTimeoutMillis?: int,
/** Number of retries to attempt before returning error. Default: 12. */
maxNumRetries?: int,
/** Milliseconds that would be used for retry backoff increasing. Default: 500. */
retryBackoffMs?: int,
/** Initial wait time for request backoff. Default: 200. */
Expand Down Expand Up @@ -347,8 +346,6 @@ let make = (
enableChecksumAddresses,
apiToken,
httpReqTimeoutMillis,
// Retries are handled internally by the indexer, not the binary client
maxNumRetries: 0,
?serializationFormat,
?enableQueryCaching,
?retryBaseMs,
Expand Down
7 changes: 0 additions & 7 deletions packages/envio/src/sources/Svm.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
let cleanUpRawEventFieldsInPlace: JSON.t => unit = %raw(`fields => {
delete fields.hash
delete fields.height
delete fields.time
}`)

// Ordered transaction field names, the field codes shared with the Rust store
// (`SvmTxField`). Derived from the typed field list so the two can't drift;
// `Internal.allSvmTransactionFields` is pinned to the Rust ordinal order by a test.
Expand Down Expand Up @@ -32,7 +26,6 @@ let make = (~logger: Pino.t): Ecosystem.t => {
blockNumberName: "height",
blockTimestampName: "time",
blockHashName: "hash",
cleanUpRawEventFieldsInPlace,
onBlockMethodName: "onSlot",
// SVM filter shape: `{slot: {_gte?, _lte?, _every?}}`.
// Inner range chunk parsed by `blockRangeSchema` in `Main.res`.
Expand Down
150 changes: 0 additions & 150 deletions scenarios/test_codegen/test/integration-raw-events.test.ts

This file was deleted.