Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: PRT-1178: Subscriptions phase 1 (without handover) (lavanet#1462)
* Enable the subscription again * Add GetParams() to GenericMessage struct * Fix tendermint small bug * RelayProcessor to skip some logic on subscription * Add subscription management in the provider - some TODOs are left * Fix the subscription category for supported chains * Remove unused functions * Small fix to the provider web socket manager * Small fixes to the provider * Move finalization consensus to a new package * Split the SendRelay into 2 functions: ParseRelay & SendParsedRelay * Add an utility function for readable hex * Remove the logic of disconnecting consumers after the end of epoch * Fix to the sage channel sender * Use a utility function CreateHashFromParams * Add some trace logs * Rename IsSubscription -> IsSubscriptionCategory * Add LongLastingProvidersStorage * Add the cancellable context to subscription relays int he rpcconsumer_server * Add ConsumerWebsocketManager & ConsumerWSSubscriptionManager * Move the subscription closing logic to a new function * Rename to make the code more sense * Implemented timeout of 15 minutes for open subscription * Add the subscription function tags * Updated cosmos and ethereum specs with new subscription parse directives * Implemented unsubscribe logic in the consumer * Small logs improvements * Rename CreateSubscriptionKey -> CreateDappKey * Use hashed params as map keys for subscription context * Move the websocket replies channel creation to the subscription manager * Rethink the storing of connected dapps and active subscriptions in the consumer Which now supports multiple subscriptions in one websocket * Some small fixes to the Unsubscribe function * Small rename * Implement unsubscribe_all for consumer * Typos fix * Improved some logs * Add a missing lock * Make the websocket channel writing a little bit safer * Fix a small bug * Don't support ubsubscribe_all in Relay flow * Split the TryRelay into smaller pieces * Add GetID to RPCInput interface * Add support for unsubscribe relay in the provider * Safe channel sender improvements * Use SafeChannelSender for the subscription in the consumer and fix bugs * Use formatter to preserve original jsonrpc ID * Add some comments * Small fixes * Rename and fix AnalyzeWebSocketErrorAndWriteMessage * Add a comment * Remove done TODO * Some log improvements * Provider subscription manager fix * Move UpdateCU call to start of subscription instead of its end * Updated subscription CU cost * Fix finalization consensus test * Lint fixes * Add LongLastingProvidersStorage tests * Add SafeChannelSender tests * Add 10 seconds timeout to handle hang when waiting for first message from subscription * Move the first subscription reply verification into the rpcconsumer_server so we can control better the OnSessionFailure call * Handle bad provider signature better * Fix a small bug and remove redundant return value * Fix typos * Move ProviderNodeSubscriptionManager to chainlib * Fix to the UnsubscribeAll call * Create a const for the subscription relay timeout * Sync the consumer and provider on session failure * Change the type of replyServer to not be a pointer to interface * Small fix for the consumer subscription manager * Fix a small bug in the provider node subscription manager * Small fix to the consumer subscription manager * Remove epochs from provider subscription manager * Small fix to the safe channel sender * Tiny log fix * Allow weboscket and http connectors in jsonRPC * Small log fix to connector.go * Add websocket server to mock chain lib * Add tests for provider and consumer subscription manager * Post merge fixes * Fix lint errors * Verify webSocket is up in consumer in protocol integration tests * Revert "Allow weboscket and http connectors in jsonRPC" This reverts commit 0a5d142. * WIP * changing functionality of parsed directive to be saved on the chain message instead of every time looking for it from scratch * rename long lasting to active subscription provider storage * adding purge callback. * two consumers setup * fix a bug where 2 consumers wouldn't be able to subscribe. * fixing test for subscriptions, fixing bug in chain router, and managing the state properly. * fixing safe channel sender functionality * fixing provider subscription manager test. * fix problem with websocket listener in tests. * fixing test routine condition. * lint * fix ws issue on generic chain lib mocks * fix e2e for jsonrpc. * removing unused code. * fix typo * adding comments * comment fix * adding more comments. * removing spam trace logs * undoing WIP changes * adding seen block to rpc consumer's consistency. * handling same consumer subscription hash. * rename to a proper convention * fixing case where two subscriptions at the same time could trigger a race, and a hanging lock. * improve readability * adding comments for better readability * insert sdk address inside the consumer container to avoid unnecessary unmarshlling * improve json marshalling by using gojson :) * remove unused code * change json marshaling package * improve flow on rpcconsumer server. * improved encoding on rpc consumer server * mistakenly forgotten unlock. * Small log fix * Pass also the ws connection to the provider in the setup_providers.sh script * Add websocket subscription test in e2e * fix mock tests * add replace channel method to safe channel sender * fix test * use replace channel instead of close * add more documentation * fix sub manager test * Fix lint * fix pending subscription race issue and add tests * Checking for errors when writing to file in e2e * Add websocket response to log * Allow more than 2 websocket in e2e test for subscriptions * fix nil deref on a race between read and close connection * Remove log * add comments * remove log spam and make addon print better * fix ws message bug * Leftovers from committed WIP * Small code cleaning * Post merge fix * Small test fix * fix: PRT-1178: Subscription phase 1 unsubscribe fix (lavanet#1575) * Fix init_chain command for macOS * Fix the bug with unsubscribing from jsonrpc * Send error message to user when subscription not found * Updated the ethereum spec to match the fix * Delete the dappkey from connected dapps when empty * Test fix * Fix lint issues * Make the logs clear to investigate test fail on GH * Add some logs for the SDK to trace the E2E test failure * Attempt to fix test by removing go routines * Another attempt to fix the protocol tests * Small lint fix * merged * Adding better search func for requirements * fix unused else * adding consumer guid for subscription requests from multiple consumer processes with the same key * consumer websocket manager fixes * fix 7 more comments * fixing more comments :) * set all id parsing in chain message. * fixing more comments * merged v2 changes * merge conflict fixes * terminate connection in handleNewNodeMessage on error * fixing missing websocket id for unique dapp key for websocket subscriptions from the same user. * another review bites the dust * another one bites the dust * logs * fixing a bug in unsubscribe brackets * do not purge providers if they have more than one subscription * solving issue after issue. I love to call it, Hero mode. * solve the safe channel sender issue when sending a message and waiting the entire time until the consumer responds * remove log. * fix lint * lint v2 * lint v3 * lint v4 * fixing context issue reading headers on subscription. * nil deref fix * fix initialize redundancy * adding multiple unique id on same dapp etc.. * fixing pending race for more than one pending subscriptions * adding a test to validate the queue mechanism * fixed. --------- Co-authored-by: Ran Mishael <[email protected]> Co-authored-by: Omer <[email protected]>
- Loading branch information