Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement subscribeNewHeads,subscriptionReorg,subscribePendingTransactions #2211

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

weiihann
Copy link
Contributor

@weiihann weiihann commented Oct 11, 2024

Description

Fixes #2205
Fixes #2207
Fixes #2232

The difference between the previous implementation of juno_subscribeNewHeads is that it supports streaming historical block headers up to 1024 blocks ago, as per the specification.

rpc/events.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 80.19481% with 61 lines in your changes missing coverage. Please review.

Project coverage is 74.33%. Comparing base (4ff174d) to head (9c99505).

Files with missing lines Patch % Lines
rpc/subscriptions.go 78.60% 38 Missing and 14 partials ⚠️
jsonrpc/server.go 66.66% 4 Missing and 1 partial ⚠️
sync/sync.go 87.09% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2211      +/-   ##
==========================================
- Coverage   74.38%   74.33%   -0.06%     
==========================================
  Files         109      110       +1     
  Lines       11493    11711     +218     
==========================================
+ Hits         8549     8705     +156     
- Misses       2278     2329      +51     
- Partials      666      677      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pnowosie pnowosie self-requested a review October 11, 2024 12:02
@weiihann weiihann force-pushed the weiihann/2205-subscribeNewHeads branch 2 times, most recently from a84cbfd to 24d8885 Compare October 14, 2024 09:26
@weiihann weiihann changed the title Implements starknet_subscribeNewHeads and starknet_subscriptionNewHeads Implements starknet_subscribeNewHeads Oct 14, 2024
@weiihann weiihann force-pushed the weiihann/2205-subscribeNewHeads branch from f01671a to fcd5e8f Compare October 15, 2024 09:43
@weiihann weiihann changed the title Implements starknet_subscribeNewHeads Implements starknet_subscribeNewHeads and starknet_subscriptionReorg Oct 15, 2024
@weiihann weiihann force-pushed the weiihann/2205-subscribeNewHeads branch 2 times, most recently from eaea8ce to e7ccc0a Compare October 21, 2024 16:58
@weiihann weiihann changed the title Implements starknet_subscribeNewHeads and starknet_subscriptionReorg Implement starknet_subscribeNewHeads,starknet_subscriptionReorg,starknet_subscribePendingTransactions Oct 21, 2024
@weiihann weiihann force-pushed the weiihann/2205-subscribeNewHeads branch from e7ccc0a to 8efccc0 Compare October 21, 2024 17:01
@pnowosie pnowosie force-pushed the weiihann/2205-subscribeNewHeads branch from 8efccc0 to 19641b8 Compare October 23, 2024 12:16
jsonrpc/server.go Show resolved Hide resolved
sync/sync.go Show resolved Hide resolved
@weiihann weiihann changed the title Implement starknet_subscribeNewHeads,starknet_subscriptionReorg,starknet_subscribePendingTransactions Implement subscribeNewHeads,subscriptionReorg,subscribePendingTransactions Oct 25, 2024
@weiihann weiihann force-pushed the weiihann/2205-subscribeNewHeads branch 2 times, most recently from c84636c to a4cc367 Compare October 29, 2024 09:30
commit 7687360
Author: Ng Wei Han <47109095+weiihann@users.noreply.github.com>
Date:   Thu Dec 12 18:54:32 2024 +0800

    Remove size in OrderedSet (#2319)

commit 65b7507
Author: Ng Wei Han <47109095+weiihann@users.noreply.github.com>
Date:   Thu Dec 12 18:20:55 2024 +0800

    Fix and refactor trie proof logics (#2252)

commit 2b1b219
Author: aleven1999 <andrei.levenstein@gmail.com>
Date:   Thu Dec 12 12:11:28 2024 +0400

    Remove unused code (#2318)

commit 0a21162
Author: Daniil Ankushin <ankushin.daniil42@gmail.com>
Date:   Thu Dec 12 00:04:08 2024 +0700

    Remove unused code (#2317)

commit 8bf9be9
Author: Rian Hughes <rian.hughes@physics.ox.ac.uk>
Date:   Wed Dec 11 14:11:22 2024 +0200

    update invoke v3 txn validation to require sender_address (#2308)

commit 91d0f8e
Author: Kirill <paltsev.kir@gmail.com>
Date:   Wed Dec 11 16:01:10 2024 +0400

    Add schema_version to output of db info command (#2309)

commit 60e8cc9
Author: AnavarKh <108727035+AnavarKh@users.noreply.github.com>
Date:   Wed Dec 11 16:04:31 2024 +0530

    Update download link for Juno snapshots from dev to io in Readme file (#2314)

commit 8862de1
Author: wojciechos <wojciech.zieba@nethermind.io>
Date:   Wed Dec 11 11:20:02 2024 +0100

    Improve binary build workflow for cross-platform releases (#2315)

    - Add proper architecture handling in matrix configuration
    - Implement caching for Go modules and Rust dependencies
    - Streamline dependency installation for both Linux and macOS
    - Improve binary artifact handling and checksums
    - Add retention policy for build artifacts
    - Split build steps for better clarity and maintainability

    This update ensures more reliable and efficient binary builds
    across all supported platforms.

commit e75e504
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed Dec 11 07:35:16 2024 +0000

    Bump nanoid from 3.3.7 to 3.3.8 in /docs in the npm_and_yarn group across 1 directory (#2316)

    Bump nanoid in /docs in the npm_and_yarn group across 1 directory

    Bumps the npm_and_yarn group with 1 update in the /docs directory: [nanoid](https://github.com/ai/nanoid).

    Updates `nanoid` from 3.3.7 to 3.3.8
    - [Release notes](https://github.com/ai/nanoid/releases)
    - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
    - [Commits](ai/nanoid@3.3.7...3.3.8)

    ---
    updated-dependencies:
    - dependency-name: nanoid
      dependency-type: indirect
      dependency-group: npm_and_yarn
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 3a7abeb
Author: wojciechos <wojciech.zieba@nethermind.io>
Date:   Tue Dec 10 21:52:49 2024 +0100

    Skip error logs for FGW responses with NOT_RECEIVED status (#2303)

    * Add NotReceived case handling in adaptTransactionStatus

    ---------

    Co-authored-by: Rian Hughes <rian.hughes@physics.ox.ac.uk>
commit 4ff174d
Author: IronGauntlets <aneequesafdar@gmail.com>
Date:   Fri Apr 26 22:10:44 2024 +0100

    Move pending to sync package

    In order to moved handling of pending to synchroniser the following
    changes needed to be made:
    - Add database to synchroniser, so that pending state can be served
    - Blockchain and Events Filter have a pendingBlockFn() which returns the
      pending block. Due to import cycle pending struct could not be
      referenced, therefore, the anonymous function is passed.
    - Add PendingBlock() to return just the pending block, this was mainly
      added to support the pendingBlockFn().
    - In rpc package the pending block and state is retrieved through
      synchroniser. Therefore, receipt and transaction handler now check the
      pending block for the requested transaction/receipt.

commit fb75cd6
Author: IronGauntlets <aneequesafdar@gmail.com>
Date:   Fri Apr 26 15:18:33 2024 +0100

    Rename cachedPending to pending

commit 3ffc458
Author: IronGauntlets <aneequesafdar@gmail.com>
Date:   Fri Apr 26 01:27:53 2024 +0100

    Check pending block protocol version before storing

commit 317ca38
Author: IronGauntlets <aneequesafdar@gmail.com>
Date:   Fri Apr 26 00:52:59 2024 +0100

    Refactor blockchain.Pending to return a reference

commit 03f4bfa
Author: IronGauntlets <aneequesafdar@gmail.com>
Date:   Mon Apr 22 21:16:22 2024 +0100

    Remove pending and empty pending from DB

    Pending Block is now only managed in memory this is to make sure that
    pending block in the DB and in memory do not become out of sync. Before
    the pending block was managed in memory as a cache, however, since there
    is only one pending block at a given time it doesn't make sense to keep
    track of pending block in both memory and DB.

    To reduce the number of block not found errors while simulating
    transactions it was decided to store empty pending block, using the
    latest header to fill in fields such as block number, parent block hash,
    etc. This meant that any time we didn't have a pending block this
    empty pending block would be served along with empty state diff and
    classes. Every time a new block was added to the blockchain a new empty
    pending block was also added to the DB.

    The unforeseen side effect of this change was when the
    --poll-pending-interval flag was disabled the rpc would still serve a
    pending block. This is incorrect behaviour.

    As the blocks changed per new versions of starknet the empty block also
    needed to be changed and a storage diff with a special contract "0x1"
    needed to be updated in the state diff. This overhead is unnecessary and
    incorrectly informs the user that there is a pending block when
    there isn't one.
@weiihann weiihann force-pushed the weiihann/2205-subscribeNewHeads branch from 40a8af2 to a624ed2 Compare December 13, 2024 02:11
sub events
@weiihann weiihann force-pushed the weiihann/2205-subscribeNewHeads branch from a624ed2 to 9c99505 Compare December 13, 2024 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants