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

Cache Status Command Fails on Nitro Devnode #136

Open
rauljordan opened this issue Jan 23, 2025 · 1 comment
Open

Cache Status Command Fails on Nitro Devnode #136

rauljordan opened this issue Jan 23, 2025 · 1 comment

Comments

@rauljordan
Copy link
Contributor

When running cargo stylus cache status --address=$ADDR --endpoint=http://localhost:8547 on the Nitro devnode, we get an alloy decoding failure:

Caused by:
   0: buffer overrun while deserializing
   1: buffer overrun while deserializing

This was debugged and determined to happen in the cache.rs file when attempting to fetch all the cache manager addresses:

async fn get_cache_manager_address<P>(provider: P) -> Result<Address>
where
    P: Provider + Clone + Send + Sync,
{
    let arb_wasm_cache = ArbWasmCache::new(CONTRACT_ADDR, provider.clone());
    let result = arb_wasm_cache.allCacheManagers().call().await?;
    ...

However, a minimum reproduction of the code, in an isolated binary, indeed passes with the same dependencies and flags. Something is wrong with the alloy decoder in cargo stylus that works fine in isolation.

// Copyright 2023-2024, Offchain Labs, Inc.
// For licensing, see https://github.com/OffchainLabs/cargo-stylus/blob/stylus/licenses/COPYRIGHT.md

use alloy_primitives::{address, Address};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_sol_macro::sol;
use eyre::{bail, Result};

sol! {
    #[sol(rpc)]
    interface ArbWasmCache {
        function allCacheManagers() external view returns (address[] managers);
    }
}

pub const CONTRACT_ADDR: Address = address!("0000000000000000000000000000000000000072");

#[tokio::main]
pub async fn main() -> Result<()> {
    let endpoint = "http://localhost:8547";
    let provider = ProviderBuilder::new()
        .with_recommended_fillers()
        .on_builtin(&endpoint)
        .await?;
    let manager_addr = get_cache_manager_address(provider).await?;
    println!("Addr: {:?}", manager_addr);
    Ok(())
}

async fn get_cache_manager_address<P>(provider: P) -> Result<Address>
where
    P: Provider + Clone + Send + Sync,
{
    let arb_wasm_cache = ArbWasmCache::new(CONTRACT_ADDR, provider.clone());
    let result = arb_wasm_cache.allCacheManagers().call().await?;
    if result.managers.is_empty() {
        bail!("no cache managers found in ArbWasmCache, perhaps the Stylus cache is not yet enabled on this chain");
    }
    Ok(*result.managers.last().unwrap())
}
@gligneul
Copy link
Contributor

gligneul commented Jan 27, 2025

Here is the deployment of the cache manager in the devnode:

echo "Deploying Cache Manager contract..."
deploy_output=$(cast send --private-key 0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 \
  --rpc-url http://127.0.0.1:8547 \
  --create 0x60a06040523060805234801561001457600080fd5b50608051611d1c61003060003960006105260152611d1c6000f3fe)

The command deploys the bytecode directly, so I'm not entirely sure what the contract looks like. Maybe this version of the cache manager doesn't contain the method cargo-stylus is looking for?

[1] https://github.com/OffchainLabs/nitro-devnode/blob/main/run-dev-node.sh#L68

Edit: Nvm, this might not be related as the issue seems to be in the precompile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants