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

Check Slatepack file size before loading contents #495

Merged
merged 1 commit into from
Aug 12, 2020

Conversation

unseddd
Copy link
Contributor

@unseddd unseddd commented Jul 29, 2020

Check Slatepack file size is within valid range before loading contents into memory.

@antiochp
Copy link
Member

Not sure max_block_size is the right thing to base slate size limit off.
A slate will potentially have a max size transaction plus additional data. May be easier to simply hardcode/configure a max size directly in wallet itself.

@unseddd
Copy link
Contributor Author

unseddd commented Jul 29, 2020

Not sure max_block_size is the right thing to base slate size limit off.
A slate will potentially have a max size transaction plus additional data. May be easier to simply hardcode/configure a max size directly in wallet itself.

I had similar reservations about directly basing max Slatepack size on max block size, since the metadata in block is not one-to-one with the metadata in Slatepack. However, hardcoding max size in wallet isn't fool-proof either, and has overhead for any changes to max block size in the node (i.e. developers will have to remember to manually update max Slatepack size).

Ideally, the max Slatepack size would be: MAX_BLOCK - BLOCK_HEADER + SLATEPACK_METADATA (maybe with some extra space for whitespace + >). Though, with Slatepack files, there should be no whitespace, since the files are presumably generated by wallets (not copy-pasted). Slatepack metadata size might be hard to calculate precisely, since it would vary between binary and JSON encoded Slatepacks.

IIUC, the above formula would encode max transaction size + Slatepack metadata size + acceptable whitespace size. WDYT?

@davidtavarez
Copy link
Contributor

It would be nice to write some tests for this.

@unseddd
Copy link
Contributor Author

unseddd commented Jul 30, 2020

Updated with new grin_api::max_tx_size function, and calculation for additional Slatepack metadata. @antiochp let me know what you think.

Copy link
Member

@antiochp antiochp left a comment

Choose a reason for hiding this comment

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

I think this looks good.
One question about where to do the size validation.

libwallet/src/slatepack/packer.rs Outdated Show resolved Hide resolved
@unseddd
Copy link
Contributor Author

unseddd commented Aug 4, 2020

Tests are failing to compile due to grin_core::global::max_tx_weight not being tagged. Tests pass local testing, with some workarounds for versioning, changes unrelated to this PR, etc.

@unseddd unseddd requested a review from antiochp August 4, 2020 00:14
@yeastplume
Copy link
Member

Tests are failing to compile due to grin_core::global::max_tx_weight not being tagged. Tests pass local testing, with some workarounds for versioning, changes unrelated to this PR, et

For dev on master just run cargo update to get the latest version of master from grin core, it'll make changes to Cargo.lock but that's fine at this stage of development

@unseddd
Copy link
Contributor Author

unseddd commented Aug 4, 2020

For dev on master just run cargo update to get the latest version of master from grin core, it'll make changes to Cargo.lock but that's fine at this stage of development

Build still fails due to traits not being in scope or implemented. Any tips on resolving failures like here and here (here or another PR)?

@yeastplume
Copy link
Member

For dev on master just run cargo update to get the latest version of master from grin core, it'll make changes to Cargo.lock but that's fine at this stage of development

Build still fails due to traits not being in scope or implemented. Any tips on resolving failures like here and here (here or another PR)?

hrm.. crap. It looks as if some dependency is trying to pull in a different version of ed25519 dalek then we use. Let me look into this and fix via another PR.

@unseddd
Copy link
Contributor Author

unseddd commented Aug 6, 2020

Let me look into this and fix via another PR.

Sounds good to me, will rebase over the fix.

@yeastplume
Copy link
Member

@unseddd Should be all good now, could you try again rebasing with latest master please?

Check Slatepack file size is within valid range before loading contents
into memory
@unseddd
Copy link
Contributor Author

unseddd commented Aug 10, 2020

@yeastplume the fix worked, many thanks 😄

@yeastplume yeastplume merged commit f29fc93 into mimblewimble:master Aug 12, 2020
bayk added a commit to mwcproject/mwc-wallet that referenced this pull request Jul 31, 2024
… contents (mimblewimble#495)

- Check Slatepack file size is within valid range before loading contents into memory
bayk added a commit to mwcproject/mwc-wallet that referenced this pull request Jul 31, 2024
… contents (mimblewimble#495)

- Check Slatepack file size is within valid range before loading contents into memory
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.

4 participants