Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tenderly RPCs #301

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# These must be set or some RPC requests will return errors. See https://github.com/WalletConnect/rpc-proxy/issues/294
export RPC_PROXY_INFURA_PROJECT_ID=""
export RPC_PROXY_TENDERLY_PROJECT_ID=""
export RPC_PROXY_POKT_PROJECT_ID=""

# Uncomment if you have access to our Project ID registry and want to validate project IDs
Expand Down
1 change: 1 addition & 0 deletions .env.terraform.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export AWS_SECRET_ACCESS_KEY=""
export AWS_REGION="eu-central-1"

export TF_VAR_infura_project_id=""
export TF_VAR_tenderly_project_id=""
export TF_VAR_pokt_project_id=""
export TF_VAR_grafana_endpoint=$(aws grafana list-workspaces | jq -r '.workspaces[] | select( .tags.Env == "prod") | select( .tags.Name == "grafana-9") | .endpoint')
export TF_VAR_registry_api_auth_token=""
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ on:
required: true
INFURA_PROJECT_ID:
required: true
TENDERLY_PROJECT_ID:
required: true
POKT_PROJECT_ID:
required: true
REGISTRY_API_AUTH_TOKEN:
Expand All @@ -59,6 +61,7 @@ concurrency: cd
env:
IMAGE_NAME: "rpc-proxy"
TF_VAR_infura_project_id: ${{ secrets.INFURA_PROJECT_ID }}
TF_VAR_tenderly_project_id: ${{ secrets.TENDERLY_PROJECT_ID }}
TF_VAR_pokt_project_id: ${{ secrets.POKT_PROJECT_ID }}
TF_VAR_registry_api_auth_token: ${{ secrets.REGISTRY_API_AUTH_TOKEN }}
TF_VAR_debug_secret: ${{ secrets.DEBUG_SECRET }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ jobs:
env:
TEST_RPC_PROXY_PROJECT_ID: ${{ secrets.PROJECT_ID }}
RPC_PROXY_INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }}
RPC_PROXY_TENDERLY_PROJECT_ID: ${{ secrets.TENDERLY_PROJECT_ID }}
RPC_PROXY_REGISTRY_API_URL: ${{ secrets.REGISTRY_URL }}
RPC_PROXY_REGISTRY_API_AUTH_TOKEN: ${{ secrets.RPC_PROXY_REGISTRY_API_AUTH_TOKEN }}
RPC_PROXY_POKT_PROJECT_ID: ${{ secrets.POKT_PROJECT_ID }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci_terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ concurrency:

env:
TF_VAR_infura_project_id: ${{ secrets.INFURA_PROJECT_ID }}
TF_VAR_tenderly_project_id: ${{ secrets.TENDERLY_PROJECT_ID }}
TF_VAR_pokt_project_id: ${{ secrets.POKT_PROJECT_ID }}
TF_VAR_registry_api_auth_token: ${{ secrets.REGISTRY_API_AUTH_TOKEN }}
TF_VAR_debug_secret: ${{ secrets.DEBUG_SECRET }}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ $ docker build . --tag rpc-proxy:
$ docker run -p 3000:3000 \
-e RPC_PROXY_POKT_PROJECT_ID=<some_id> \
-e RPC_PROXY_INFURA_PROJECT_ID=<some_id> \
-e RPC_PROXY_TENDERLY_PROJECT_ID=<some_id> \
-e RPC_PROXY_REGISTRY_API_URL=<registry_url> \
-e RPC_PROXY_REGISTRY_API_AUTH_TOKEN=<token> \
--name rpc -it rpc-proxy
Expand All @@ -57,6 +58,7 @@ If you need to test with registry caching activated, you can use `docker-compose
```console
$ RPC_PROXY_POKT_PROJECT_ID=<some_id> \
RPC_PROXY_INFURA_PROJECT_ID=<some_id> \
RPC_PROXY_TENDERLY_PROJECT_ID=<some_id> \
RPC_PROXY_REGISTRY_API_AUTH_TOKEN=<token> \
docker-compose up
```
10 changes: 10 additions & 0 deletions SUPPORTED_CHAINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Chain name with associated `chainId` query param to use.
- Base Goerli (`eip155:84531`)
- Zora (`eip155:7777777`)
- Zora Goerli (`eip155:999`)
- Boba Ethereum (`eip155:288`)
- Boba BNB (`eip155:56288`)
- Boba BNB Testnet (`eip155:9728`)

## WebSocket RPC

Expand All @@ -37,7 +40,14 @@ Chain name with associated `chainId` query param to use.
- Optimism Goerli (`eip155:420`)
- Arbitrum (`eip155:42161`)
- Arbitrum Goerli (`eip155:421613`)
- Polygon (`eip155:137`)
- Polygon Mumbai (`eip155:80001`)
- Aurora (`eip155:1313161554`)
- Aurora Testnet (`eip155:1313161555`)
- Base (`eip155:8453`)
- Base Goerli (`eip155:84531`)
- Zora (`eip155:7777777`)
- Zora Goerli (`eip155:999`)
- Boba Ethereum (`eip155:288`)
- Boba BNB (`eip155:56288`)
- Boba BNB Testnet (`eip155:9728`)
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
- RPC_PROXY_HOST=0.0.0.0
- RPC_PROXY_PORT=3000
- RPC_PROXY_INFURA_PROJECT_ID=${RPC_PROXY_INFURA_PROJECT_ID}
- RPC_PROXY_TENDERLY_PROJECT_ID=${RPC_PROXY_TENDERLY_PROJECT_ID}
- RPC_PROXY_POKT_PROJECT_ID=${RPC_PROXY_POKT_PROJECT_ID}
- RPC_PROXY_REGISTRY_API_URL=https://registry-prod-cf.walletconnect.com
- RPC_PROXY_REGISTRY_API_AUTH_TOKEN=${RPC_PROXY_REGISTRY_API_AUTH_TOKEN}
Expand Down
2 changes: 2 additions & 0 deletions src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod omnia;
mod pokt;
mod publicnode;
mod server;
mod tenderly;
mod zksync;
mod zora;

Expand All @@ -28,6 +29,7 @@ pub use {
pokt::*,
publicnode::*,
server::*,
tenderly::*,
zksync::*,
zora::*,
};
Expand Down
196 changes: 196 additions & 0 deletions src/env/tenderly.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
use {
super::ProviderConfig,
crate::providers::{Priority, Weight},
std::collections::HashMap,
};

#[derive(Debug)]
pub struct TenderlyConfig {
pub project_id: String,

pub supported_chains: HashMap<String, (String, Weight)>,

pub supported_ws_chains: HashMap<String, (String, Weight)>,
}

impl TenderlyConfig {
pub fn new(project_id: String) -> Self {
Self {
project_id,
supported_chains: default_supported_chains(),
supported_ws_chains: default_ws_supported_chains(),
}
}
}

impl ProviderConfig for TenderlyConfig {
fn supported_chains(self) -> HashMap<String, (String, Weight)> {
self.supported_chains
}

fn supported_ws_chains(self) -> HashMap<String, (String, Weight)> {
self.supported_ws_chains
}

fn provider_kind(&self) -> crate::providers::ProviderKind {
crate::providers::ProviderKind::Tenderly
}
}

fn default_supported_chains() -> HashMap<String, (String, Weight)> {
// Keep in-sync with SUPPORTED_CHAINS.md

HashMap::from([
// Ethereum Mainnet
(
"eip155:1".into(),
("mainnet".into(), Weight::new(Priority::Max).unwrap()),
),
// Ethereum Görli
(
"eip155:5".into(),
("goerli".into(), Weight::new(Priority::Normal).unwrap()),
),
// Ethereum Sepolia
(
"eip155:11155111".into(),
("sepolia".into(), Weight::new(Priority::Normal).unwrap()),
),
// Optimism Mainnet
(
"eip155:10".into(),
("optimism".into(), Weight::new(Priority::Normal).unwrap()),
),
// Optimism Görli
(
"eip155:420".into(),
(
"optimism-goerli".into(),
Weight::new(Priority::Normal).unwrap(),
),
),
// Polygon Mainnet
(
"eip155:137".into(),
("polygon".into(), Weight::new(Priority::High).unwrap()),
),
// Polygon Mumbai
(
"eip155:80001".into(),
(
"polygon-mumbai".into(),
Weight::new(Priority::Normal).unwrap(),
),
),
// Base Mainnet
(
"eip155:8453".into(),
("base".into(), Weight::new(Priority::Normal).unwrap()),
),
// Base Görli
(
"eip155:84531".into(),
("base-goerli".into(), Weight::new(Priority::Normal).unwrap()),
),
// Boba Ethereum Mainnet
(
"eip155:288".into(),
(
"boba-ethereum".into(),
Weight::new(Priority::Normal).unwrap(),
),
),
// Boba BNB Mainnet
(
"eip155:56288".into(),
("boba-bnb".into(), Weight::new(Priority::Normal).unwrap()),
),
// Boba BNB Testnet
(
"eip155:9728".into(),
(
"boba-bnb-testnet".into(),
Weight::new(Priority::Normal).unwrap(),
),
),
])
}

fn default_ws_supported_chains() -> HashMap<String, (String, Weight)> {
// Keep in-sync with SUPPORTED_CHAINS.md

HashMap::from([
// Ethereum Mainnet
(
"eip155:1".into(),
("mainnet".into(), Weight::new(Priority::Normal).unwrap()),
),
// Ethereum Görli
(
"eip155:5".into(),
("goerli".into(), Weight::new(Priority::Normal).unwrap()),
),
// Ethereum Sepolia
(
"eip155:11155111".into(),
("sepolia".into(), Weight::new(Priority::Normal).unwrap()),
),
// Optimism Mainnet
(
"eip155:10".into(),
("optimism".into(), Weight::new(Priority::Normal).unwrap()),
),
// Optimism Görli
(
"eip155:420".into(),
(
"optimism-goerli".into(),
Weight::new(Priority::Normal).unwrap(),
),
),
// Polygon Mainnet
(
"eip155:137".into(),
("polygon".into(), Weight::new(Priority::Normal).unwrap()),
),
// Polygon Mumbai
(
"eip155:80001".into(),
(
"polygon-mumbai".into(),
Weight::new(Priority::Normal).unwrap(),
),
),
// Base Mainnet
(
"eip155:8453".into(),
("base".into(), Weight::new(Priority::Normal).unwrap()),
),
// Base Görli
(
"eip155:84531".into(),
("base-goerli".into(), Weight::new(Priority::Normal).unwrap()),
),
// Boba Ethereum Mainnet
(
"eip155:288".into(),
(
"boba-ethereum".into(),
Weight::new(Priority::Normal).unwrap(),
),
),
// Boba BNB Mainnet
(
"eip155:56288".into(),
("boba-bnb".into(), Weight::new(Priority::Normal).unwrap()),
),
// Boba BNB Testnet
(
"eip155:9728".into(),
(
"boba-bnb-testnet".into(),
Weight::new(Priority::Normal).unwrap(),
),
),
])
}
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use {
OmniatechConfig,
PoktConfig,
PublicnodeConfig,
TenderlyConfig,
ZKSyncConfig,
ZoraConfig,
},
Expand All @@ -34,6 +35,8 @@ use {
PoktProvider,
ProviderRepository,
PublicnodeProvider,
TenderlyProvider,
TenderlyWsProvider,
ZKSyncProvider,
ZoraProvider,
ZoraWsProvider,
Expand Down Expand Up @@ -223,6 +226,9 @@ fn init_providers() -> ProviderRepository {
let infura_project_id = std::env::var("RPC_PROXY_INFURA_PROJECT_ID")
.expect("Missing RPC_PROXY_INFURA_PROJECT_ID env var");

let tenderly_project_id = std::env::var("RPC_PROXY_TENDERLY_PROJECT_ID")
.expect("Missing RPC_PROXY_TENDERLY_PROJECT_ID env var");

// Keep in-sync with SUPPORTED_CHAINS.md

providers.add_provider::<PoktProvider, PoktConfig>(PoktConfig::new(
Expand All @@ -238,10 +244,17 @@ fn init_providers() -> ProviderRepository {
providers
.add_provider::<InfuraProvider, InfuraConfig>(InfuraConfig::new(infura_project_id.clone()));
providers.add_provider::<ZoraProvider, ZoraConfig>(ZoraConfig::default());
providers.add_provider::<TenderlyProvider, TenderlyConfig>(TenderlyConfig::new(
tenderly_project_id.clone(),
));

// WebSocket Providers
providers
.add_ws_provider::<InfuraWsProvider, InfuraConfig>(InfuraConfig::new(infura_project_id));
providers.add_ws_provider::<ZoraWsProvider, ZoraConfig>(ZoraConfig::default());
providers.add_ws_provider::<TenderlyWsProvider, TenderlyConfig>(TenderlyConfig::new(
tenderly_project_id,
));

providers
}
5 changes: 5 additions & 0 deletions src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod infura;
mod omnia;
mod pokt;
mod publicnode;
mod tenderly;
mod weights;
mod zksync;
mod zora;
Expand All @@ -31,6 +32,7 @@ pub use {
omnia::OmniatechProvider,
pokt::PoktProvider,
publicnode::PublicnodeProvider,
tenderly::{TenderlyProvider, TenderlyWsProvider},
zksync::ZKSyncProvider,
zora::{ZoraProvider, ZoraWsProvider},
};
Expand Down Expand Up @@ -211,6 +213,7 @@ pub enum ProviderKind {
Binance,
ZKSync,
Publicnode,
Tenderly,
Omniatech,
Base,
Zora,
Expand All @@ -224,6 +227,7 @@ impl Display for ProviderKind {
ProviderKind::Binance => "Binance",
ProviderKind::ZKSync => "zkSync",
ProviderKind::Publicnode => "Publicnode",
ProviderKind::Tenderly => "Tenderly",
ProviderKind::Omniatech => "Omniatech",
ProviderKind::Base => "Base",
ProviderKind::Zora => "Zora",
Expand All @@ -239,6 +243,7 @@ impl ProviderKind {
"Binance" => Some(Self::Binance),
"zkSync" => Some(Self::ZKSync),
"Publicnode" => Some(Self::Publicnode),
"Tenderly" => Some(Self::Tenderly),
"Omniatech" => Some(Self::Omniatech),
"Base" => Some(Self::Base),
"Zora" => Some(Self::Zora),
Expand Down
Loading