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: add additonal validity checks during process proposal #1128

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions app/process_proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,63 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) abci.ResponsePr

tx, err := app.txConfig.TxDecoder()(malleatedTx.Tx)
if err != nil {
// we don't reject the block here because it is not a block validity
// rule that all transactions included in the block data are
// decodable
continue
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
Comment on lines -82 to +84
Copy link
Member

Choose a reason for hiding this comment

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

still thinking about this 🤔 but its probably the correct move. All transactions with an index wrapped around them must be decodable

}

var checkedTx bool

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

if !checkedTx {
err = tx.ValidateBasic()
if err != nil {
app.Logger().Error("Tx including MsgPayForBlob is invalid")
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
}

response := app.BaseApp.CheckTx(abci.RequestCheckTx{
Tx: rawTx,
Type: abci.CheckTxType_New,
})
Comment on lines +103 to +106
Copy link
Member

Choose a reason for hiding this comment

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

[blocking]
We can not use CheckTx here, as it uses its own copy of the state, not the actual state! I think its very probable that this would not be deterministic, since the check tx state depends on which txs that validator has added to their mempool.

we also only need to check the signature, and therefore also looking up the account.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah makes sense, I will revert to previous changes


if response.GasUsed > response.GasWanted {
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
}
Comment on lines +108 to +112
Copy link
Member

@evan-forbes evan-forbes Dec 22, 2022

Choose a reason for hiding this comment

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

let's only check the signature for now as state in the target issue. As a side note, the gas used in check tx isn't 100% accurate


checkedTx = true
}

pfb, ok := msg.(*types.MsgPayForBlob)
if !ok {
app.Logger().Error("Msg type does not match MsgPayForBlob URL")
continue
}

if err = pfb.ValidateBasic(); err != nil {
logInvalidPropBlockError(app.Logger(), req.Header, "invalid MsgPayForBlob", err)
signers := msg.GetSigners()
if len(signers) != 1 {
Copy link
Member

Choose a reason for hiding this comment

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

why are we rejecting txs that have more than one signer?

logInvalidPropBlockError(app.Logger(), req.Header, "cannot have multiple signers for MsgPayForBlob", err)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
}

signer, err := sdk.AccAddressFromBech32(pfb.Signer)
if err != nil {
// this panic should be unreachable
panic("signer address validation should not fail after basic validation has already been done")
}

if !bytes.Equal(signer, signers[0]) {
Copy link
Member

Choose a reason for hiding this comment

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

why are we checking the signer here?

logInvalidPropBlockError(app.Logger(), req.Header, "invalid signer for MsgPayForBlob", err)
return abci.ResponseProcessProposal{
Result: abci.ResponseProcessProposal_REJECT,
}
Expand Down