| Crates.io | newton-prover-rpc |
| lib.rs | newton-prover-rpc |
| version | 0.1.29 |
| created_at | 2025-11-14 08:11:01.520343+00 |
| updated_at | 2026-01-06 17:14:05.490365+00 |
| description | newton prover rpc |
| homepage | |
| repository | https://github.com/newt-foundation/newton-prover-avs |
| max_upload_size | |
| id | 1932455 |
| size | 398,938 |
Deprecation Notice: The standalone RPC server is deprecated in favor of the Gateway's integrated RPC endpoints. The Gateway provides a superset of RPC functionality with additional features including:
- Secrets management with encrypted storage
- WebSocket support for real-time updates
- Dual-flow architecture (synchronous and asynchronous)
- API key authentication with fine-grained permissions
- PostgreSQL integration for persistent storage
- Enhanced operator pool management
For new deployments, use the Gateway instead. See
crates/gateway/README.mdfor Gateway documentation.
High-performance JSON-RPC server for Newton Policy Protocol task management and policy evaluation.
# Using Make (recommended - automatically deploys if needed on local)
make run bin=rpc
# Using Make on testnet
make run bin=rpc chain_id=11155111 env=testnet
# Using Make with custom data provider config
make run bin=rpc data_provider_config=./my-data-provider.toml
# Using cargo directly
CHAIN_ID=31337 cargo run --manifest-path ./crates/rpc/Cargo.toml -- --chain-id 31337 start
# With custom data provider config
CHAIN_ID=31337 cargo run --manifest-path ./crates/rpc/Cargo.toml -- --chain-id 31337 --data-provider-config ./my-data-provider.toml start
# On testnet
CHAIN_ID=11155111 DEPLOYMENT_ENV=testnet cargo run --manifest-path ./crates/rpc/Cargo.toml -- --chain-id 11155111 start
The RPC server is configured through the newton-rpc.toml file, optional data provider config, and environment variables.
crates/rpc/newton-rpc.toml - RPC-specific settings (automatically loaded)--data-provider-config flag
crates/data-provider/data-provider.tomlCHAIN_ID, DEPLOYMENT_ENV, PRIVATE_KEY, etc.CHAIN_ID and DEPLOYMENT_ENVThe RPC config file (newton-rpc.toml) includes:
The newton-rpc.toml file structure:
[task_generator]
quorum_number = "00"
quorum_threshold_percentage = "40"
[task_generator.signer]
private_key = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
[server]
host = "127.0.0.1"
port = 8080
max_connections = 100
max_request_body_size = 10485760 # 10MB
[rate_limit]
max_requests_per_sender = 100
window_seconds = 60
global_rps = 1000
[cors]
enabled = true
allowed_origins = ["*"]
allowed_methods = ["GET", "POST"]
allowed_headers = ["Content-Type", "Authorization", "x-api-key"]
[metrics]
enabled = true
[logging]
level = "newton_rpc=info,jsonrpsee=info"
format = "json"
[processor]
max_pending_tasks = 10000
task_timeout_seconds = 300
[data_provider]
max_cache_size = 104857600 # 100 MiB
max_wasm_stack = 67108864 # 64 MiB
fuel = 100000000
max_http_calls = 50
max_http_request_size = 1048576 # 1 MiB
data_cache_url = "redis://:redis@127.0.0.1:6379"
[auth.whitelist]
"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266" = 100
# Required
CHAIN_ID=31337
DEPLOYMENT_ENV=stagef
# Optional
RUST_LOG=info
The Newton RPC Server provides JSON-RPC 2.0 endpoints for policy-based task management. All endpoints require cryptographic authentication via signed requests.
All RPC methods require a signature field containing a cryptographic signature of the request parameters. The signature must be generated using a whitelisted private key.
keccak256(abi.encodePacked(...))newton_createTaskCreate a new policy evaluation task with user intent validation.
Request:
{
"jsonrpc": "2.0",
"method": "newton_createTask",
"params": {
"signature": "0x1234567890abcdef...",
"policy_client": "0x1234567890123456789012345678901234567890",
"intent": {
"from": "0x1234567890123456789012345678901234567890",
"to": "0x0987654321098765432109876543210987654321",
"value": "1000000000000000000",
"data": "0x70a08231000000000000000000000000",
"chain_id": "1",
"function_signature": "0x70a08231"
},
"quorum_number": [1],
"quorum_threshold_percentage": 40
},
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"task_request_id": "550e8400-e29b-41d4-a716-446655440000",
"task_request": {
"policyClient": "0x1234567890123456789012345678901234567890",
"intent": { ... },
"quorumNumber": "0x01",
"quorumThresholdPercentage": 40
},
"status": "Queued",
"result": null,
"error": null,
"processing_time_ms": 15
},
"id": 1
}
newton_getTaskIdGet the current status of a task request (immediate response).
Request:
{
"jsonrpc": "2.0",
"method": "newton_getTaskId",
"params": {
"signature": "0x1234567890abcdef...",
"task_request_id": "550e8400-e29b-41d4-a716-446655440000"
},
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"task_request_id": "550e8400-e29b-41d4-a716-446655440000",
"task_request": { ... },
"status": "Completed",
"result": {
"task_id": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"tx_hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"error": null,
"processing_time_ms": 150
},
"id": 1
}
newton_waitForTaskIdWait for a task to complete and return the result. This endpoint blocks until the task is completed or the timeout is reached.
Request:
{
"jsonrpc": "2.0",
"method": "newton_waitForTaskId",
"params": {
"signature": "0x1234567890abcdef...",
"task_request_id": "550e8400-e29b-41d4-a716-446655440000",
"timeout": 60
},
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"task_request_id": "550e8400-e29b-41d4-a716-446655440000",
"task_request": { ... },
"status": "Completed",
"result": {
"task_id": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"tx_hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"error": null,
"processing_time_ms": 200
},
"id": 1
}
newton_createTaskAndWaitCreate a new task and wait for its completion in a single request. This combines the functionality of newton_createTask and newton_waitForTaskId.
Request:
{
"jsonrpc": "2.0",
"method": "newton_createTaskAndWait",
"params": {
"signature": "0x1234567890abcdef...",
"policy_client": "0x1234567890123456789012345678901234567890",
"intent": {
"from": "0x1234567890123456789012345678901234567890",
"to": "0x0987654321098765432109876543210987654321",
"value": "1000000000000000000",
"data": "0x70a08231000000000000000000000000",
"chain_id": "1",
"function_signature": "0x70a08231"
},
"quorum_number": [1],
"quorum_threshold_percentage": 40,
"timeout": 60
},
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"task_request_id": "550e8400-e29b-41d4-a716-446655440000",
"task_request": { ... },
"status": "Completed",
"result": {
"task_id": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"tx_hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
},
"error": null,
"processing_time_ms": 250
},
"id": 1
}
newton_simulatePolicyEvaluationSimulate policy evaluation without creating an actual task. This endpoint allows testing policy logic against user intents.
Request:
{
"jsonrpc": "2.0",
"method": "newton_simulatePolicyEvaluation",
"params": {
"signature": "0x1234567890abcdef...",
"intent": {
"from": "0x1234567890123456789012345678901234567890",
"to": "0x0987654321098765432109876543210987654321",
"value": "1000000000000000000",
"data": "0x70a08231000000000000000000000000",
"chainId": "1",
"functionSignature": "0x70a08231"
},
"policy_task_data": {
"policy": "0x706f6c696379...",
"policyParams": "0x7b226d617856616c7565223a313030307d",
"policyConfig": "0x7b22656e747279706f696e74223a226d61696e227d",
"policyMetadata": "0x7b226e616d65223a2254657374506f6c696379227d"
}
},
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"policy": "package main\n\nallow := true",
"evaluation_result": true,
"metadata": {
"execution_time_ms": 25,
"policy_version": "1.2.0"
}
},
"id": 1
}
newton_healthGet server health status (no authentication required).
Request:
{
"jsonrpc": "2.0",
"method": "newton_health",
"params": {},
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"status": "healthy",
"timestamp": 1234567890,
"version": "0.1.0"
},
"id": 1
}
newton_metricsGet server metrics and performance data (no authentication required).
Request:
{
"jsonrpc": "2.0",
"method": "newton_metrics",
"params": {},
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"request_count": 12345,
"error_count": 23,
"avg_response_time_ms": 45.2,
"active_connections": 15,
"rate_limit_hits": 5,
"uptime_seconds": 86400
},
"id": 1
}
Queued: Task request has been submitted and is waiting to be processedProcessing: Task is currently being processed by the systemCompleted: Task has been successfully completedFailed: Task processing failed with an errorThe Newton RPC Server is built with a modular, async architecture designed for high performance and reliability.
┌─────────────────────────────────────────────────────────────────────────────┐
│ Newton RPC Server │
├─────────────────────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────────────────┐ ┌─────────────────────────────┐ │
│ │ JSON-RPC │ │ Middleware Layer │ │ Task Processor │ │
│ │ Server │ │ │ │ │ │
│ │ │ │ - Authentication │ │ - Request Validation │ │
│ │ - jsonrpsee │ │ • Signature Verify │ │ - Task Creation │ │
│ │ - Async │ │ • Address Whitelist │ │ - Status Tracking │ │
│ │ - CORS │ │ - Rate Limiting │ │ - Policy Simulation │ │
│ │ - HTTP/WS │ │ • Per-Address Limits │ │ - AVS Integration │ │
│ │ │ │ • Global RPS Limits │ │ - Data Provider Access │ │
│ │ │ │ - Metrics Collection │ │ │ │
│ │ │ │ - IP Filtering │ │ │ │
│ └─────────────┘ └─────────────────────────┘ └─────────────────────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ External Services │ │
│ │ - EigenLayer AVS Contracts (Task Manager, Service Manager) │ │
│ │ - Policy Evaluation Engine (Rego/OPA) │ │
│ │ - Blockchain RPC (Ethereum/Holesky) │ │
│ │ - Data Provider Cache (Redis) │ │
│ │ - Metrics Backend (Prometheus) │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
GET /health - Returns server health statusGET /metrics - Prometheus metrics endpoint{
"status": "healthy",
"timestamp": 1234567890,
"version": "0.1.0"
}
The RPC server is optimized for high throughput and low latency:
The server provides comprehensive error handling with detailed error messages:
{
"jsonrpc": "2.0",
"error": {
"code": -32000,
"message": "Whitelisted address required",
"data": {
"code": "WHITELISTED_ADDRESS_REQUIRED",
"details": "This method requires a whitelisted address"
}
},
"id": 1
}
INVALID_SIGNATURE - Signature verification failedWHITELISTED_ADDRESS_REQUIRED - Address not in whitelistRATE_LIMIT_EXCEEDED - Too many requests from addressIP_BLOCKED - Request from blocked IP addressTo interact with the Newton RPC server, clients must generate valid signatures for each request:
use alloy::{
primitives::{keccak256, Address},
signers::{local::PrivateKeySigner, SignerSync},
sol_types::SolValue,
};
use std::str::FromStr;
// Example: Signing a CreateTaskRequest
let signer = PrivateKeySigner::from_str("0x...")?;
// Create the internal request representation
let internal_request = ICreateTaskRequest {
policyClient: policy_client_address,
intent: task_intent,
quorumNumber: quorum_bytes,
quorumThresholdPercentage: threshold,
};
// Generate hash and sign
let hash = keccak256(internal_request.abi_encode_packed());
let signature = signer.sign_hash_sync(&hash)?;
// Include in RPC request
let rpc_request = CreateTaskRequest {
signature: hex::encode(signature.as_bytes()),
policy_client: policy_client_address,
intent: task_intent,
quorum_number: Some(vec![1]),
quorum_threshold_percentage: Some(40),
};
Add your address to the server whitelist configuration:
[rpc.auth]
whitelist_enabled = true
whitelisted_addresses = [
"0xYourAddressHere",
# Add more addresses as needed
]
import { ethers } from "ethers";
async function signRequest(request: any, privateKey: string): Promise<string> {
const wallet = new ethers.Wallet(privateKey);
// Convert to internal format and generate hash
const internalRequest = convertToInternalFormat(request);
const hash = ethers.utils.solidityKeccak256(
["bytes"],
[ethers.utils.solidityPack(/* internal request fields */)]
);
const signature = await wallet.signMessage(ethers.utils.arrayify(hash));
return signature;
}
# Clone the repository
git clone <repository-url>
cd newton-prover-avs
# Build the RPC server
cargo build --manifest-path ./crates/rpc/Cargo.toml
# Run tests
cargo test --manifest-path ./crates/rpc/Cargo.toml
# Run the server
CHAIN_ID=31337 cargo run --manifest-path ./crates/rpc/Cargo.toml -- --chain-id 31337 start
The RPC server can be built and run using Docker. The CHAIN_ID environment variable can be set at runtime:
# Build Docker image for RPC (default CHAIN_ID=31337)
docker build --target rpc -t newton-prover-rpc .
# Build for specific chain (configs baked in at build time)
docker build --build-arg CHAIN_ID=11155111 --target rpc -t newton-prover-rpc:sepolia .
# Run with default chain_id (31337)
docker run -p 8080:8080 newton-prover-rpc
# Run Sepolia image on Sepolia
docker run -e CHAIN_ID=11155111 -e DEPLOYMENT_ENV=testnet \
-p 8080:8080 newton-prover-rpc:sepolia
# Run with custom configs mounted (overrides baked-in configs)
docker run -e CHAIN_ID=11155111 -e DEPLOYMENT_ENV=testnet \
-v /path/to/custom-configs:/app/config \
-p 8080:8080 newton-prover-rpc
# Run on mainnet
docker run -e CHAIN_ID=1 -e DEPLOYMENT_ENV=mainnet \
-v /path/to/mainnet-configs:/app/config \
-p 8080:8080 newton-prover-rpc
The same pattern applies to all services (operator, aggregator, challenger):
# Build for specific chain
docker build --build-arg CHAIN_ID=31337 --target operator -t newton-prover-operator .
docker build --build-arg CHAIN_ID=11155111 --target aggregator -t newton-prover-aggregator:sepolia .
docker build --build-arg CHAIN_ID=17000 --target challenger -t newton-prover-challenger:holesky .
# Run with baked-in configs
docker run -e CHAIN_ID=11155111 -e DEPLOYMENT_ENV=testnet newton-prover-operator
# Run with custom configs (overrides baked-in configs via volume mount)
docker run -e CHAIN_ID=11155111 -e DEPLOYMENT_ENV=testnet \
-v /path/to/configs:/app/config \
-p 9002:9002 newton-prover-aggregator:sepolia
Config Directory Structure:
/app/config/app/config to override baked-in configsoperator.toml (for operator)aggregator.toml (for aggregator)challenger.toml (for challenger)newton-rpc.toml (for rpc)data-provider.toml (optional, for custom data provider config)