diff --git a/cookbook/specs/solana.json b/cookbook/specs/solana.json old mode 100644 new mode 100755 index e6b596641d..5089de1331 --- a/cookbook/specs/solana.json +++ b/cookbook/specs/solana.json @@ -964,6 +964,330 @@ "stateful": 0 }, "extra_compute_units": 0 + }, + { + "name": "accountSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "accountUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "blockSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "blockUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "logsSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "logsUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "programSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "programUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "rootSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "rootUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "signatureSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "signatureUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "slotSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "slotUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "slotsUpdatesSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "slotsUpdatesUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "voteSubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 + }, + { + "name": "voteUnsubscribe", + "block_parsing": { + "parser_arg": [ + "latest" + ], + "parser_func": "DEFAULT" + }, + "compute_units": 1000, + "enabled": true, + "category": { + "deterministic": false, + "local": true, + "subscription": true, + "stateful": 0 + }, + "extra_compute_units": 0 } ], "headers": [], @@ -994,6 +1318,87 @@ "encoding": "base64" }, "api_name": "getBlock" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "accountSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"accountUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "accountUnsubscribe" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "blockSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"blockUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "blockUnsubscribe" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "logsSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"logsUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "logsUnsubscribe" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "programSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"programUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "programUnsubscribe" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "rootSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"rootUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "rootUnsubscribe" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "signatureSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"signatureUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "signatureUnsubscribe" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "slotSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"slotUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "slotUnsubscribe" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "slotsUpdatesSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"slotsUpdatesUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "slotsUpdatesUnsubscribe" + }, + { + "function_tag": "SUBSCRIBE", + "api_name": "voteSubscribe" + }, + { + "function_template": "{\"jsonrpc\":\"2.0\",\"method\":\"voteUnsubscribe\",\"params\":[%d],\"id\":1}", + "function_tag": "UNSUBSCRIBE", + "api_name": "voteUnsubscribe" } ], "verifications": [ diff --git a/protocol/chainlib/base_chain_parser.go b/protocol/chainlib/base_chain_parser.go index fa730cde48..6cc5e8ea24 100644 --- a/protocol/chainlib/base_chain_parser.go +++ b/protocol/chainlib/base_chain_parser.go @@ -429,9 +429,21 @@ func getServiceApis( } for _, parsing := range apiCollection.ParseDirectives { - taggedApis[parsing.FunctionTag] = TaggedContainer{ - Parsing: parsing, - ApiCollection: apiCollection, + // We do this because some specs may have multiple parse directives + // with the same tag - SUBSCRIBE (like in Solana). + // + // Since the function tag is not used for handling the subscription flow, + // we can ignore the extra parse directives and take only the first one. The + // subscription flow is handled by the consumer websocket manager and the chain router + // that uses the api collection to fetch the correct parse directive. + // + // The only place the SUBSCRIBE tag is checked against the taggedApis map is in the chain parser with GetParsingByTag. + // But there, we're not interested in the parse directive, only if the tag is present. + if _, ok := taggedApis[parsing.FunctionTag]; !ok { + taggedApis[parsing.FunctionTag] = TaggedContainer{ + Parsing: parsing, + ApiCollection: apiCollection, + } } }