Skip to content

Commit

Permalink
Merge branch 'main' into PRT-blockParser-warning-suppress-on-hash
Browse files Browse the repository at this point in the history
  • Loading branch information
shleikes authored Nov 7, 2024
2 parents 08d5cdf + c57c9f8 commit 71aa047
Show file tree
Hide file tree
Showing 57 changed files with 1,549 additions and 343 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const (
var Upgrades = []upgrades.Upgrade{
upgrades.Upgrade_3_1_0,
upgrades.Upgrade_4_0_0,
upgrades.Upgrade_4_1_0,
}

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down
6 changes: 6 additions & 0 deletions app/upgrades/empty_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ var Upgrade_4_0_0 = Upgrade{
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}

var Upgrade_4_1_0 = Upgrade{
UpgradeName: "v4.1.0",
CreateUpgradeHandler: defaultUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}
1 change: 1 addition & 0 deletions cmd/lavap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func main() {
testCmd.AddCommand(connection.CreateTestConnectionServerCobraCommand())
testCmd.AddCommand(connection.CreateTestConnectionProbeCobraCommand())
testCmd.AddCommand(monitoring.CreateHealthCobraCommand())
testCmd.AddCommand(monitoring.CreateChainHeightsCommand())
testCmd.AddCommand(loadtest.CreateTestLoadCobraCommand())

rootCmd.AddCommand(cache.CreateCacheCobraCommand())
Expand Down
216 changes: 216 additions & 0 deletions cookbook/specs/celestia.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,132 @@
"add_on": ""
},
"apis": [
{
"name": "/celestia/minfee/v1/min_gas_price",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "/ibc/apps/packetforward/v1/params",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "/celestia/core/v1/tx/{tx_id}",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "/cosmos/mint/v1beta1/inflation_rate",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "/cosmos/mint/v1beta1/genesis_time",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "/signal/v1/tally/{version}",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "/signal/v1/upgrade",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "/blob/v1/params",
"block_parsing": {
Expand Down Expand Up @@ -382,6 +508,24 @@
},
"extra_compute_units": 0
},
{
"name": "celestia.core.v1.tx.Tx/TxStatus",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": false,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "celestia.qgb.v1.Query/LatestValsetRequestBeforeNonce",
"block_parsing": {
Expand Down Expand Up @@ -418,6 +562,24 @@
},
"extra_compute_units": 0
},
{
"name": "packetforward.v1.Query/Params",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "celestia.qgb.v1.Query/LatestDataCommitment",
"block_parsing": {
Expand Down Expand Up @@ -454,6 +616,60 @@
},
"extra_compute_units": 0
},
{
"name": "celestia.signal.v1.Query/GetUpgrade",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "celestia.signal.v1.Query/VersionTally",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "celestia.minfee.v1.Querycelestia.minfee.v1.Query/NetworkMinGasPrice",
"block_parsing": {
"parser_arg": [
"latest"
],
"parser_func": "DEFAULT"
},
"compute_units": 10,
"enabled": true,
"category": {
"deterministic": true,
"local": false,
"subscription": false,
"stateful": 0
},
"extra_compute_units": 0
},
{
"name": "celestia.mint.v1.Query/GenesisTime",
"block_parsing": {
Expand Down
4 changes: 4 additions & 0 deletions protocol/chainlib/chain_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type baseChainMessageContainer struct {
resultErrorParsingMethod func(data []byte, httpStatusCode int) (hasError bool, errorMessage string)
}

func (bcnc *baseChainMessageContainer) GetRequestedBlocksHashes() []string {
return bcnc.requestedBlockHashes
}

func (bcnc *baseChainMessageContainer) SubscriptionIdExtractor(reply *rpcclient.JsonrpcMessage) string {
return bcnc.msg.SubscriptionIdExtractor(reply)
}
Expand Down
1 change: 1 addition & 0 deletions protocol/chainlib/chainlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type ChainMessage interface {
SetForceCacheRefresh(force bool) bool
CheckResponseError(data []byte, httpStatusCode int) (hasError bool, errorMessage string)
GetRawRequestHash() ([]byte, error)
GetRequestedBlocksHashes() []string

ChainMessageForSend
}
Expand Down
8 changes: 8 additions & 0 deletions protocol/chainlib/chainlib_mock.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (jm JsonrpcMessage) CheckResponseError(data []byte, httpStatusCode int) (ha
utils.LavaFormatWarning("Failed unmarshalling CheckError", err, utils.LogAttr("data", string(data)))
return false, ""
}
if result.Error == nil {
if result.Error == nil { // no error
return false, ""
}
return result.Error.Message != "", result.Error.Message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,37 @@ func (cp TendermintrpcMessage) GetParams() interface{} {
return cp.Params
}

type TendermintMessageResponseBody struct {
Code int `json:"code,omitempty"`
Log string `json:"log,omitempty"`
}

type TendermintMessageResponse struct {
Response TendermintMessageResponseBody `json:"response,omitempty"`
}

// returns if error exists and
func (jm TendermintrpcMessage) CheckResponseError(data []byte, httpStatusCode int) (hasError bool, errorMessage string) {
result := &JsonrpcMessage{}
err := json.Unmarshal(data, result)
if err != nil {
utils.LavaFormatWarning("Failed unmarshalling CheckError", err, utils.LogAttr("data", string(data)))
return false, ""
}

if result.Error == nil { // no error
if result.Result != nil { // check if we got a tendermint error
tendermintResponse := &TendermintMessageResponse{}
err := json.Unmarshal(result.Result, tendermintResponse)
if err == nil {
return (tendermintResponse.Response.Code != 0 && tendermintResponse.Response.Log != ""), tendermintResponse.Response.Log
}
}
return false, ""
}
return result.Error.Message != "", result.Error.Message
}

func (tm TendermintrpcMessage) GetResult() json.RawMessage {
if tm.Error != nil {
utils.LavaFormatWarning("GetResult() Request got an error from the node", nil, utils.Attribute{Key: "error", Value: tm.Error})
Expand Down
2 changes: 2 additions & 0 deletions protocol/chainlib/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ const (
relayMsgLogMaxChars = 200
RPCProviderNodeAddressHash = "Lava-Provider-Node-Address-Hash"
RPCProviderNodeExtension = "Lava-Provider-Node-Extension"
RpcProviderLoadRateHeader = "Lava-Provider-Load-Rate"
RpcProviderUniqueIdHeader = "Lava-Provider-Unique-Id"
WebSocketExtension = "websocket"
)

var (
TrailersToAddToHeaderResponse = []string{RPCProviderNodeExtension, RpcProviderLoadRateHeader}
InvalidResponses = []string{"null", "", "nil", "undefined"}
FailedSendingSubscriptionToClients = sdkerrors.New("failed Sending Subscription To Clients", 1015, "Failed Sending Subscription To Clients connection might have been closed by the user")
NoActiveSubscriptionFound = sdkerrors.New("failed finding an active subscription on provider side", 1016, "no active subscriptions for hashed params.")
Expand Down
2 changes: 1 addition & 1 deletion protocol/chainlib/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (apip *GrpcChainParser) ParseMsg(url string, data []byte, connectionType st
// Check API is supported and save it in nodeMsg.
apiCont, err := apip.getSupportedApi(url, connectionType)
if err != nil {
return nil, utils.LavaFormatError("failed to getSupportedApi gRPC", err)
return nil, utils.LavaFormatError("failed to getSupportedApi gRPC", err, utils.LogAttr("url", url), utils.LogAttr("connectionType", connectionType))
}

apiCollection, err := apip.getApiCollection(connectionType, apiCont.collectionKey.InternalPath, apiCont.collectionKey.Addon)
Expand Down
1 change: 1 addition & 0 deletions protocol/common/cobra_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const (
// websocket flags
RateLimitWebSocketFlag = "rate-limit-websocket-requests-per-connection"
BanDurationForWebsocketRateLimitExceededFlag = "ban-duration-for-websocket-rate-limit-exceeded"
RateLimitRequestPerSecondFlag = "rate-limit-requests-per-second"
)

const (
Expand Down
1 change: 1 addition & 0 deletions protocol/common/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
MaximumConcurrentProvidersFlagName = "concurrent-providers"
StatusCodeMetadataKey = "status-code"
VersionMetadataKey = "lavap-version"
LavaChainIdMetadataKey = "lavap-chain-id"
TimeOutForFetchingLavaBlocksFlag = "timeout-for-fetching-lava-blocks"
)

Expand Down
2 changes: 1 addition & 1 deletion protocol/integration/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func createRpcProvider(t *testing.T, ctx context.Context, rpcProviderOptions rpc
chainTracker.StartAndServe(ctx)
reliabilityManager := reliabilitymanager.NewReliabilityManager(chainTracker, &mockProviderStateTracker, rpcProviderOptions.account.Addr.String(), chainRouter, chainParser)
mockReliabilityManager := NewMockReliabilityManager(reliabilityManager)
rpcProviderServer.ServeRPCRequests(ctx, rpcProviderEndpoint, chainParser, rws, providerSessionManager, mockReliabilityManager, rpcProviderOptions.account.SK, cache, chainRouter, &mockProviderStateTracker, rpcProviderOptions.account.Addr, rpcProviderOptions.lavaChainID, rpcprovider.DEFAULT_ALLOWED_MISSING_CU, nil, nil, nil, false)
rpcProviderServer.ServeRPCRequests(ctx, rpcProviderEndpoint, chainParser, rws, providerSessionManager, mockReliabilityManager, rpcProviderOptions.account.SK, cache, chainRouter, &mockProviderStateTracker, rpcProviderOptions.account.Addr, rpcProviderOptions.lavaChainID, rpcprovider.DEFAULT_ALLOWED_MISSING_CU, nil, nil, nil, false, nil)
listener := rpcprovider.NewProviderListener(ctx, rpcProviderEndpoint.NetworkAddress, "/health")
err = listener.RegisterReceiver(rpcProviderServer, rpcProviderEndpoint)
require.NoError(t, err)
Expand Down
Loading

0 comments on commit 71aa047

Please sign in to comment.