-
Notifications
You must be signed in to change notification settings - Fork 286
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
feat(core-transaction-pool): Switch expiration to chain height #2461
Conversation
Switch from calculating transactions' expiration in "number of seconds since genesis block" to "chain height". Notice: this change alters the semantic of the maxTransactionAge beyond just the units (seconds vs height). Before the change we would use the user-defined transaction.timestamp and add maxTransactionAge (seconds) to it. After the change we use the current chain height when we have received the transaction (which is not user-defined and not necessary the same as when the transaction was created by the user) and add maxTransactionAge (height) to it. Resolves #1060
The ci/circleci: test-node10-e2e job is failing as of 21845ee79cfe1c89f0331691453abe84a94adfce. Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
854244a
to
537eb5d
Compare
// Max transaction age in number of blocks produced since receiving a transaction. | ||
// If a transaction stays that long in the pool without being included in any block, | ||
// then it will be removed. | ||
maxTransactionAge: 2700, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to something better so the comment is not needed to understand what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the variable name is fine, any suggestions are welcome though.
It is not possible to condense the information from 3 lines into a variable name. In this case the important information the comment is conveying is:
- The units of measurement (it is blocks, not seconds)
- When does the counter start ticking (it is when the transaction has been received, not when it was created like it was before this change)
- What happens when the time expires.
Please, do not remove the comment.
It is normal to have one or two sentences describing each variable/config parameter, for example:
-debuglogfile=<file>
Specify location of debug log file. Relative paths will be prefixed by a
net-specific datadir location. (-nodebuglogfile to disable;
default: debug.log)
-includeconf=<file>
Specify additional configuration file, relative to the -datadir path
(only useable from configuration file, not command line)
-loadblock=<file>
Imports blocks from external blk000??.dat file on startup
-maxmempool=<n>
Keep the transaction memory pool below <n> megabytes (default: 300)
-maxorphantx=<n>
Keep at most <n> unconnectable transactions in memory (default: 100)
-mempoolexpiry=<n>
Do not keep transactions in the mempool longer than <n> hours (default:
336)
-par=<n>
Set the number of script verification threads (-8 to 16, 0 = auto, <0 =
leave that many cores free, default: 0)
-persistmempool
Whether to save the mempool on shutdown and load on restart (default: 1)
-prune=<n>
Reduce storage requirements by enabling pruning (deleting) of old
blocks. This allows the pruneblockchain RPC to be called to
delete specific blocks, and enables automatic pruning of old
blocks if a target size in MiB is provided. This mode is
incompatible with -txindex and -rescan. Warning: Reverting this
setting requires re-downloading the entire blockchain. (default:
0 = disable pruning blocks, 1 = allow manual pruning via RPC,
>=550 = automatically prune block files to stay under the
specified target size in MiB)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it not possible to convey that minuscule bit of information in a variable name? All of the following make it pretty clear that it is about lifetime/expiration of the transaction and the unit of measurement is a number of blocks.
transactionTtlInBlocks
transactionLifetimeInBlocks
transactionValidForNumberOfBlocks
transactionMaxAgeInBlocks
transactionExpiresAfterNumberOfBlocks
* transactions that are without expiration are not included. Used to: | ||
* - find all transactions that have expired (have an expiration height | ||
* lower than the current height) - they are at the beginning of the array. | ||
*/ | ||
private byExpiration: MemoryTransaction[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need that long of a comment to understand what an array with the name byExpiration
holds? The name is pretty self-explanatory and the code that uses it is also very simple.
If you feel the need to write that long comments, or even comments at all for such trivial things, you should think about why you really need those comments and remove the need for them and figure out how to make the code easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is needed to convey the following information, which cannot be deduced from the name of the variable:
- The array does not contain all transactions
- Is it sorted in ascending or descending order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo the information the comment tries to convey is a bit redundant since it can be quickly deduced by checking the relevant code. I personally would remove the comment, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this in a followup PR, see if you like it: https://github.com/ArkEcosystem/core/pull/2494/files#diff-ea1f8e8a5fdc70f328cde94d66d99dfeR20
537eb5d
to
e61fa9f
Compare
Co-Authored-By: vasild <vd@freebsd.org>
Co-Authored-By: vasild <vd@freebsd.org>
Co-Authored-By: vasild <vd@freebsd.org>
Co-Authored-By: vasild <vd@freebsd.org>
and handle the case if we are unable to get it
3241b69
to
fb8631b
Compare
The test needs to query the current chain height and then wait until it increases or fake an increased height.
…tion-expiration-in-height * ArkEcosystem/core/develop: release: 2.3.15 (#2478) release: 2.3.14 (#2477) refactor(core): remove support for old release channels (#2476) fix(crypto): add exceptions for transactions with invalid recipients (#2471) refactor(crypto): make all Slots.* methods static (#2473) docs(template): add release section to pull request template (#2472) chore: fix absolute banner urls (#2469)
…tion-expiration-in-height * ArkEcosystem/core/develop: style: apply linting and formatting to e2e tests (#2480)
Codecov Report
@@ Coverage Diff @@
## develop #2461 +/- ##
===========================================
- Coverage 67.79% 67.76% -0.03%
===========================================
Files 386 386
Lines 8396 8399 +3
Branches 398 399 +1
===========================================
Hits 5692 5692
- Misses 2652 2655 +3
Partials 52 52
Continue to review full report at Codecov.
|
…tion-expiration-in-height * ArkEcosystem/core/develop: feat: add core-state to manage the state of in-memory data (#2479)
} | ||
|
||
return new Set(); | ||
} | ||
|
||
public remember(MemoryTransaction: MemoryTransaction, maxTransactionAge: number, databaseReady?: boolean): void { | ||
const transaction: Interfaces.ITransaction = MemoryTransaction.transaction; | ||
public remember(SequentialTransaction: SequentialTransaction, maxTransactionAge: number, databaseReady?: boolean): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public remember(SequentialTransaction: SequentialTransaction, maxTransactionAge: number, databaseReady?: boolean): void { | |
public remember(sequentialTransaction: SequentialTransaction, maxTransactionAge: number, databaseReady?: boolean): void { |
Variable names should always be in camelCase
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You named it MemoryTransaction
all over the place, I did not wanted to argue and assumed you wanted it to be with capital letter for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely removed the [sS]equentialTransaction
from the code in a followup PR: #2494
…tion-expiration-in-height * ArkEcosystem/core/develop: fix(core): parse only the last line of pm2 stdout (#2484) release: 2.3.18 (#2488) fix(core-snapshots): reset unfinished round after import (#2486) fix(core-forger): update configManager height (#2487) release: 2.3.16 (#2483) fix(core-database): initialize height on startup (#2482)
Switch from calculating transactions' expiration in "number of seconds
since genesis block" to "chain height".
Notice: this change alters the semantic of the maxTransactionAge beyond
just the units (seconds vs height). Before the change we would use the
user-defined transaction.timestamp and add maxTransactionAge (seconds)
to it. After the change we use the current chain height when we have
received the transaction (which is not user-defined and not necessary
the same as when the transaction was created by the user) and add
maxTransactionAge (height) to it.
Resolves #1060
Summary
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
Other information