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

When checking balance/nonce, always query at latest block. #945

Closed
danfinlay opened this issue Dec 21, 2016 · 5 comments
Closed

When checking balance/nonce, always query at latest block. #945

danfinlay opened this issue Dec 21, 2016 · 5 comments
Assignees
Labels

Comments

@danfinlay
Copy link
Contributor

danfinlay commented Dec 21, 2016

We're currently querying at last block number we're aware of, but when hitting infura, which is a load balanced cluster, when there is a slight de-synchronization, we can hit a node that hasn't heard about that block yet!

In this case, neither Parity nor Geth replies with much grace:

Geth:

Request

curl 'https://ropsten.infura.io/metamask' -H "Infura-Ethereum-Preferred-Client: geth" --data-binary '{"id":1482348034196178,"jsonrpc":"2.0","params":["0xf414ca28e61abc7ad7d9b09a2c10de6573cc41ee","0x60799"],"method":"eth_getBalance"}'

response:

{"jsonrpc":"2.0","id":1482348034196178,"result":"\u003cnil\u003e"}

Parity

Request

curl 'https://ropsten.infura.io/metamask' -H "Infura-Ethereum-Preferred-Client: parity" --data-binary '{"id":1482348034196178,"jsonrpc":"2.0","params":["0xf414ca28e61abc7ad7d9b09a2c10de6573cc41ee","0x60799"],"method":"eth_getBalance"}'

Response:

{"jsonrpc":"2.0","error":{"code":-32000,"message":"This request is not supported because your node is running with state pruning. Run with --pruning=archive.","data":null},"id":1482348034196178}

So geth returns a mis-formatted value, and Parity acts like you aren't in archive mode.

We should submit these bugs to those client providers, but also we should just be getting balance & nonce at latest.

@danfinlay
Copy link
Contributor Author

This may not be happening anymore , so needs verification.

@danfinlay danfinlay added the ready label Jan 2, 2017
@danfinlay danfinlay self-assigned this Jan 2, 2017
@danfinlay
Copy link
Contributor Author

I've re-verified as was requested. While we request block at latest, we request both balance and transactionCount at the last-seen block's number.

Here are screenshots for non-believers:

screen shot 2017-01-03 at 3 07 12 pm
screen shot 2017-01-03 at 3 07 06 pm

@danfinlay
Copy link
Contributor Author

Since balance & nonce are fetched on new block by eth-store, we're using whatever it does, and it always queries by block.

A further complication is that we're on the 1.1.x version, while the published npm package is at 2.2.0, which broke the API in a way we haven't migrated to from metamask-plugin.

The master branch has, on the other hand, retained the old API as old.js.

Our options for dealing with this problem, from easiest to most correct:

  • Update the old.js file to query latest, and get on the latest master branch.
  • Update the 1.1.x branch to query latest and publish it.
  • Convert metamask to use the 2.2.x branch, and update it to query latest, and publish it.

In addition, I think we should:

  • Add a README file describing basic usage.
  • Add a repo link to the package.json, so the npm package can point to the github page & issues. (As easy as running the npm init command in the folder)

Thoughts or opinions, @kumavis?

@danfinlay
Copy link
Contributor Author

Fun news: Parity now throws a descriptive error for this behavior, and geth is working on it.

@danfinlay
Copy link
Contributor Author

We're going with a fourth option: Bring in the old eth-store as a local dependency for now, and monkey patch as needed.

@ghost ghost assigned 2-am-zzz Jan 5, 2017
@ghost ghost removed the in progress label Jan 5, 2017
david0xd added a commit that referenced this issue Sep 27, 2023
## **Description**
This PR removes `long-running` Snap endowment/permission.

Snaps team have decided to remove this endowment because of its
unpredictable security concerns around running Snaps indefinitely. This
endowment is removed in favor of the new endowments that will be focused
on solving certain use cases that require snap to be running for more
time than default.

## **Related issues**

_Fixes [#945](MetaMask/snaps#945

## **Related PR**
MetaMask/snaps#1751 (**required**)
MetaMask/metamask-docs#919

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've clearly explained:
  - [ ] What problem this PR is solving.
  - [ ] How this problem was solved.
  - [ ] How reviewers can test my changes.
- [ ] I’ve indicated what issue this PR is linked to: Fixes #???
- [ ] I’ve included tests if applicable.
- [ ] I’ve documented any added code.
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
- [ ] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants