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

feat: added spanValue for BMT smart contracts #11

Closed
wants to merge 5 commits into from

Conversation

molekilla
Copy link

  • spanValue is a little endian of 8 bytes value to support BMT smart contracts in Solidity

Reference:
#10

@molekilla molekilla requested a review from nugaon May 24, 2022 14:39
@molekilla molekilla force-pushed the span-value-solidity branch from 50969d6 to 9f239be Compare May 24, 2022 14:51
package.json Outdated
"@types/jest": "^27.4.1",
"@types/terser-webpack-plugin": "^5.2.0",
"@types/webpack-bundle-analyzer": "^4.4.1",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"babel-jest": "^27.5.1",
"babel-loader": "^8.2.3",
"bn.js": "^5.2.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it in the devDependencies when you use it in the application logic?

src/file.ts Outdated
chunkInclusionProofs.push({
sisterSegments,
span: chunk.span(),
spanValue: new BN(chunk.span()).toBuffer('le', 8),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't use external library for these kind of problems. can you solve it with DataView usage or with other basic API functions?
Moreover, it has to work in browser envrionment as well, and the toBuffer's JSDoc suggests different method to use...

src/file.ts Outdated

export interface ChunkInclusionProof<SpanLength extends number = typeof DEFAULT_SPAN_SIZE> {
span: Bytes<SpanLength>
spanValue: Uint8Array
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is very confusing, we have an Uint8Array value with span and another Uint8Array with name spanValue....

@molekilla molekilla requested a review from nugaon May 25, 2022 14:32
@nugaon
Copy link
Collaborator

nugaon commented May 26, 2022

you have to keep littleEndian for span serialization of swarm hashes, and create a helper method to serialize the span value into bigEndian if you need.

Even better would be maybe a breaking change, where we keep spanValue as number | BigInt, but for that, you have to make the span serialization in the logic.

@molekilla
Copy link
Author

resolved by fairDataSociety/fdp-contracts@e44adf0

@molekilla molekilla closed this May 26, 2022
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.

2 participants