Skip to content

Commit

Permalink
Update data_layer_height to da_height (cosmos#519)
Browse files Browse the repository at this point in the history
* Update data_layer_height to da_height
Resolves: cosmos#345

* Change capitalization
  • Loading branch information
nashqueue authored Sep 9, 2022
1 parent 3420af7 commit 7571cf0
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 85 deletions.
12 changes: 6 additions & 6 deletions da/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ func (d *DataAvailabilityLayerClient) SubmitBlock(block *types.Block) da.ResultS
BaseResult: da.BaseResult{
Code: da.StatusCode(resp.Result.Code),
Message: resp.Result.Message,
DAHeight: resp.Result.DataLayerHeight,
DAHeight: resp.Result.DAHeight,
},
}
}

// CheckBlockAvailability proxies CheckBlockAvailability request to gRPC server.
func (d *DataAvailabilityLayerClient) CheckBlockAvailability(dataLayerHeight uint64) da.ResultCheckBlock {
resp, err := d.client.CheckBlockAvailability(context.TODO(), &dalc.CheckBlockAvailabilityRequest{DataLayerHeight: dataLayerHeight})
func (d *DataAvailabilityLayerClient) CheckBlockAvailability(daHeight uint64) da.ResultCheckBlock {
resp, err := d.client.CheckBlockAvailability(context.TODO(), &dalc.CheckBlockAvailabilityRequest{DAHeight: daHeight})
if err != nil {
return da.ResultCheckBlock{BaseResult: da.BaseResult{Code: da.StatusError, Message: err.Error()}}
}
Expand All @@ -103,8 +103,8 @@ func (d *DataAvailabilityLayerClient) CheckBlockAvailability(dataLayerHeight uin
}

// RetrieveBlocks proxies RetrieveBlocks request to gRPC server.
func (d *DataAvailabilityLayerClient) RetrieveBlocks(dataLayerHeight uint64) da.ResultRetrieveBlocks {
resp, err := d.client.RetrieveBlocks(context.TODO(), &dalc.RetrieveBlocksRequest{DataLayerHeight: dataLayerHeight})
func (d *DataAvailabilityLayerClient) RetrieveBlocks(daHeight uint64) da.ResultRetrieveBlocks {
resp, err := d.client.RetrieveBlocks(context.TODO(), &dalc.RetrieveBlocksRequest{DAHeight: daHeight})
if err != nil {
return da.ResultRetrieveBlocks{BaseResult: da.BaseResult{Code: da.StatusError, Message: err.Error()}}
}
Expand All @@ -122,7 +122,7 @@ func (d *DataAvailabilityLayerClient) RetrieveBlocks(dataLayerHeight uint64) da.
BaseResult: da.BaseResult{
Code: da.StatusCode(resp.Result.Code),
Message: resp.Result.Message,
DAHeight: dataLayerHeight,
DAHeight: daHeight,
},
Blocks: blocks,
}
Expand Down
10 changes: 5 additions & 5 deletions da/grpc/mockserv/mockserv.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ func (m *mockImpl) SubmitBlock(_ context.Context, request *dalc.SubmitBlockReque
resp := m.mock.SubmitBlock(&b)
return &dalc.SubmitBlockResponse{
Result: &dalc.DAResponse{
Code: dalc.StatusCode(resp.Code),
Message: resp.Message,
DataLayerHeight: resp.DAHeight,
Code: dalc.StatusCode(resp.Code),
Message: resp.Message,
DAHeight: resp.DAHeight,
},
}, nil
}

func (m *mockImpl) CheckBlockAvailability(_ context.Context, request *dalc.CheckBlockAvailabilityRequest) (*dalc.CheckBlockAvailabilityResponse, error) {
resp := m.mock.CheckBlockAvailability(request.DataLayerHeight)
resp := m.mock.CheckBlockAvailability(request.DAHeight)
return &dalc.CheckBlockAvailabilityResponse{
Result: &dalc.DAResponse{
Code: dalc.StatusCode(resp.Code),
Expand All @@ -67,7 +67,7 @@ func (m *mockImpl) CheckBlockAvailability(_ context.Context, request *dalc.Check
}

func (m *mockImpl) RetrieveBlocks(context context.Context, request *dalc.RetrieveBlocksRequest) (*dalc.RetrieveBlocksResponse, error) {
resp := m.mock.RetrieveBlocks(request.DataLayerHeight)
resp := m.mock.RetrieveBlocks(request.DAHeight)
blocks := make([]*optimint.Block, len(resp.Blocks))
for i := range resp.Blocks {
blocks[i] = resp.Blocks[i].ToProto()
Expand Down
10 changes: 5 additions & 5 deletions da/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ func (m *DataAvailabilityLayerClient) SubmitBlock(block *types.Block) da.ResultS
}

// CheckBlockAvailability queries DA layer to check data availability of block corresponding to given header.
func (m *DataAvailabilityLayerClient) CheckBlockAvailability(dataLayerHeight uint64) da.ResultCheckBlock {
blocksRes := m.RetrieveBlocks(dataLayerHeight)
func (m *DataAvailabilityLayerClient) CheckBlockAvailability(daHeight uint64) da.ResultCheckBlock {
blocksRes := m.RetrieveBlocks(daHeight)
return da.ResultCheckBlock{BaseResult: da.BaseResult{Code: blocksRes.Code}, DataAvailable: len(blocksRes.Blocks) > 0}
}

// RetrieveBlocks returns block at given height from data availability layer.
func (m *DataAvailabilityLayerClient) RetrieveBlocks(dataLayerHeight uint64) da.ResultRetrieveBlocks {
if dataLayerHeight >= atomic.LoadUint64(&m.daHeight) {
func (m *DataAvailabilityLayerClient) RetrieveBlocks(daHeight uint64) da.ResultRetrieveBlocks {
if daHeight >= atomic.LoadUint64(&m.daHeight) {
return da.ResultRetrieveBlocks{BaseResult: da.BaseResult{Code: da.StatusError, Message: "block not found"}}
}

iter := m.dalcKV.PrefixIterator(getPrefix(dataLayerHeight))
iter := m.dalcKV.PrefixIterator(getPrefix(daHeight))
defer iter.Discard()

var blocks []*types.Block
Expand Down
7 changes: 4 additions & 3 deletions proto/dalc/dalc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dalc;
option go_package = "github.com/celestiaorg/optimint/types/pb/dalc";

import "optimint/optimint.proto";
import "gogoproto/gogo.proto";

enum StatusCode {
STATUS_CODE_UNSPECIFIED = 0;
Expand All @@ -14,7 +15,7 @@ enum StatusCode {
message DAResponse {
StatusCode code = 1;
string message = 2;
uint64 data_layer_height = 3;
uint64 da_height = 3 [(gogoproto.customname) = "DAHeight"];
}

message SubmitBlockRequest {
Expand All @@ -26,7 +27,7 @@ message SubmitBlockResponse {
}

message CheckBlockAvailabilityRequest {
uint64 data_layer_height = 1;
uint64 da_height = 1 [(gogoproto.customname) = "DAHeight"];
}

message CheckBlockAvailabilityResponse {
Expand All @@ -35,7 +36,7 @@ message CheckBlockAvailabilityResponse {
}

message RetrieveBlocksRequest {
uint64 data_layer_height = 1;
uint64 da_height = 1 [(gogoproto.customname) = "DAHeight"];
}

message RetrieveBlocksResponse {
Expand Down
Loading

0 comments on commit 7571cf0

Please sign in to comment.