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: create compact share counter #1657

Merged
merged 7 commits into from
Apr 26, 2023
Merged

feat: create compact share counter #1657

merged 7 commits into from
Apr 26, 2023

Conversation

cmwaters
Copy link
Contributor

@cmwaters cmwaters commented Apr 25, 2023

As part of ADR 020, we need something to iteratively calculate how many shares both pfbs and txs would take up should they be added. This PR creates a CompactShareCounter to perform this job. It would have been also possible to extend the CompactShareSplitter to do this task but we would have needed to add the functionality to "undo" transactions (because they were too large) and this seemed like quite some functionality to add.

Ref: #1214

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@MSevey MSevey requested a review from a team April 25, 2023 17:13
@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2023

Codecov Report

Merging #1657 (0b51d44) into main (bdeba24) will increase coverage by 0.44%.
The diff coverage is 86.45%.

@@            Coverage Diff             @@
##             main    #1657      +/-   ##
==========================================
+ Coverage   51.11%   51.56%   +0.44%     
==========================================
  Files          94       95       +1     
  Lines        5894     5954      +60     
==========================================
+ Hits         3013     3070      +57     
- Misses       2569     2570       +1     
- Partials      312      314       +2     
Impacted Files Coverage Δ
pkg/shares/padding.go 52.08% <52.17%> (-11.56%) ⬇️
pkg/shares/split_compact_shares.go 67.16% <88.23%> (+0.49%) ⬆️
pkg/da/data_availability_header.go 79.09% <100.00%> (+3.43%) ⬆️
pkg/shares/counter.go 100.00% <100.00%> (ø)
pkg/shares/share_splitting.go 64.65% <100.00%> (+2.91%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

evan-forbes
evan-forbes previously approved these changes Apr 25, 2023
Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

makes sense so far! LGTM

Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM after one blocking comment

pkg/da/data_availability_header.go Outdated Show resolved Hide resolved
Comment on lines -75 to -78
tailShares, err := TailPaddingShares(wantShareCount - currentShareCount)
if err != nil {
return nil, err
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

[no change needed] In the past we've observed edge cases where wantShareCount < currentShareCount which will now cause a panic here. Given this code will likely go away soon w/ deterministic square layout I think it's worth just being mindful of it in case it comes up in tests / fuzzing

pkg/shares/counter.go Outdated Show resolved Hide resolved
pkg/shares/counter.go Outdated Show resolved Hide resolved
pkg/shares/counter_test.go Show resolved Hide resolved
Co-authored-by: Rootul P <rootulp@gmail.com>
@MSevey MSevey requested a review from a team April 26, 2023 07:44
Comment on lines +20 to +27
{txs: []coretypes.Tx{newTx(120)}},
{txs: []coretypes.Tx{newTx(appconsts.FirstCompactShareContentSize - 2)}},
{txs: []coretypes.Tx{newTx(appconsts.FirstCompactShareContentSize - 1)}},
{txs: []coretypes.Tx{newTx(appconsts.FirstCompactShareContentSize)}},
{txs: []coretypes.Tx{newTx(appconsts.FirstCompactShareContentSize + 1)}},
{txs: []coretypes.Tx{newTx(appconsts.FirstCompactShareContentSize), newTx(appconsts.ContinuationCompactShareContentSize - 4)}},
{txs: newTxs(1000, 100)},
{txs: newTxs(100, 1000)},
Copy link
Collaborator

Choose a reason for hiding this comment

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

[no change needed] the inputs to this test could also be fuzzed given we just need a random dataLen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I can explore that in a follow up. I think these cover the edge cases that come to mind

@cmwaters cmwaters merged commit f31ee58 into main Apr 26, 2023
27 checks passed
@cmwaters cmwaters deleted the cal/square-1 branch April 26, 2023 15:06
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.

None yet

4 participants