Skip to content

feat: handle reorg on the daemon#7

Merged
andreabadesso merged 13 commits intodevfrom
feat/handle-reorg
Jun 15, 2021
Merged

feat: handle reorg on the daemon#7
andreabadesso merged 13 commits intodevfrom
feat/handle-reorg

Conversation

@andreabadesso
Copy link
Copy Markdown
Collaborator

No description provided.

@andreabadesso andreabadesso self-assigned this Jun 1, 2021
@andreabadesso andreabadesso changed the base branch from master to dev June 1, 2021 19:34
@andreabadesso andreabadesso changed the title Feat/handle reorg feat: handle reorg on the daemon Jun 1, 2021
@andreabadesso andreabadesso marked this pull request as ready for review June 2, 2021 16:55
Comment thread src/utils.ts
Comment thread src/machine.ts
Comment thread src/api/lambda.ts Outdated
export const invokeReorg = async (): Promise<ApiResponse> => {
const response = await lambdaCall('onHandleReorgRequest', {});

return response;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we need the response for anything? If not, shouldn't we just return the promise lambdaCall(...)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Done in f5bc6f4

Comment thread src/utils.ts
const network = process.env.NETWORK || 'mainnet';
const network: string = process.env.NETWORK || 'mainnet';

if (IGNORE_TXS.has(network)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow an unknown network? And maybe the txs on IGNORE_TXS should be in the wallet-lib constants.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should allow an unknown network. What do you think, @pedroferreira1 ?

I agree that the txs should be in the wallet-lib, I will create an issue there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the lib we already raise exception if we try to use a network different than 'mainnet' or 'testnet', so I think it's fine to handle only them.

About the txs in the lib I agree and I believe we've created an issue about that (or should've created) because we've already discussed this

@andreabadesso andreabadesso requested review from msbrogli and removed request for msbrogli June 10, 2021 17:54
Comment thread src/api/lambda.ts
@andreabadesso andreabadesso merged commit 8be7bb1 into dev Jun 15, 2021
@andreabadesso andreabadesso deleted the feat/handle-reorg branch June 15, 2021 23:58
r4mmer added a commit that referenced this pull request Jul 1, 2021
* origin/dev:
  refactor: sending transactions before blocks (#12)
  feat: handle reorg on the daemon (#7)
andreabadesso added a commit that referenced this pull request Sep 30, 2021
* chore: empty commit

* chore: empty commit

* feat: invoking onHandleReorgRequest on reorg state

* fix: possible infinite loop on circular parents on transactions

* feat: handling reorg on generator yield

* chore: logging errors properly

* chore: passing eslint

* refactor: logging reorg fail as error

* docs: added comment explaining the seen list on the recursivelyDownloadTxs method

* tests: fixed tests

* refactor: setting state as reorg when our best block is not found on the wallet-service

* refactor: returning the lambda invoke on invokeReorg and sendTx methods

* chore: added more details to error log on lambda call
andreabadesso added a commit that referenced this pull request Sep 30, 2021
* feat: initial commit

* chore: removed .env from git

* chore: removed size.yml github action (came from tsdx template)

* fix: added missing attributes to PreparedTx type

* feat: typed yield result from generator

* fix: token creation tx was not sending token_name and token_symbol

* fix: send transactions in topological order (#9)

* fix: send transactions in topological order (using the timestamp to order)

* tests: removed extra spentBy on block api response

* feat: handle reorg on the daemon (#7)

* chore: empty commit

* chore: empty commit

* feat: invoking onHandleReorgRequest on reorg state

* fix: possible infinite loop on circular parents on transactions

* feat: handling reorg on generator yield

* chore: logging errors properly

* chore: passing eslint

* refactor: logging reorg fail as error

* docs: added comment explaining the seen list on the recursivelyDownloadTxs method

* tests: fixed tests

* refactor: setting state as reorg when our best block is not found on the wallet-service

* refactor: returning the lambda invoke on invokeReorg and sendTx methods

* chore: added more details to error log on lambda call

* refactor: sending transactions before blocks (#12)

* feat: sync mempool (#11)

feat: sync mempool

* fix: using decoded to get token uid (#14)

* chore: pre-deploy adjustments (#13)

* fix: broken Dockerfile
chore: create Makefile and script to build and push Docker image
refactor: change name of some env vars

* refactor: Make sure the script fails if a command fails

* fix: ignoring NFT transaction outputs with undecoded scripts (#15)

* feat: validating tx outputs before sending transactions

* refactor: ignoring output instead of whole transaction

* chore: logging ignored tx output index

* feat: websocket conn error log (#17)

* chore: upgraded hathor-wallet-lib to 0.20.3

* feat: logging error messages on websocket connection

* refactor: logging connection attempts as INFO instead of ERROR

* fix: send height on transactions (#18)

* chore: updated lodash

* chore: improved logs

* fix: sending height on every block transaction

* refactor: send NFT outputs to wallet-service (#20)

* refactor: invalid nft output is now being validated on the wallet-service

* fix: lint passing (#21)

* chore: passing lint

* chore: added eslintrc to automatically detect carriage returns

* chore: passing NODE_OPTIONS as env variable globally on workflow

* chore: using generated eslintrc.js

* fix: validating decoded data before trying to get the token data (#22)

* fix: validating decoded data before trying to get the token data

* chore: lint

* ci: configure automated deployment (#19)

* ci: configure automated deploy

* send message to Slack

* send message only in case of deploy

* feat: added ALERT string to critical failure logs (#23)

* fix: deploy of docker images (#24)

* chore: added log on connection error (to fullnode) (#25)

* chore: bumped to v1.0.0-alpha (#28)

Co-authored-by: André Carneiro <andreluizmrcarneiro@gmail.com>
Co-authored-by: Luis Helder <luislhl@gmail.com>
andreabadesso added a commit that referenced this pull request Oct 6, 2021
* chore: empty commit

* chore: empty commit

* feat: invoking onHandleReorgRequest on reorg state

* fix: possible infinite loop on circular parents on transactions

* feat: handling reorg on generator yield

* chore: logging errors properly

* chore: passing eslint

* refactor: logging reorg fail as error

* docs: added comment explaining the seen list on the recursivelyDownloadTxs method

* tests: fixed tests

* refactor: setting state as reorg when our best block is not found on the wallet-service

* refactor: returning the lambda invoke on invokeReorg and sendTx methods

* chore: added more details to error log on lambda call
andreabadesso added a commit that referenced this pull request Apr 17, 2026
Tier 2 fix #7 from #395. `address.address` is a unique key, so the
DISTINCT clause is redundant for this SELECT — it only forces MySQL to
add a sort/dedup step on top of the join result.

Small per-event savings (~0.5-2ms depending on address count), and the
query runs once per event in the sync hot path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

4 participants