Skip to content

Commit

Permalink
Merge branch 'main' into CNS-930-begin-block-may-take-too-long
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-lava committed Mar 28, 2024
2 parents 817e18b + bf25f7d commit d190137
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 210 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
inputs:
release_tag:
description: "The desired tag for the release (e.g. v1.1.0)."
required: true

permissions:
contents: read
Expand All @@ -21,6 +26,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || github.ref_name }}

- name: Fetch all tags
run: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ ecosystem/lavajs/proto/cosmos
ecosystem/lavajs/proto/gogoproto
ecosystem/lavajs/proto/google
ecosystem/lavajs/proto/tendermint
ecosystem/lavajs/proto/cosmos_proto/LICENSE
ecosystem/lavajs/proto/cosmos_proto/README.md



testutil/e2e/sdk/tests/package-lock.json
testutil/e2e/sdk/tests/node_modules.json
Expand Down
204 changes: 0 additions & 204 deletions ecosystem/lavajs/proto/cosmos_proto/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion ecosystem/lavajs/proto/cosmos_proto/README.md

This file was deleted.

3 changes: 2 additions & 1 deletion protocol/chainlib/base_chain_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/lavanet/lava/protocol/chainlib/extensionslib"
"github.com/lavanet/lava/protocol/common"
"github.com/lavanet/lava/utils"
epochstorage "github.com/lavanet/lava/x/epochstorage/types"
pairingtypes "github.com/lavanet/lava/x/pairing/types"
Expand Down Expand Up @@ -299,7 +300,7 @@ func (apip *BaseChainParser) getSupportedApi(name, connectionType string) (*ApiC

// Return an error if spec does not exist
if !ok {
return nil, utils.LavaFormatInfo("api not supported", utils.Attribute{Key: "name", Value: name}, utils.Attribute{Key: "connectionType", Value: connectionType})
return nil, common.APINotSupportedError
}

// Return an error if api is disabled
Expand Down
6 changes: 5 additions & 1 deletion protocol/chainlib/jsonRPC.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (apip *JsonRPCChainParser) ParseMsg(url string, data []byte, connectionType
// Check api is supported and save it in nodeMsg
apiCont, err := apip.getSupportedApi(msg.Method, connectionType)
if err != nil {
return nil, utils.LavaFormatInfo("getSupportedApi jsonrpc failed", utils.LogAttr("reason", err), utils.Attribute{Key: "method", Value: msg.Method})
return nil, utils.LavaFormatWarning("getSupportedApi jsonrpc failed", err, utils.LogAttr("method", msg.Method))
}

apiCollectionForMessage, err := apip.getApiCollection(connectionType, apiCont.collectionKey.InternalPath, apiCont.collectionKey.Addon)
Expand Down Expand Up @@ -458,6 +458,10 @@ func (apil *JsonRPCChainListener) Serve(ctx context.Context, cmdFlags common.Con
reply := relayResult.GetReply()
go apil.logger.AddMetricForHttp(metricsData, err, fiberCtx.GetReqHeaders())
if err != nil {
if common.APINotSupportedError.Is(err) {
return fiberCtx.Status(fiber.StatusOK).JSON(common.JsonRpcMethodNotFoundError)
}

// Get unique GUID response
errMasking := apil.logger.GetUniqueGuidResponseForError(err, msgSeed)

Expand Down
9 changes: 8 additions & 1 deletion protocol/chainlib/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ func (apip *RestChainParser) getSupportedApi(name, connectionType string) (*ApiC

// Return an error if spec does not exist
if !ok {
return nil, errors.New("rest api not supported " + name)
return nil, utils.LavaFormatWarning("rest api not supported", common.APINotSupportedError,
utils.LogAttr("name", name),
utils.LogAttr("connectionType", connectionType),
)
}
api := apiCont.api

Expand Down Expand Up @@ -379,6 +382,10 @@ func (apil *RestChainListener) Serve(ctx context.Context, cmdFlags common.Consum
reply := relayResult.GetReply()
go apil.logger.AddMetricForHttp(analytics, err, fiberCtx.GetReqHeaders())
if err != nil {
if common.APINotSupportedError.Is(err) {
return common.CreateRestMethodNotFoundError(fiberCtx, chainID)
}

// Get unique GUID response
errMasking := apil.logger.GetUniqueGuidResponseForError(err, msgSeed)

Expand Down
4 changes: 3 additions & 1 deletion protocol/chainlib/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/lavanet/lava/protocol/chainlib/chainproxy"
"github.com/lavanet/lava/protocol/chainlib/chainproxy/rpcInterfaceMessages"
"github.com/lavanet/lava/protocol/chainlib/extensionslib"
"github.com/lavanet/lava/protocol/common"
"github.com/lavanet/lava/protocol/parser"
pairingtypes "github.com/lavanet/lava/x/pairing/types"
spectypes "github.com/lavanet/lava/x/spec/types"
Expand Down Expand Up @@ -89,7 +90,8 @@ func TestRestGetSupportedApi(t *testing.T) {
}
_, err = apip.getSupportedApi("API2", connectionType_test)
assert.Error(t, err)
assert.Equal(t, "rest api not supported API2", err.Error())
assert.ErrorIs(t, err, common.APINotSupportedError)
assert.Equal(t, "rest api not supported ErrMsg: api not supported {name:API2,connectionType:test}: api not supported", err.Error())

// Test case 3: Returns error if the API is disabled
apip = &RestChainParser{
Expand Down
6 changes: 5 additions & 1 deletion protocol/chainlib/tendermintRPC.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (apip *TendermintChainParser) ParseMsg(urlPath string, data []byte, connect
// Check api is supported and save it in nodeMsg
apiCont, err := apip.getSupportedApi(msg.Method, connectionType)
if err != nil {
return nil, utils.LavaFormatInfo("getSupportedApi jsonrpc failed", utils.LogAttr("reason", err), utils.Attribute{Key: "method", Value: msg.Method})
return nil, utils.LavaFormatWarning("getSupportedApi jsonrpc failed", err, utils.LogAttr("method", msg.Method))
}

apiCollectionForMessage, err := apip.getApiCollection(connectionType, apiCont.collectionKey.InternalPath, apiCont.collectionKey.Addon)
Expand Down Expand Up @@ -482,6 +482,10 @@ func (apil *TendermintRpcChainListener) Serve(ctx context.Context, cmdFlags comm
go apil.logger.AddMetricForHttp(metricsData, err, fiberCtx.GetReqHeaders())

if err != nil {
if common.APINotSupportedError.Is(err) {
return fiberCtx.Status(fiber.StatusOK).JSON(common.JsonRpcMethodNotFoundError)
}

// Get unique GUID response
errMasking := apil.logger.GetUniqueGuidResponseForError(err, msgSeed)

Expand Down
1 change: 1 addition & 0 deletions protocol/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ var (
StatusCodeError504 = sdkerrors.New("Disallowed StatusCode Error", 504, "Disallowed status code error")
StatusCodeError429 = sdkerrors.New("Disallowed StatusCode Error", 429, "Disallowed status code error")
StatusCodeErrorStrict = sdkerrors.New("Disallowed StatusCode Error", 800, "Disallowed status code error")
APINotSupportedError = sdkerrors.New("APINotSupported Error", 900, "api not supported")
)
Loading

0 comments on commit d190137

Please sign in to comment.