Skip to content

Erasure coding test vectors - #74

Merged
davxy merged 17 commits into
masterfrom
erasure_coding
Jun 24, 2025
Merged

davxy merged 17 commits into
masterfrom
erasure_coding

Conversation

@davxy

@davxy davxy commented Jun 8, 2025

Copy link
Copy Markdown
Owner

@davxy
davxy marked this pull request as ready for review June 8, 2025 14:19
@davxy
davxy marked this pull request as draft June 8, 2025 15:49
@davxy
davxy marked this pull request as ready for review June 9, 2025 21:48
sourabhniyogi added a commit to jam-duna/coreplay that referenced this pull request Jun 11, 2025
sourabhniyogi added a commit to jam-duna/coreplay that referenced this pull request Jun 11, 2025
Same algorithm but input sizes are 3, 10, 32, 100, 272, 4096, 4104, 10000 
  davxy/jam-test-vectors#74
Tiny only for now
@sourabhniyogi

sourabhniyogi commented Jun 11, 2025

Copy link
Copy Markdown

Thank you for updating GP to match what polkajam is actually doing, and making the test set a bit bigger.

We must care about efficiency of the erasure encoding and decoding.

Can you suggest a way of improving this: (which generates your test
https://github.com/jam-duna/jamtestnet/blob/main/erasurecoding/src/lib.rs#L29-L44
so that its efficient? By "efficient" I mean that I want just one call to encode, not k calls to encode, which you get from this actually simple solution (and is surely how this package is intended to be used):

        let shard_size = d_bytes.len() / C;
        let k = d_bytes.len() / W_E;
        let mut original_shards: Vec<Vec<u8>> = vec![Vec::with_capacity(2 * k); C];
        let mut recovery_shards: Vec<Vec<u8>> = vec![Vec::with_capacity(2 * k); V - C];

        let mut encoder = ReedSolomonEncoder::new(C, V - C, shard_size)?;
        for i in 0..C {
            let shard: Vec<u8> = d_bytes[i * shard_size..(i + 1) * shard_size].to_vec();
            encoder.add_original_shard(&shard)?;
            original_shards[i].extend_from_slice(&shard);
        }
        let encoded = encoder.encode()?;
        for (j, shard) in encoded.recovery_iter().enumerate() {
                recovery_shards[j].extend_from_slice(shard);
        }

But it doesn't get the same result as your test vectors. You mentioned shard sizes but I wasn't sure what to do with that. I'm probably missing something basic: What is it?

@jaymansfield

Copy link
Copy Markdown

JavaJAM passes these. Thanks @davxy.

@davxy

davxy commented Jun 18, 2025

Copy link
Copy Markdown
Owner Author

JavaJAM passes these. Thanks @davxy.

Hey @jaymansfield what lib are you using for erasure coding?

@jaymansfield

Copy link
Copy Markdown

JavaJAM passes these. Thanks @davxy.

Hey @jaymansfield what lib are you using for erasure coding?

reed-solomon-simd 3.0.1

@davxy

davxy commented Jun 19, 2025

Copy link
Copy Markdown
Owner Author

JavaJAM passes these. Thanks @davxy.

Hey @jaymansfield what lib are you using for erasure coding?

reed-solomon-simd 3.0.1

Alright, it seems like everyone is using it. At some point I'll try to implement a simple reference version in Python , since that library is doing some performance optimization voodoo that I haven't really looked into. We want to make sure it's actually compliant with what the GP specifies.

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

Successfully merging this pull request may close these issues.

3 participants