Skip to content
Closed
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
18 changes: 12 additions & 6 deletions crates/boundless-cli/src/commands/povw/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use boundless_povw::{
log_updater::IPovwAccounting::{self, EpochFinalized, IPovwAccountingInstance, WorkLogUpdated},
mint_calculator::{prover::MintCalculatorProver, IPovwMint, CHAIN_SPECS},
};
use boundless_zkc::deployments::NamedChain;
use clap::Args;
use risc0_povw::PovwLogId;
use risc0_zkvm::{default_prover, Digest, ProverOpts};
Expand Down Expand Up @@ -87,6 +88,10 @@ pub struct PovwClaim {

#[clap(flatten, next_help_heading = "Prover")]
prover_config: ProverConfig,

/// The RPC URL to use to submit the reward claim transaction.
#[clap(long, env = "ETH_RPC_URL")]
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe rename it to REWARD_RPC_URL so in case it's decided to use a different chain for the reward (for example base due to tx fees in eth), it's a no brainer :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah agree that might be a better name. @willpote you good with this, also because similarity with us using REWARD_ADDRESS env vars now?

pub eth_rpc_url: Url,
}

impl PovwClaim {
Expand All @@ -97,14 +102,14 @@ impl PovwClaim {
tracing::warn!("You can provide it using the --beacon-api-url flag.");
}
let tx_signer = global_config.require_private_key()?;
let rpc_url = global_config.require_rpc_url()?;
let eth_rpc_url = self.eth_rpc_url.clone();

// Connect to the chain.
let provider = ProviderBuilder::new()
.wallet(tx_signer.clone())
.connect(rpc_url.as_str())
.connect(eth_rpc_url.as_str())
.await
.with_context(|| format!("failed to connect provider to {rpc_url}"))?;
.with_context(|| format!("failed to connect provider to {eth_rpc_url}"))?;

let chain_id = provider.get_chain_id().await.context("Failed to query the chain ID")?;
let chain_spec = CHAIN_SPECS.get(&chain_id).with_context(|| {
Expand All @@ -114,9 +119,10 @@ impl PovwClaim {
.deployment
.clone()
.or_else(|| Deployment::from_chain_id(chain_id))
.context(
"could not determine deployment from chain ID; please specify deployment explicitly",
)?;
.context(format!(
"could not determine deployment from chain ID {chain_id} ({:?}); please check the RPC matches the chain of the PoVW accounting contract or specify deployment explicitly",
NamedChain::try_from(chain_id)
))?;

// Determine the limits on the blocks that will be searched for events.
let latest_block_number =
Expand Down
22 changes: 15 additions & 7 deletions crates/boundless-cli/src/commands/povw/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ use boundless_povw::{
deployments::Deployment,
log_updater::{prover::LogUpdaterProver, IPovwAccounting},
};
use boundless_zkc::deployments::NamedChain;
use clap::Args;
use risc0_povw::guest::Journal as LogBuilderJournal;
use risc0_zkvm::{default_prover, ProverOpts};
use url::Url;

use super::State;
use crate::config::{GlobalConfig, ProverConfig};
Expand Down Expand Up @@ -58,14 +60,18 @@ pub struct PovwSubmit {

#[clap(flatten, next_help_heading = "Prover")]
prover_config: ProverConfig,

/// The RPC URL to use to submit the work update transaction to the staking contract.
#[clap(long, env = "ETH_RPC_URL")]
pub eth_rpc_url: Url,
}

impl PovwSubmit {
/// Run the [PovwSubmit] command.
pub async fn run(&self, global_config: &GlobalConfig) -> anyhow::Result<()> {
let tx_signer = global_config.require_private_key()?;
let work_log_signer = self.povw_private_key.as_ref().unwrap_or(&tx_signer);
let rpc_url = global_config.require_rpc_url()?;
let eth_rpc_url = self.eth_rpc_url.clone();

// Load the state and check to make sure the private key matches.
let mut state = State::load(&self.state)
Expand All @@ -83,21 +89,23 @@ impl PovwSubmit {
// Connect to the chain.
let provider = ProviderBuilder::new()
.wallet(tx_signer.clone())
.connect(rpc_url.as_str())
.connect(eth_rpc_url.as_str())
.await
.with_context(|| format!("Failed to connect provider to {rpc_url}"))?;
.with_context(|| format!("Failed to connect provider to {eth_rpc_url}"))?;

let chain_id = provider
.get_chain_id()
.await
.with_context(|| format!("Failed to get chain ID from {rpc_url}"))?;
.with_context(|| format!("Failed to get chain ID from {eth_rpc_url}"))?;

let deployment = self
.deployment
.clone()
.or_else(|| Deployment::from_chain_id(chain_id))
.context(
"could not determine deployment from chain ID; please specify deployment explicitly",
)?;
.context(format!(
"could not determine deployment from chain ID {chain_id} ({:?}); please check the RPC matches the chain of the PoVW accounting contract or specify deployment explicitly",
NamedChain::try_from(chain_id)
))?;
let povw_accounting =
IPovwAccounting::new(deployment.povw_accounting_address, provider.clone());

Expand Down
6 changes: 3 additions & 3 deletions crates/boundless-cli/tests/povw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async fn prove_and_send_update() -> anyhow::Result<()> {
.env("VEZKC_ADDRESS", format!("{:#x}", ctx.zkc_rewards.address()))
.env("PRIVATE_KEY", format!("{:#x}", tx_signer.to_bytes()))
.env("RISC0_DEV_MODE", "1")
.env("RPC_URL", ctx.anvil.lock().await.endpoint_url().as_str())
.env("ETH_RPC_URL", ctx.anvil.lock().await.endpoint_url().as_str())
.env("POVW_PRIVATE_KEY", format!("{:#x}", work_log_signer.to_bytes()))
.assert()
.success()
Expand Down Expand Up @@ -270,7 +270,7 @@ async fn claim_reward_multi_epoch() -> anyhow::Result<()> {
.env("VEZKC_ADDRESS", format!("{:#x}", ctx.zkc_rewards.address()))
.env("PRIVATE_KEY", format!("{:#x}", tx_signer.to_bytes()))
.env("RISC0_DEV_MODE", "1")
.env("RPC_URL", ctx.anvil.lock().await.endpoint_url().as_str())
.env("ETH_RPC_URL", ctx.anvil.lock().await.endpoint_url().as_str())
.env("POVW_PRIVATE_KEY", format!("{:#x}", work_log_signer.to_bytes()));

let result = cmd.assert().success().stdout(contains("Work log update confirmed"));
Expand Down Expand Up @@ -382,7 +382,7 @@ async fn claim_on_partially_finalized_epochs() -> anyhow::Result<()> {
.env("VEZKC_ADDRESS", format!("{:#x}", ctx.zkc_rewards.address()))
.env("PRIVATE_KEY", format!("{:#x}", tx_signer.to_bytes()))
.env("RISC0_DEV_MODE", "1")
.env("RPC_URL", ctx.anvil.lock().await.endpoint_url().as_str())
.env("ETH_RPC_URL", ctx.anvil.lock().await.endpoint_url().as_str())
.env("POVW_PRIVATE_KEY", format!("{:#x}", work_log_signer.to_bytes()));

let result = cmd.assert().success().stdout(contains("Work log update confirmed"));
Expand Down
Loading