From c56ee242dad69f9db07b48653b8904e0fd8fea79 Mon Sep 17 00:00:00 2001 From: jahabeebs <47253537+jahabeebs@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:08:34 -0500 Subject: [PATCH 1/3] chore: blocknumber readme --- apps/agent/README.md | 2 +- packages/blocknumber/README.md | 58 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 packages/blocknumber/README.md diff --git a/apps/agent/README.md b/apps/agent/README.md index 0c01385b..54b1b929 100644 --- a/apps/agent/README.md +++ b/apps/agent/README.md @@ -97,6 +97,6 @@ pnpm run test:cov ### End-to-End Testing -The e2e tests simulate scenarios starting at the contract level and extending to the agent, like processing requests and handling disputes. For detailed test scenarios, refer to the files in `test/e2e/scenarios`. +The e2e tests simulate scenarios starting at the contract level and extending to the agent, like processing requests and handling disputes. For detailed test scenarios, refer to the refer to the fies in [test/e2e/scenarios](./test/e2e/scenarios). TODO: Add instructions on running e2e tests diff --git a/packages/blocknumber/README.md b/packages/blocknumber/README.md new file mode 100644 index 00000000..d030b873 --- /dev/null +++ b/packages/blocknumber/README.md @@ -0,0 +1,58 @@ +# ebo-agent: blocknumber package + +The `blocknumber` package in `ebo-agent` provides services for retrieving block numbers based on timestamps across different blockchains. This package includes two main providers for accurate, efficient block number resolution: + +1. **EVM Block Number Provider**: Uses a binary search approach optimized to interact with EVM-compatible chains through direct RPC calls. +2. **Blockmeta JSON Block Number Provider**: Utilizes The Graph's Blockmeta service to retrieve block numbers with precision for specific timestamps, using HTTP requests instead of classic RPC calls. + +## Available Scripts + +Available scripts that can be run using `pnpm`: + +| Script | Description | +| ------------ | ------------------------------------------------------- | +| `build` | Build the library | +| `lint` | Run ESLint to check for coding standards | +| `lint:fix` | Run linter and automatically fix code formatting issues | +| `format` | Check code formatting and style using Prettier | +| `format:fix` | Run formatter and automatically fix issues | +| `test` | Run unit tests using Vitest | +| `coverage` | Run tests with coverage report | + +## Usage + +The `blocknumber` package provides utilities for retrieving block numbers based on specific timestamps. Import the required classes as shown below: + +## API + +The primary services available within the `blocknumber` package are the following: + +### [BlockNumberService](./src/services/blockNumberService.ts) + +Handles the interactions with chains specified in the configuration, using the appropriate block number provider based on the chain type (EVM or Blockmeta). + +#### Available Methods + +- **getEpochBlockNumber**(timestamp: UnixTimestamp, chainId: Caip2ChainId): Promise + - Retrieves the block number corresponding to a given timestamp for a specified chain. +- **getEpochBlockNumbers**(timestamp: UnixTimestamp, chains: Caip2ChainId[]): Promise> + - Retrieves the block numbers for a list of chains based on a single timestamp. + +### [EvmBlockNumberProvider](./src/providers/evmBlockNumberProvider.ts) + +Uses a binary search algorithm on EVM-compatible chains to find the block corresponding to a timestamp. + +#### Highlights + +- **Optimized binary search**: Reduces search space with estimated bounds. +- **Direct RPC calls**: Interacts directly with chain nodes to fetch data. +- **Configuration**: Includes customizable settings for blocks lookback and delta multipliers for efficient block time estimation. + +### [BlockmetaJsonBlockNumberProvider](./src/providers/blockmetaJsonBlockNumberProvider.ts) + +Fetches blocks based on timestamps using the Blockmeta service from The Graph, by passing the timestamp to the service via HTTP requests. + +#### Highlights + +- **HTTP integration with Blockmeta**: Queries Blockmeta endpoints for timestamp-based block resolution. +- **Bearer token validation**: Ensures token validity with expiration checks and logging for token refresh reminders. From f3a5e9420b12cbbb53191ec0ce877e40b264ee69 Mon Sep 17 00:00:00 2001 From: jahabeebs <47253537+jahabeebs@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:09:59 -0500 Subject: [PATCH 2/3] fix: typo --- apps/agent/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/agent/README.md b/apps/agent/README.md index 54b1b929..450aa4d4 100644 --- a/apps/agent/README.md +++ b/apps/agent/README.md @@ -97,6 +97,6 @@ pnpm run test:cov ### End-to-End Testing -The e2e tests simulate scenarios starting at the contract level and extending to the agent, like processing requests and handling disputes. For detailed test scenarios, refer to the refer to the fies in [test/e2e/scenarios](./test/e2e/scenarios). +The e2e tests simulate scenarios starting at the contract level and extending to the agent, like processing requests and handling disputes. For detailed test scenarios, refer to the files in [test/e2e/scenarios](./test/e2e/scenarios). TODO: Add instructions on running e2e tests From a27aec84e3136f7f84fb51d07b1144966a53c6b7 Mon Sep 17 00:00:00 2001 From: jahabeebs <47253537+jahabeebs@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:10:41 -0500 Subject: [PATCH 3/3] fix: unneeded info --- packages/blocknumber/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/blocknumber/README.md b/packages/blocknumber/README.md index d030b873..cb69c6d5 100644 --- a/packages/blocknumber/README.md +++ b/packages/blocknumber/README.md @@ -19,10 +19,6 @@ Available scripts that can be run using `pnpm`: | `test` | Run unit tests using Vitest | | `coverage` | Run tests with coverage report | -## Usage - -The `blocknumber` package provides utilities for retrieving block numbers based on specific timestamps. Import the required classes as shown below: - ## API The primary services available within the `blocknumber` package are the following: