stellar-rust-sdk icon indicating copy to clipboard operation
stellar-rust-sdk copied to clipboard

Stellar XDR Types

Open choubacha opened this issue 6 years ago • 11 comments

They have a set of XDR types here: https://github.com/stellar/stellar-core/blob/master/src/xdr/Stellar-types.x

We should model them in rust as best as possible and demonstrate the ability to pack and unpack them. The stellar go library has some tests around all xdr here:

https://github.com/stellar/go/tree/master/xdr

I wish they had tests in the core library for it was well ☹️ They also appear to duplicate the xdr files into every repo that they are used in, likely because they use xdrgen.

choubacha avatar Mar 11 '18 16:03 choubacha

Can build some XDR here: https://www.stellar.org/laboratory/#txbuilder?network=test

choubacha avatar Mar 11 '18 16:03 choubacha

Can confirm we use https://github.com/stellar/xdrgen.

robertDurst avatar Apr 19 '18 23:04 robertDurst

This is awesome. I just learned today that parts of stellar are built in rust and was curious to know if you all had put something like this together already 👍

correlator avatar Apr 19 '18 23:04 correlator

@robertDurst What does that mean? Can it generate rust code?

choubacha avatar Apr 19 '18 23:04 choubacha

@correlator nope, none of our codebase is rust -- at least not until I get good enough to push for change 😁

@kbacha so I talked to one of our devs and this is what we use for xdrgen for various languages -- js, go, and a couple others. This is different than Rust's XDRGEN because that XDRGEN isn't adapted or built for specific encodings or definitions for xdr within the stellar codebase.

I just got the lowdown from one of our devs on how to get started adding rust support https://github.com/stellar/xdrgen and am going to take this on.

robertDurst avatar Apr 20 '18 15:04 robertDurst

That's awesome! That's the missing piece and I wasn't getting any feedback on the rust library.

Let me know how I can help, I'm actually coming from a ruby background so working in that library looks pretty easy.

choubacha avatar Apr 20 '18 17:04 choubacha

Awesome! I skimmed the code and it looks quite doable -- while I have never written any ruby, this is quite easy to read.

Happy to collaborate, the goal here is to ultimately send a PR here for rust support!

Going to give this a go myself this weekend.

robertDurst avatar Apr 21 '18 01:04 robertDurst

Work is being done on this branch https://github.com/kbacha/xdrgen/tree/rust

correlator avatar May 06 '18 02:05 correlator

Exciting!

robertDurst avatar May 06 '18 03:05 robertDurst

FYI, I have created a crate with generated rust code from the Stellar XDR. I had to hand-modify the XDR input files to get around issues in xdrgen with unnamed unions and structs. I must admit that I have not done in-depth testing, but I have verified the code does decode a CreateAccount transaction correctly. Feel free to comment on the project.

https://github.com/thorhs/rust-stellar-xdr

thorhs avatar Sep 14 '19 23:09 thorhs

@thorhs Excellent! I'll take a look in a few weeks. I've been on parental leave caring for my new child.

choubacha avatar Oct 11 '19 16:10 choubacha