Caching Proxies Terminal is a Go-based service designed to interface with nearcore for block processing. It accepts HTTP requests to submit data chunks and leverages NATS for efficient message passing and storage. This service is a part of RPC speedup project and particularly useful for data chunks distribution to other NEAR rpc nodes.
- Go 1.20 or higher
- Access to a NATS server
- Clone the repository:
git clone https://github.com/aurora-is-near/caching-proxies-terminal
- Navigate to the project directory:
cd caching-proxies-terminal
- Build the project using the provided Makefile:
make build
The service offers several configuration options, which are set using command-line flags:
-
-use-blob-hash
(boolean): Determines whether to use blob hash as the unique MsgID instead of combiningprevious_hash_id
andshard_id
. Default isfalse
../caching-proxies-terminal -use-blob-hash=true
-
-server
(string): Sets the NATS server URL to connect to../caching-proxies-terminal -server=[server_address]
-
-shard-prefix
(string): Prefix for shard subjects. Messages will be published toshard-prefix.shard_id
subject in the NATS../caching-proxies-terminal -shard-prefix=[prefix]
-
-submissions-verifier-host
(string): Sets the submissions verifier host and endpoint. Must be in format ofhttp://host:port/authenticate
./caching-proxies-terminal -submissions-verifier-host=[verifier_host]
- To run with custom NATS context and shard prefix:
./caching-proxies-terminal -shard-prefix [prefix] -submissions-verifier-host [verifier_host]
- Use the
-use-blob-hash=true
flag for unique MsgID generation based on blob hash.
- Submit a chunk for processing:
curl -XPOST -H 'Authentication: Bearer [token]' -d '[data]' 'localhost:1323/process?shard_id=1&previous_hash_id=0x12348'
- The
/process
endpoint requires a Bearer token for requests. - Upon receiving a request, the service will:
- Attempt to authenticate the Bearer token by contacting the Submission Verifier service.
- Once authenticated, the "Submission Verifier" will provide a valid NATS JWT token, which will be used by the terminal service.
- This NATS JWT token will have an expiration date and will be used to access NATS to store the received chunk in it.