-
Notifications
You must be signed in to change notification settings - Fork 262
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
Documentation for subxt-cli and windows. #969
Comments
That is interesting, where exactly did you encounter the error? While downloading the metadata from a node via the CLI or when using it with the |
For substrate in general Windows is a tricky to use and please have look at https://docs.substrate.io/install/windows/ To, echo back what @tadeohepperle said please specify which Windows version you are using, command, subxt CLI version and attach the entire backtrack/error you got. |
Version on both OS's is: I created the files as per instructions: In my project I have:
I tried doing only a single system pallet with similar results (slightly different place where it fails to decode) |
I'd be interested to know; does running I also wonder whether you need to reverse the slash in |
I have provided the two outputs attached in my previous comment. They are very close to identical and all the visible text is the same but there are differences in some of the binary characters. |
Ah so you have, apologies for missing that! Let me have a look... |
I did look into this a bit, and can see various small differences between the metadatas generated. Since the CLI tool in each case is just decoding the bytes via parity-scale-codec and then writing those bytes to stdout, I have no good idea as to why this difference would exist; none of these libraries to my knowledge would have any windows-specific behaviours. It'd be interesting to work out whether the error is in the actual decoding or the writing of bytes to disk (I've been assuming windows is mangling something in the latter but I have no easy way to test this). Can I also confirm that both metadatas were generated from the exact same running node (running on the same OS etc too)? I assume so but just want to rule out any possibility of the node sending something different. |
Yes, the node was running in WSL on the same machine and I ran the command on both OS's one after the other without restarting the node. |
@lexnv / @niklasad1 / @tadeohepperle I don't suppose one of you has a copy of windows somewhere that you could try this on? It'd be good to figure out where the issue is coming from at least :) |
Hi, I did manage to run this experiment on a Windows box. I entered the CLI directory and run the following command:
The only difference here from your input is that I am targeting the official "wss://rpc.polkadot.io:443" endpoint, instead of a local running substrate chain on Windows. I did modify the use subxt::{OnlineClient, PolkadotConfig};
#[subxt::subxt(runtime_metadata_path = "../artifacts/windows_metadata.scale")]
pub mod polkadot {}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client to use:
// Note: this is targeting "wss://rpc.polkadot.io:443", not the local node.
let api = OnlineClient::<PolkadotConfig>::from_url("wss://rpc.polkadot.io:443").await?;
// A query to obtain some contant:
let constant_query = polkadot::constants().system().block_length();
// Obtain the value:
let value = api.constants().at(&constant_query)?;
println!("Block length: {value:?}");
Ok(())
} The result is as expected Block length: BlockLength { max: PerDispatchClass { normal: 3932160, operational: 5242880, mandatory: 5242880 } } I did this both in WSL and plain windows and I used the following instructions to install Rust: This might be an issue related with substrate itself, and I believe we recommend running the node on linux based machines. As Niklas mentioned, there might be some issues related to compatibility in Windows platform. |
Just tried the polkadot url as suggested above. The only difference is I am using the installed subxt cli version subxt metadata --url wss://rpc.polkadot.io:443 > windows-polkadot-metadata.scale The resulting files on Windows and WSL have some byte differences I have not tried to use them but for my own chain I am using the .scale file generated in WSL and using it in my subxt based project in windows without issues, but the scale file generated in windows does not work in either windows or WSL. |
@lexnv did you spot any byte differences when you tried to fetch the metadata via windows versus linux (while running the actual node on linux)? |
There is a difference in the metadata format. The SHA256 differs from the metadata fetched from the polkadot chain:
From the commit fdc0d09 of subxt:
|
@lexnv I installed subxt on both windows and linux in the same way to make sure the same version of subxt is running, with
Both local and remote metadata show the same resulting files. I think the difference encountered before might have been subxt version related? |
I've targeted a local running polkadot node on my Mac machine and fetched the metadata. Indeed the metadata presents differences when using PowerShell on windows, although the linux subsystem outputs the information right. This is related to how Windows redirects output from stdout to a file. To mitigate the differences between Linux and Windows, I've created a path: #1018. To ensure consistency between platforms users can point the |
Thankyou @tadeohepperle and @lexnv for digging into this :) |
I had followed the instructions for using subxt-cli to export the metadata but when I imported the metadata into my project it always showed errors saying it could not understand it. I tried this even with the substrate-node-template with the same results. I eventually tried running subxt-cli in WSL and that seems to have fixed it. So it seems there is some incompatibility with windows. At least temporarily it might be wise to add this to the documentation.
The text was updated successfully, but these errors were encountered: