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

fix(stacking): fix "Assertion failed" error when calling .stack and .canStack #925

Merged
merged 1 commit into from
Jan 22, 2021

Conversation

pradel
Copy link
Contributor

@pradel pradel commented Jan 22, 2021

Description

When integrating the new @stacks/stacking npm package I am having an issue with the client.stack and the client.canStack methods, both are throwing [Error: Assertion failed].

After some debugging, it looks like the error is coming from this call https://github.com/blockstack/stacks.js/blob/a6b7da0586caa893c7cdf2ef4a3011de3248afe8/packages/stacking/src/index.ts#L319.
hashMode returned by const { hashMode, data } = decodeBtcAddress(poxAddress); is 0 and calling bn.js new BN(hashMode, 10).toBuffer() to get the buffer on 0 is throwing an error

Related issue #898.

Example:

Following the stacking tutorial and doing a simple operation like this:

const stackingClient = new StackingClient(
  "STRW09277YXKS1GZFT7QQSQ7GNWS2M4S3CG5V6ZT",
  new StacksTestnet()
);

const stackingEligibility = await stackingClient.canStack({
  poxAddress: "tb1qa96uwhml8rxfees4ggn98z55xlmdxnrxhe60n2jl29vyg5txcnts36xrr2",
  cycles: 1,
});

For details refer to issue #123

Type of Change

  • New feature
  • Bug fix
  • API reference/documentation update
  • Other

Does this introduce a breaking change?

No

Are documentation updates required?

No

Testing information

Provide context on how tests should be performed.

  1. Is testing required for this change?

I tested to manually patch the file in my project and the error was fixed with this change.

  1. If it’s a bug fix, list steps to reproduce the bug
const stackingClient = new StackingClient(
  "STRW09277YXKS1GZFT7QQSQ7GNWS2M4S3CG5V6ZT",
  new StacksTestnet()
);

const stackingEligibility = await stackingClient.canStack({
  poxAddress: "tb1qa96uwhml8rxfees4ggn98z55xlmdxnrxhe60n2jl29vyg5txcnts36xrr2",
  cycles: 1,
});

Checklist

  • Code is commented where needed
  • Unit test coverage for new or modified code paths
  • npm run test passes
  • Changelog is updated
  • Tag 1 of @yknl or @zone117x for review

@CLAassistant
Copy link

CLAassistant commented Jan 22, 2021

CLA assistant check
All committers have signed the CLA.

@vercel
Copy link

vercel bot commented Jan 22, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/blockstack/stacks-js/fqwt6dub3
✅ Preview: https://stacks-js-git-fork-pradel-patch-1.blockstack.vercel.app

@codecov
Copy link

codecov bot commented Jan 22, 2021

Codecov Report

Merging #925 (cfac222) into master (788006e) will decrease coverage by 0.20%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #925      +/-   ##
==========================================
- Coverage   77.10%   76.89%   -0.21%     
==========================================
  Files          72       72              
  Lines        4385     4488     +103     
  Branches      747      784      +37     
==========================================
+ Hits         3381     3451      +70     
- Misses        969     1000      +31     
- Partials       35       37       +2     
Impacted Files Coverage Δ
src/index.ts 78.30% <0.00%> (-21.70%) ⬇️
src/utils.ts 52.52% <0.00%> (-1.33%) ⬇️
src/constants.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 788006e...cfac222. Read the comment docs.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants