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

Ignore oversize transaction batches #62

Merged
merged 3 commits into from
Mar 4, 2021

Conversation

xandkar
Copy link
Contributor

@xandkar xandkar commented Feb 12, 2021

Pre-merge TODO:

Resolves: helium/miner#566

@xandkar xandkar marked this pull request as draft February 12, 2021 22:05
@Vagabond
Copy link
Contributor

I guessing this needs a rebase now #61 is merged?

src/hbbft.erl Outdated
@@ -355,6 +355,8 @@ handle_msg(Data = #hbbft_data{round=R}, J, {dec, R, I, Share}) ->
failed_decrypt=[I|Data#hbbft_data.failed_decrypt]});
Decrypted ->
case decode_list(Decrypted, []) of
[_ | Transactions] when length(Transactions) > Data#hbbft_data.batch_size ->
ignore;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we ignore or truncate here? @evanmcc thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's a good question! I'm not actually sure what would be best. my feeling is that either is fine? dropping makes it a lot easier to test, and maybe easier to make deterministic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Vagabond If we truncate, how do we know which to drop and which to keep? If I'm following the chain of calls correctly - from here it would go into {result, {transactions, ... which the miner in turn accepts as final.

Copy link
Contributor

Choose a reason for hiding this comment

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

you could just truncate to the first batch size elements, the commitment is already agreed to so everyone will have the same batch, in the same order.

Dropping is probably fine though.

@xandkar xandkar force-pushed the xandkar/ignore-oversize-txn-batches branch 2 times, most recently from 91940e6 to fd5e3be Compare February 18, 2021 16:37
@xandkar xandkar changed the title [draft] Ignore oversize transaction batches Ignore oversize transaction batches Feb 18, 2021
@xandkar xandkar marked this pull request as ready for review February 19, 2021 21:38
@xandkar xandkar force-pushed the xandkar/ignore-oversize-txn-batches branch from efcc8c4 to f677cc5 Compare February 22, 2021 19:48
test/hbbft_SUITE.erl Outdated Show resolved Hide resolved
@xandkar xandkar force-pushed the xandkar/ignore-oversize-txn-batches branch from 2517352 to 1fa9fda Compare February 23, 2021 19:24
@xandkar xandkar force-pushed the xandkar/ignore-oversize-txn-batches branch 4 times, most recently from c7384df to f7216bf Compare February 25, 2021 00:05
@xandkar xandkar requested a review from vihu March 1, 2021 20:16
src/hbbft.erl Outdated Show resolved Hide resolved
@@ -346,7 +376,20 @@ handle_msg(Data = #hbbft_data{round=R}, J, {dec, R, I, Share}) ->
check_completion(Data#hbbft_data{dec_shares=NewShares, decrypted=NewDecrypted,
failed_decrypt=[I|Data#hbbft_data.failed_decrypt]});
Decrypted ->
#hbbft_data{batch_size=B, n=N} = Data,
Copy link
Member

Choose a reason for hiding this comment

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

Just nitpicking and I know we don't do it anywhere in the module (we should have) but it would be nice to have accessor funs for hbbft_data record imo. So like batch_size(Data), num_nodes(Data) etc perhaps? Similarly, we can then just have B div N calculated in a separate fun or whatever and check whether the transactions length exceeds.

Maybe a thing to do as a simplification pass in another PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it.

Definitely better done in a separate PR though, since it'll be a much larger diff and will further obscure the point of this one (I already did some nonessential things, like reformatting the signature (though it kind of was essential for my reading of it)).

Copy link
Contributor

Choose a reason for hiding this comment

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

File an issue to remind us?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Vagabond Done: #64

Copy link
Member

@vihu vihu left a comment

Choose a reason for hiding this comment

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

lgtm 👍 , just a couple minor comments

test/hbbft_SUITE.erl Outdated Show resolved Hide resolved
test/hbbft_SUITE.erl Outdated Show resolved Hide resolved
Copy link
Contributor

@evanmcc evanmcc left a comment

Choose a reason for hiding this comment

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

other than the test printing nits this seems good.

@xandkar xandkar force-pushed the xandkar/ignore-oversize-txn-batches branch from 630e165 to ee2c80f Compare March 4, 2021 16:22
@xandkar xandkar merged commit 480ff1d into master Mar 4, 2021
@xandkar xandkar deleted the xandkar/ignore-oversize-txn-batches branch March 4, 2021 19:58
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.

Reject oversize txn batches from consensus members
4 participants