Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fetching offchain storage value returns different value than the value fetched using localStorageGet function #14413

Open
1 of 2 tasks
chirag-bgh opened this issue Jun 19, 2023 · 3 comments
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.

Comments

@chirag-bgh
Copy link

chirag-bgh commented Jun 19, 2023

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

I need to get the rpc_url value set initially from the explorer. The localStorageGet rpc function returns the correct value of the rpc_url.
This returns https://eth-mainnet.g.alchemy.com/v2/MY_API_KEY

But while fetching the rpc_url through the storage call like this:

    pub const ETHEREUM_EXECUTION_RPC: &[u8] = b"starknet::ETHEREUM_EXECUTION_RPC";
    let eth_execution_rpc_url = StorageValueRef::persistent(ETHEREUM_EXECUTION_RPC)
        .get::<Vec<u8>>()
        .map_err(|_| OffchainWorkerError::GetStorageFailed)?
        .ok_or(OffchainWorkerError::EthRpcNotSet)?;
    
     let endpoint: &str =
        core::str::from_utf8(&eth_execution_rpc_url).map_err(|_| OffchainWorkerError::FormatBytesFailed)?;

This returns endpoint = ttps://eth-mainnet.g.alche

Steps to reproduce

No response

@github-actions github-actions bot added the J2-unconfirmed Issue might be valid, but it’s not yet known. label Jun 19, 2023
@chirag-bgh
Copy link
Author

@bkchr Do you have any insights on this?

@chirag-bgh
Copy link
Author

chirag-bgh commented Jun 20, 2023

Update:
So setting the rpc_url as Bytes in the explorer works instead putting it as String

@gui1117
Copy link
Contributor

gui1117 commented Jun 20, 2023

at a first glance it looks like the value is not encoded as a Vec<u8> but maybe as an u8 array of fixed size or something else.

Because the h seems to be interpreted as the compact length of the vec and thus is missing from the result and then the url is cut too short probably meaning the length of the vec is wrong, because it has been computed from h instead of the correct way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.
Projects
None yet
Development

No branches or pull requests

2 participants