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

Message inclusion check #216

Merged
merged 21 commits into from
May 5, 2022
Merged

Message inclusion check #216

merged 21 commits into from
May 5, 2022

Conversation

evan-forbes
Copy link
Member

@evan-forbes evan-forbes commented Feb 18, 2022

Description

This PR creates a consensus time message inclusion check using the new ProcessProposal ABCI++ method.

It's worth noting that this check does not actually check that the commitment to the data is an actual subtree root to the data commitment, because 1) we aren't actually filling the square according to the non-interactive default rules yet and 2) the specs specifically describes the non-interactive rules as not consensus critical, unlike message inclusion. However, we can eventually make those rules consensus critical using the same ABCI method if that's something we want to do.

It's also worth noting that this check does not ensure that the MsgPayForMessage that it is checking the messages against is actually valid. This means that if a validator wanted to, they could produce a block that has an invalid MsgPayForMessage, which therefore wouldn't pay for the message, but the message does get included in the block. In order to check if the MsgPayForMessage is valid, I think we might have wait for immediate execution.

This PR also only uses the normal integration test, meaning that the happy case is tested for implicitly if the test passes, but the cases where the block should be rejected do not have integration/liveness tests. We can either write an issue to do this in a different PR or we can add these integration tests to this PR.

closes #205

Comment on lines 19 to 40
// extract the commitments from any MsgPayForMessages in the block
commitments := make(map[string]struct{})
for _, rawTx := range req.BlockData.Txs {
tx, err := app.txConfig.TxDecoder()(rawTx)
if err != nil {
continue
}

for _, msg := range tx.GetMsgs() {
if sdk.MsgTypeURL(msg) != types.URLMsgPayforMessage {
continue
}

pfm, ok := msg.(*types.MsgPayForMessage)
if !ok {
continue
}

commitments[string(pfm.MessageShareCommitment)] = struct{}{}
}

}
Copy link
Member Author

@evan-forbes evan-forbes Feb 18, 2022

Choose a reason for hiding this comment

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

using this mechanism also makes it so that two identical messages included in the same block are invalid. Is that something we want? If so, I can add a specific test for this, along with making it so block producers don't accidentally do this. If not, then we can fix this before merging.

cc @adlerjohn

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any reason to forbid including two of the same message in the same block, so long as they're paid for. That being said, a block proposer could be tricky and make both PayForMessage txs in the block point to the same message! An interesting corner case. Can you file an issue...somewhere...to re-visit this? And document your decision (forbid or allow, doesn't really matter, impl detail) in the code with a link to the issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

#226

will update this PR tmrw to make the default behavior to exclude the identical message, but keep the payments

Copy link
Member Author

@evan-forbes evan-forbes Apr 27, 2022

Choose a reason for hiding this comment

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

update to this, I just ended up taking the easier option, f3b543f in which we count the commitments using a counter instead of relying on a map, this way we also count identical commitments and I think things work intuitively. Intuitively being that identical messages get included twice and each PayForData must have a corresponding message.

we should still make a formal decision with #226

@adlerjohn
Copy link
Member

adlerjohn commented Feb 28, 2022

If there are outstanding TODOs can we convert this to draft?

@evan-forbes evan-forbes marked this pull request as draft February 28, 2022 06:26
Base automatically changed from evan/ABCI++ to master April 8, 2022 10:38
@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2022

Codecov Report

Merging #216 (f6661b1) into master (d7bb393) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #216   +/-   ##
=======================================
  Coverage   25.86%   25.86%           
=======================================
  Files          12       12           
  Lines        1840     1840           
=======================================
  Hits          476      476           
  Misses       1326     1326           
  Partials       38       38           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d7bb393...f6661b1. Read the comment docs.

@evan-forbes evan-forbes marked this pull request as ready for review April 27, 2022 15:23
app/process_proposal.go Outdated Show resolved Hide resolved
app/process_proposal.go Outdated Show resolved Hide resolved
app/process_proposal.go Outdated Show resolved Hide resolved
app/process_proposal.go Outdated Show resolved Hide resolved
app/process_proposal.go Outdated Show resolved Hide resolved
app/process_proposal.go Outdated Show resolved Hide resolved
app/process_proposal.go Outdated Show resolved Hide resolved
evan-forbes and others added 2 commits April 27, 2022 19:56
Co-authored-by: Ismail Khoffi <[email protected]>
Co-authored-by: Ismail Khoffi <[email protected]>
evan-forbes and others added 5 commits April 27, 2022 19:57
Co-authored-by: John Adler <[email protected]>
Co-authored-by: John Adler <[email protected]>
Co-authored-by: John Adler <[email protected]>
Co-authored-by: John Adler <[email protected]>
Co-authored-by: Ismail Khoffi <[email protected]>
app/process_proposal.go Outdated Show resolved Hide resolved
@adlerjohn adlerjohn requested review from liamsi and adlerjohn April 30, 2022 01:24
Copy link
Member

@adlerjohn adlerjohn left a comment

Choose a reason for hiding this comment

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

nits

app/process_proposal.go Outdated Show resolved Hide resolved
app/process_proposal.go Outdated Show resolved Hide resolved
evan-forbes and others added 2 commits May 2, 2022 15:06
Co-authored-by: John Adler <[email protected]>
Co-authored-by: John Adler <[email protected]>
Copy link
Member

@adlerjohn adlerjohn left a comment

Choose a reason for hiding this comment

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

utACK

app/process_proposal.go Outdated Show resolved Hide resolved
app/process_proposal.go Show resolved Hide resolved
Copy link
Member

@adlerjohn adlerjohn left a comment

Choose a reason for hiding this comment

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

Approved by accident 😂

@evan-forbes evan-forbes merged commit b2617e4 into master May 5, 2022
@evan-forbes evan-forbes deleted the evan/message-inclusion branch May 5, 2022 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Check for message inclusion before committing to a block
4 participants