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(manager): stop using state info numblock to calculate batch end height #1100

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions proto/types/dymensionxyz/dymension/rollapp/state_info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ message StateInfo {
string sequencer = 2;
// startHeight is the block height of the first block in the batch
uint64 startHeight = 3;
// numBlocks is the number of blocks included in this batch update
uint64 numBlocks = 4;

reserved 4;
// DAPath is the description of the location on the DA layer
string DAPath = 5;

Expand Down
2 changes: 1 addition & 1 deletion settlement/dymension/dymension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestPostBatch(t *testing.T) {
}
rollappQueryClientMock.On("StateInfo", mock.Anything, mock.Anything).Return(
&rollapptypes.QueryGetStateInfoResponse{StateInfo: rollapptypes.StateInfo{
StartHeight: batch.StartHeight(), StateInfoIndex: rollapptypes.StateInfoIndex{Index: 1}, DAPath: daMetaData.ToPath(), NumBlocks: 1,
StartHeight: batch.StartHeight(), StateInfoIndex: rollapptypes.StateInfoIndex{Index: 1}, DAPath: daMetaData.ToPath(),
}},
nil)
} else {
Expand Down
8 changes: 7 additions & 1 deletion settlement/dymension/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ func convertStateInfoToResultRetrieveBatch(stateInfo *rollapptypes.StateInfo) (*
if err != nil {
return nil, err
}

Copy link
Contributor

@omritoptix omritoptix Oct 1, 2024

Choose a reason for hiding this comment

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

Suggested change
// We're populating the endHeight here with the assumption that state info must contain at least one block and that BDs are in ascending order

endHeight := uint64(0)
if len(stateInfo.BDs.BD) > 0 {
endHeight = stateInfo.BDs.BD[len(stateInfo.BDs.BD)-1].Height
}

batchResult := &settlement.Batch{
Sequencer: stateInfo.Sequencer,
StartHeight: stateInfo.StartHeight,
EndHeight: stateInfo.StartHeight + stateInfo.NumBlocks - 1,
EndHeight: endHeight,
MetaData: &settlement.BatchMetaData{
DA: daMetaData,
},
Expand Down
110 changes: 37 additions & 73 deletions types/pb/dymensionxyz/dymension/rollapp/state_info.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/pb/dymint/state.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading