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 Llama RPC providers #222

Merged
merged 7 commits into from
Jun 11, 2024
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
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ ic-stable-structures = { workspace = true }
ic-certified-map = { workspace = true }
ic-cdk = { workspace = true }
ic-cdk-macros = { workspace = true }
ic-canister-log = { git = "https://github.com/dfinity/ic", rev = "0f6a050f402248ee611631ce4855b86ae3414ced", package = "ic-canister-log" }
cketh-common = { git = "https://github.com/dfinity/ic", rev = "0f6a050f402248ee611631ce4855b86ae3414ced", package = "ic-cketh-minter" }
ic-canister-log = { git = "https://github.com/dfinity/ic", rev = "3f04ac23896b05e3fd0eb66793b9cb75f95eeff4", package = "ic-canister-log" }
cketh-common = { git = "https://github.com/dfinity/ic", rev = "3f04ac23896b05e3fd0eb66793b9cb75f95eeff4", package = "ic-cketh-minter" }
maplit = "1.0"
num = "0.4"
num-traits = "0.2"
Expand Down
2 changes: 2 additions & 0 deletions candid/evm_rpc.did
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type EthMainnetService = variant {
BlockPi;
Cloudflare;
PublicNode;
Llama;
Copy link
Collaborator Author

@rvanasa rvanasa Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently using Llama in place of LlamaNodes since the API domain name is llamarpc.com. Otherwise, also having PublicNode could create some confusion about when to include an s at the end for people unfamiliar with these individual providers.

Totally open to hearing other perspectives on this in case it makes more sense to use LlamaNodes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought those were coming from the company name, which in that case LlamaNodes and PublicNode make perfect sense, and not from the API domain name. A priori I would say that the company name is more stable than the domain name, that's why I would tend to stick to the company name, but that's not a strong opinion.

};
type EthSepoliaService = variant {
Alchemy;
Expand All @@ -48,6 +49,7 @@ type L2MainnetService = variant {
Ankr;
BlockPi;
PublicNode;
Llama;
};
type FeeHistory = record {
reward : vec vec nat;
Expand Down
20 changes: 13 additions & 7 deletions e2e/motoko/main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,32 @@ shared ({ caller = installer }) actor class Main() {
};
};

// Any unused cycles will be refunded
let candidRpcCycles = 200_000_000_000;
let mainnetServices = [#Alchemy, #Ankr, #Cloudflare, #BlockPi, #PublicNode, #Llama];
let l2Services = [#Ankr, #BlockPi, #PublicNode, #Llama];
let allServices : [(Text, EvmRpc.RpcServices)] = [
(
"Ethereum",
#EthMainnet(?[#Alchemy, #Ankr, #Cloudflare, #BlockPi, #PublicNode]),
#EthMainnet(?mainnetServices),
),
(
"Arbitrum",
#ArbitrumOne(null),
#ArbitrumOne(?l2Services),
),
(
"Base",
#BaseMainnet(null),
#BaseMainnet(?l2Services),
),
(
"Optimism",
#OptimismMainnet(null),
#OptimismMainnet(?l2Services),
),
];

// Services to use for `eth_sendRawTransaction`
let sendRawTransactionServices = #EthMainnet(?[#Alchemy, #Ankr, #Cloudflare, #BlockPi, #PublicNode]);

// Any unused cycles will be refunded
let candidRpcCycles = 200_000_000_000;

func testCandidRpc(networkName : Text, services : EvmRpc.RpcServices) : async () {
switch (await canister.eth_getBlockByNumber(services, null, #Latest)) {
Expand Down Expand Up @@ -262,7 +268,7 @@ shared ({ caller = installer }) actor class Main() {
networkName,
"eth_sendRawTransaction",
await canister.eth_sendRawTransaction(
services,
sendRawTransactionServices,
null,
"0xf86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83",
),
Expand Down
52 changes: 52 additions & 0 deletions src/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pub const PUBLICNODE_BASE_MAINNET_HOSTNAME: &str = "base-rpc.publicnode.com";
pub const ALCHEMY_OPT_MAINNET_HOSTNAME: &str = "opt-mainnet.g.alchemy.com";
pub const BLOCKPI_OPTIMISM_MAINNET_HOSTNAME: &str = "optimism.blockpi.network";
pub const PUBLICNODE_OPTIMISM_MAINNET_HOSTNAME: &str = "optimism-rpc.publicnode.com";
pub const LLAMA_ETH_MAINNET_HOSTNAME: &str = "eth.llamarpc.com";
pub const LLAMA_ARBITRUM_ONE_HOSTNAME: &str = "arbitrum.llamarpc.com";
pub const LLAMA_BASE_MAINNET_HOSTNAME: &str = "base.llamarpc.com";
pub const LLAMA_OPTIMISM_MAINNET_HOSTNAME: &str = "optimism.llamarpc.com";

// Limited API credentials for local testing.
// Use `dfx canister call evm_rpc updateProvider ...` to pass your own keys.
Expand Down Expand Up @@ -236,6 +240,38 @@ pub fn get_default_providers() -> Vec<RegisterProviderArgs> {
cycles_per_call: 0,
cycles_per_message_byte: 0,
},
RegisterProviderArgs {
chain_id: ETH_MAINNET_CHAIN_ID,
hostname: LLAMA_ETH_MAINNET_HOSTNAME.to_string(),
credential_path: "".to_string(),
credential_headers: None,
cycles_per_call: 0,
cycles_per_message_byte: 0,
},
RegisterProviderArgs {
chain_id: ARBITRUM_ONE_CHAIN_ID,
hostname: LLAMA_ARBITRUM_ONE_HOSTNAME.to_string(),
credential_path: "".to_string(),
credential_headers: None,
cycles_per_call: 0,
cycles_per_message_byte: 0,
},
RegisterProviderArgs {
chain_id: BASE_MAINNET_CHAIN_ID,
hostname: LLAMA_BASE_MAINNET_HOSTNAME.to_string(),
credential_path: "".to_string(),
credential_headers: None,
cycles_per_call: 0,
cycles_per_message_byte: 0,
},
RegisterProviderArgs {
chain_id: OPTIMISM_MAINNET_CHAIN_ID,
hostname: LLAMA_OPTIMISM_MAINNET_HOSTNAME.to_string(),
credential_path: "".to_string(),
credential_headers: None,
cycles_per_call: 0,
cycles_per_message_byte: 0,
},
]
}

Expand Down Expand Up @@ -325,6 +361,22 @@ pub fn get_default_service_provider_hostnames() -> Vec<(RpcService, &'static str
RpcService::OptimismMainnet(L2MainnetService::PublicNode),
PUBLICNODE_OPTIMISM_MAINNET_HOSTNAME,
),
(
RpcService::EthMainnet(EthMainnetService::Llama),
LLAMA_ETH_MAINNET_HOSTNAME,
),
(
RpcService::ArbitrumOne(L2MainnetService::Llama),
LLAMA_ARBITRUM_ONE_HOSTNAME,
),
(
RpcService::BaseMainnet(L2MainnetService::Llama),
LLAMA_BASE_MAINNET_HOSTNAME,
),
(
RpcService::OptimismMainnet(L2MainnetService::Llama),
LLAMA_OPTIMISM_MAINNET_HOSTNAME,
),
]
}

Expand Down
Loading