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

refactor(pool): remove unnecessary check from validateTransactions() #2951

Merged
merged 11 commits into from Sep 24, 2019

Conversation

vasild
Copy link
Contributor

@vasild vasild commented Sep 20, 2019

We would call

handler.throwIfCannotBeApplied(transaction, sender, databaseWalletManager);

followed by

handler.applyToSender(transaction, localWalletManager);

but applyToSender() calls throwIfCannotBeApplied() internally, so we
don't need to call it ourselves. Also, it was wrong to use the
databaseWalletManager in that call because we are applying the
transactions to localWalletManager, so the databaseWalletManager will be
outdated (e.g. sender nonce and balance will be stale in
databaseWalletManager).

So, remove the unnecessary call to throwIfCannotBeApplied().

A summary of what changes this PR introduces and why they were made.

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Refactor
  • Performance
  • Tests
  • Build
  • Documentation
  • Code style update
  • Continuous Integration
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Does this PR release a new version?

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

  • It's submitted to the develop branch, not the master branch
  • All tests are passing
  • New/updated tests are included

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

We would call

  handler.throwIfCannotBeApplied(transaction, sender, databaseWalletManager);

followed by

  handler.applyToSender(transaction, localWalletManager);

but applyToSender() calls throwIfCannotBeApplied() internally, so we
don't need to call it ourselves. Also, it was wrong to use the
databaseWalletManager in that call because we are applying the
transactions to localWalletManager, so the databaseWalletManager will be
outdated (e.g. sender nonce and balance will be stale in
databaseWalletManager).

So, remove the unnecessary call to throwIfCannotBeApplied().
@codecov
Copy link

codecov bot commented Sep 20, 2019

Codecov Report

❗ No coverage uploaded for pull request base (develop@d7dbbec). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             develop   #2951   +/-   ##
=========================================
  Coverage           ?   29.1%           
=========================================
  Files              ?     405           
  Lines              ?    9825           
  Branches           ?     464           
=========================================
  Hits               ?    2860           
  Misses             ?    6929           
  Partials           ?      36
Impacted Files Coverage Δ
packages/core-transaction-pool/src/connection.ts 54.68% <ø> (ø)

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 d7dbbec...85fa9f4. Read the comment docs.

faustbrian and others added 8 commits September 23, 2019 14:13
throwIfCannotBeApplied() is not called directly anymore. It is only
called from applyToSender(), but that method is mocked.
We don't call throwIfCannotBeApplied() before applyToSender() anymore,
so the test becomes irrelevant - it fakes an exception from
throwIfCannotBeApplied() and checks that applyToSender() is not called.
The test was trying to use transaction mockData.dummyLarge1 which has
nonce=2, but without having prior transactions from that sender applied.

So, use mockData.dummy10 which is from that sender and has nonce=1.
…move-throwIfCannotBeApplied

* ArkEcosystem/core/develop:
  chore: drop node 11 support (#2965)
  test(e2e): No need to run as root the chmod command when modifying own's files (#2958)
  refactor(crypto): change maximum recipients of multipayment via milestone (#2961)
  ci: split functional job into 1 job per type (#2963)
  refactor(core-p2p): make peer reply errors less verbose (#2962)
  fix(core-state): index recipient wallets during bootstrap (#2947)
…move-throwIfCannotBeApplied

* ArkEcosystem/core/develop:
  refactor: strengthen a nonce check in performGenericWalletChecks() (#2949)
  ci: setup github action workflow for e2e tests (#2964)
@codecov-io
Copy link

codecov-io commented Sep 24, 2019

Codecov Report

❗ No coverage uploaded for pull request base (develop@5883e42). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop    #2951   +/-   ##
==========================================
  Coverage           ?   29.11%           
==========================================
  Files              ?      405           
  Lines              ?     9826           
  Branches           ?      465           
==========================================
  Hits               ?     2861           
  Misses             ?     6929           
  Partials           ?       36
Impacted Files Coverage Δ
packages/core-transaction-pool/src/connection.ts 54.68% <ø> (ø)

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 5883e42...ef662f5. Read the comment docs.

@spkjp spkjp merged commit 5fc1e40 into develop Sep 24, 2019
@ghost ghost deleted the pool-remove-throwIfCannotBeApplied branch September 24, 2019 21:50
vasild added a commit that referenced this pull request Sep 27, 2019
…ts-nonce

* ArkEcosystem/core/develop:
  refactor(core-transaction-pool): don't accept expired v1 transactions (#2948)
  fix(core-snapshots): remove bogus skipRoundRows (#2973)
  feat(core-api): endpoints for locks/businesses/bridgechains (#2940)
  fix(core-blockchain): round deletion during rollback (#2970)
  fix: range selection in pool's getTransactions() (#2952)
  feat: expose `isValidPeer` via ajv format rule (#2960)
  chore: remove trailing whitespace (#2971)
  fix(core-transactions): update wallet nonce when applying v1 transaction (#2959)
  fix(core-blockchain): do not reset `noBlockCounter` when `downloadBlocks` succeeds (#2968)
  refactor(pool): remove unnecessary check from validateTransactions() (#2951)
  ci: temporarily disable pull_request.synchronize event (#2966)
  refactor: strengthen a nonce check in performGenericWalletChecks() (#2949)
  ci: setup github action workflow for e2e tests (#2964)
  chore: drop node 11 support (#2965)
  test(e2e): No need to run as root the chmod command when modifying own's files (#2958)
  refactor(crypto): change maximum recipients of multipayment via milestone (#2961)
  ci: split functional job into 1 job per type (#2963)
  refactor(core-p2p): make peer reply errors less verbose (#2962)
  fix(core-state): index recipient wallets during bootstrap (#2947)
  Tell git to ignore vim's temporary files (#2957)
  ci: force exit tests if there are hanging promises
  ci: use different test coverage directories for each type (#2956)
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.

None yet

4 participants