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

fix: setting data root in CreateProposalBlock #1271

Merged
merged 12 commits into from
Apr 23, 2024
Merged

Conversation

cmwaters
Copy link
Contributor

Currently main fails when using celestia-app because the data root that is returned to it wasn't being correctly updated in the header.

This PR fixes this

rootulp
rootulp previously approved these changes Mar 20, 2024
rootulp
rootulp previously approved these changes Mar 20, 2024
abci/types/application.go Show resolved Hide resolved
types/block.go Show resolved Hide resolved
rootulp
rootulp previously approved these changes Mar 20, 2024
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.

Can a unit test verify this in celestia-core or is it only easily test-able from celestia-app?

@cmwaters
Copy link
Contributor Author

Can a unit test verify this in celestia-core or is it only easily test-able from celestia-app?

I think we could have a unit test on this. At least to catch future regressions

@@ -145,10 +144,9 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
}

// update the block with the response from PrepareProposal
block.Data, _ = types.DataFromProto(&cmtproto.Data{
Txs: rpp.Txs[:len(rpp.Txs)-1],
Hash: rpp.Txs[len(rpp.Txs)-1],
Copy link
Contributor

Choose a reason for hiding this comment

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

The Hash is left unset, is it intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. We could probably remove it from the Data struct if we wanted to

Copy link
Contributor

Choose a reason for hiding this comment

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

So, wouldn't that be a breaking behaviour, namely it has been previously set and with the new change it is not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that would be breaking, but it just breaks celestia-app, not downstream users

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually going to revert this because I don't think it makes sense to break app just yet

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. As a follow up, should we consider adding to the specs the ABCI change that moved the data root from a field in the prepare / process proposal response to the last transaction in the list of txs? It looks like we don't currently have specs for our flavor of ABCI in https://celestiaorg.github.io/celestia-app/ so I'm not sure where this addition belongs.

Related: celestiaorg/celestia-app#1066

rootulp
rootulp previously approved these changes Mar 25, 2024
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.

[blocking question]

does this break the PartSetHeader's hash? if so, is this going to be backported / included on v0.34.x? or by main, did you mean celestia-core's main? If it is going to backported, and it does break the PartSetHeader's hash, what effect will that have on the upgrade? perhaps a better question is simply, when are we planning on celestia-app using celestia-core main?

@cmwaters
Copy link
Contributor Author

cmwaters commented Apr 8, 2024

does this break the PartSetHeader's hash?

I don't think so

perhaps a better question is simply, when are we planning on celestia-app using celestia-core main

Most likely for v3

@cmwaters
Copy link
Contributor Author

cmwaters commented Apr 8, 2024

TestByzantineConflictingProposalsWithPartition is failing in a way that I have no idea how it's connected to the changes

@cmwaters
Copy link
Contributor Author

cmwaters commented Apr 8, 2024

What seems to be happening is the following:

We have 4 validators, validator 0 is byzaninte, the remaining are divided into two partitions: Validator 1 in partition A and validator 2 and 3 in partition B.

  • Byzantine validator proposes two different proposals: Block A to partition A and Block B to partition B. It also sends prevotes to both.
  • Partition B reaches 2/3 and eventually produces a block
  • Network is healed (i.e. validator 1 can talk directly to validators 2 and 3)
  • Validator 1 receives 2/3 commits for B and tries to commit B. It sees that the proposal block parts it has (A) doesn't match what the 2/3 committed for (B) and panics

In the tests on main, it for some reason has nil for it's proposal block part so it prints something like:

commit is for a block we do not know about; set ProposalBlock=nil module=consensus validator=1 height=1 commit_round=0 proposal=343D64D40989F3C8A1CCB73D52AE0DAE8EEA1D51EB0443058DA8D9F84701D004 commit=C40D8D242C29FDB14E7B97A9D7C19751D980FF482AF13939BAC305906AF29553

It then sets it's block part header to B and eventually receives B and commits it.

@evan-forbes
Copy link
Member

evan-forbes commented Apr 8, 2024

does this break the PartSetHeader's hash?

I could be wrong, but it appears to since it removes the square size, which we're still including atm

@cmwaters cmwaters marked this pull request as draft April 8, 2024 16:43
@cmwaters
Copy link
Contributor Author

cmwaters commented Apr 17, 2024

does this break the PartSetHeader's hash?

I could be wrong, but it appears to since it removes the square size, which we're still including atm

I'm actually not sure that square size is populated in data (and in the block)

func DataFromProto(dp *cmtproto.Data) (Data, error) {

@cmwaters cmwaters marked this pull request as ready for review April 17, 2024 17:05
@cmwaters cmwaters requested a review from a team as a code owner April 17, 2024 17:05
@@ -96,7 +96,7 @@ func (BaseApplication) ApplySnapshotChunk(req RequestApplySnapshotChunk) Respons

func (BaseApplication) PrepareProposal(req RequestPrepareProposal) ResponsePrepareProposal {
// we use placeholder values for the hash
req.Txs = append(req.Txs, tmhash.Sum(nil))
req.Txs = append(req.Txs, merkle.HashFromByteSlices(req.Txs))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what was causing the test to fail. We were using idential hashes so the blockID.Hash was the same but blockID.PartSetHeader was different

@evan-forbes
Copy link
Member

I'm actually not sure that square size is populated in data (and in the block)

unfortunately for us, we are on v0.34.x-celestia 😭 this was actually the reason why the compact blocks implementation didn't work in testground but did work in the comet e2e tests here

celestia-core/types/block.go

Lines 1097 to 1122 in d3ff8e7

tp.SquareSize = data.SquareSize
tp.Hash = data.hash
return *tp
}
// DataFromProto takes a protobuf representation of Data &
// returns the native type.
func DataFromProto(dp *cmtproto.Data) (Data, error) {
if dp == nil {
return Data{}, errors.New("nil data")
}
data := new(Data)
if len(dp.Txs) > 0 {
txBzs := make(Txs, len(dp.Txs))
for i := range dp.Txs {
txBzs[i] = Tx(dp.Txs[i])
}
data.Txs = txBzs
} else {
data.Txs = Txs{}
}
data.SquareSize = dp.SquareSize

we forgot to remove the square size, which makes upgrading to not using it more complicated than it needed to

@cmwaters
Copy link
Contributor Author

Ah you're right. I was looking at main but I thought I was looking at v1.x. We can revert it and keep it around a bit longer.

rootulp
rootulp previously approved these changes Apr 18, 2024
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. I still think a unit test to verify the fix / prevent regressions would help but can add afterwards

consensus/byzantine_test.go Outdated Show resolved Hide resolved
state/execution.go Outdated Show resolved Hide resolved
evan-forbes
evan-forbes previously approved these changes Apr 18, 2024
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.

do we need to update

BlockProtocol uint64 = 11
)
?

@cmwaters
Copy link
Contributor Author

do we need to update

BlockProtocol uint64 = 11
)

?

I don't think we have any block format changes since I reverted the protos to match v0.34.x-celestia

Co-authored-by: Rootul P <rootulp@gmail.com>
@cmwaters cmwaters dismissed stale reviews from evan-forbes and rootulp via df3328b April 19, 2024 09:25
@cmwaters cmwaters enabled auto-merge (squash) April 23, 2024 12:45
@cmwaters cmwaters merged commit 9ba3fac into main Apr 23, 2024
19 checks passed
@cmwaters cmwaters deleted the cal/fix-setting-data-root branch April 23, 2024 12:50
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