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

Difference with generateTransactionChunksAsync() #9

Open
elliotsayes opened this issue Dec 22, 2022 · 0 comments
Open

Difference with generateTransactionChunksAsync() #9

elliotsayes opened this issue Dec 22, 2022 · 0 comments

Comments

@elliotsayes
Copy link

elliotsayes commented Dec 22, 2022

There is a difference in the data_root generated between generateTransactionChunks() and generateTransactionChunksAsync() when the input data is a multiple of MAX_CHUNK_SIZE. This is because chunkData() in generateTransactionChunks() has an additional zero-length chunk at the end, which in turn influences the output of generateLeaves() => buildLayers() => generateProofs(). The chunks and proofs returned remain identical as they are cleaned up before returning:

// Discard the last chunk & proof if it's zero length.
const lastChunk = chunks.slice(-1)[0];
if (lastChunk.maxByteRange - lastChunk.minByteRange === 0) {
    chunks.splice(chunks.length - 1, 1);
    proofs.splice(proofs.length - 1, 1);
}

I'm not sure if this actually makes a difference in terms of the validity of the transaction, but maybe it is worth mentioning that the outputs of the two functions can sometimes be different.

See the failing test here: master...elliotsayes:arweave-stream-tx:chunk-size-multiple

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

1 participant