hirosystems / stacks-subnets

Stacks Subnets: a layer-2 scaling solution for Stacks, intended for high-throughput, low-latency workloads
http://docs.hiro.so
GNU General Public License v3.0
51 stars 13 forks source link

feat: API now responds with state from latest microblocks by default #312

Closed jbencin closed 1 year ago

jbencin commented 1 year ago

Description

This PR contains the following changes:

Applicable issues

Additional info (benefits, drawbacks, caveats)

Scope

This PR has a wider scope than the associated issue, as it affects all API endpoints which can accept a tip=<string> parameter. I'm not sure if this is desirable.

API Consistency

Treating microblocks as confirmed creates some inconsistency in how microblocks are reported by the API:

API Changes

Since API requests now default to tip=latest, I've added the option to use tip=anchored in the query string in order to not take microblocks into account when processing the request

Potential Race Condition

It's possible for an API call to fail when using the latest microblock tip. Relevant comment from rpc.rs:

    /// # Warn
    /// - There is a potential race condition. If this function is loading the latest unconfirmed
    /// tip, that tip may get invalidated by the time it is used in `maybe_read_only_clarity_tx`,
    /// which is used to load clarity state at a particular tip (which would lead to a 404 error).
    /// If this race condition occurs frequently, we can modify `maybe_read_only_clarity_tx` to
    /// re-load the unconfirmed chain tip. Refer to issue #2997.

See here for full context

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #312 (439a1bb) into develop (3916c3c) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop     #312   +/-   ##
========================================
  Coverage    60.00%   60.00%           
========================================
  Files            4        4           
  Lines           45       45           
  Branches         6        6           
========================================
  Hits            27       27           
  Misses          18       18           
blockstack-devops commented 1 year ago

:tada: This PR is included in version 0.8.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: