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

Backport triv pr15 #4260

Merged
merged 13 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Note: Code review is a burdensome but important part of the development process,

If your pull request contains fixup commits (commits that change the same line of code repeatedly) or too fine-grained
commits, you may be asked to [squash](https://git-scm.com/docs/git-rebase#_interactive_mode) your commits
before it will be merged. The basic squashing workflow is shown below.
before it will be reviewed. The basic squashing workflow is shown below.

git checkout your_branch_name
git rebase -i HEAD~n
Expand Down
6 changes: 6 additions & 0 deletions contrib/debian/examples/dash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
# Maximum number of inbound+outbound connections.
#maxconnections=

# Maximum upload bandwidth target in MiB per day (e.g. 'maxuploadtarget=1024' is 1 GiB per day).
# This limits the upload bandwidth for those with bandwidth limits. 0 = no limit (default: 0).
# -maxuploadtarget does not apply to peers with 'download' permission.
# For more information on reducing bandwidth utilization, see: doc/reduce-traffic.md.
#maxuploadtarget=

#
# JSON-RPC options (for controlling a running Dash/dashd process)
#
Expand Down
3 changes: 2 additions & 1 deletion contrib/devtools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ clang-format-diff.py

A script to format unified git diffs according to [.clang-format](../../src/.clang-format).

Requires `clang-format`, installed e.g. via `brew install clang-format` on macOS.
Requires `clang-format`, installed e.g. via `brew install clang-format` on macOS,
or `sudo apt install clang-format` on Debian/Ubuntu.

For instance, to format the last commit with 0 lines of context,
the script should be called from the git root folder as follows.
Expand Down
3 changes: 2 additions & 1 deletion contrib/macdeploy/macdeployqtplus
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ if len(config.fancy) == 1:
sys.exit(1)

try:
fancy = plistlib.readPlist(p)
with open(p, 'rb') as fp:
fancy = plistlib.load(fp, fmt=plistlib.FMT_XML)
except:
if verbose >= 1:
sys.stderr.write("Error: Could not parse fancy disk image plist at \"%s\"\n" % (p))
Expand Down
11 changes: 11 additions & 0 deletions doc/JSON-RPC-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@ wallet would reflect the removal of these mempool transactions in the state.

However, the wallet may not be up-to-date with the current state of the mempool
or the state of the mempool by an RPC that returned before this RPC.

## Limitations

There is a known issue in the JSON-RPC interface that can cause a node to crash if
too many http connections are being opened at the same time because the system runs
out of available file descriptors. To prevent this from happening you might
want to increase the number of maximum allowed file descriptors in your system
and try to prevent opening too many connections to your JSON-RPC interface at the
same time if this is under your control. It is hard to give general advice
since this depends on your system but if you make several hundred requests at
once you are definitely at risk of encountering this issue.
12 changes: 12 additions & 0 deletions doc/REST-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ REST Interface consistency guarantees
The [same guarantees as for the RPC Interface](/doc/JSON-RPC-interface.md#rpc-consistency-guarantees)
apply.

Limitations
-----------

There is a known issue in the REST interface that can cause a node to crash if
too many http connections are being opened at the same time because the system runs
out of available file descriptors. To prevent this from happening you might
want to increase the number of maximum allowed file descriptors in your system
and try to prevent opening too many connections to your rest interface at the
same time if this is under your control. It is hard to give general advice
since this depends on your system but if you make several hundred requests at
once you are definitely at risk of encountering this issue.

Supported API
-------------

Expand Down
12 changes: 5 additions & 7 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ tool to clean up patches automatically before submission.
on the same line as the `if`, without braces. In every other case,
braces are required, and the `then` and `else` clauses must appear
correctly indented on a new line.
- There's no hard limit on line width, but prefer to keep lines to <100
characters if doing so does not decrease readability. Break up long
function declarations over multiple lines using the Clang Format
[AlignAfterOpenBracket](https://clang.llvm.org/docs/ClangFormatStyleOptions.html)
style option.

- **Symbol naming conventions**. These are preferred in new code, but are not
required when doing so would need changes to significant pieces of existing
Expand Down Expand Up @@ -903,13 +908,6 @@ A few guidelines for introducing and reviewing new RPC interfaces:

- *Rationale*: If not, the call can not be used with name-based arguments.

- Set okSafeMode in the RPC command table to a sensible value: safe mode is when the
blockchain is regarded to be in a confused state, and the client deems it unsafe to
do anything irreversible such as send. Anything that just queries should be permitted.

- *Rationale*: Troubleshooting a node in safe mode is difficult if half the
RPCs don't work.

- Add every non-string RPC argument `(method, idx, name)` to the table `vRPCConvertParams` in `rpc/client.cpp`.

- *Rationale*: `dash-cli` and the GUI debug console use this table to determine how to
Expand Down
13 changes: 12 additions & 1 deletion src/bloom.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,18 @@ class CBloomFilter
* insert()'ed ... but may also return true for items that were not inserted.
*
* It needs around 1.8 bytes per element per factor 0.1 of false positive rate.
* (More accurately: 3/(log(256)*log(2)) * log(1/fpRate) * nElements bytes)
* For example, if we want 1000 elements, we'd need:
* - ~1800 bytes for a false positive rate of 0.1
* - ~3600 bytes for a false positive rate of 0.01
* - ~5400 bytes for a false positive rate of 0.001
*
* If we make these simplifying assumptions:
* - logFpRate / log(0.5) doesn't get rounded or clamped in the nHashFuncs calculation
* - nElements is even, so that nEntriesPerGeneration == nElements / 2
*
* Then we get a more accurate estimate for filter bytes:
*
* 3/(log(256)*log(2)) * log(1/fpRate) * nElements
*/
class CRollingBloomFilter
{
Expand Down
3 changes: 3 additions & 0 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class Coin
::Unserialize(s, Using<TxOutCompression>(out));
}

/** Either this coin never existed (see e.g. coinEmpty in coins.cpp), or it
* did exist and has been spent.
*/
bool IsSpent() const {
return out.IsNull();
}
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ bool AppInitParameterInteraction()

// Trim requested connection counts, to fit into system limitations
// <int> in std::min<int>(...) to work around FreeBSD compilation issue described in #2695
nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS + MAX_ADDNODE_CONNECTIONS);
nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS + MAX_ADDNODE_CONNECTIONS + nBind);
#ifdef USE_POLL
int fd_max = nFD;
#else
Expand Down
6 changes: 5 additions & 1 deletion src/netaddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ bool CNetAddr::SetSpecial(const std::string& str)
Span<const uint8_t> input_checksum{input.data() + ADDR_TORV3_SIZE, torv3::CHECKSUM_LEN};
Span<const uint8_t> input_version{input.data() + ADDR_TORV3_SIZE + torv3::CHECKSUM_LEN, sizeof(torv3::VERSION)};

if (input_version != torv3::VERSION) {
return false;
}

uint8_t calculated_checksum[torv3::CHECKSUM_LEN];
torv3::Checksum(input_pubkey, calculated_checksum);

if (input_checksum != calculated_checksum || input_version != torv3::VERSION) {
if (input_checksum != calculated_checksum) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
<item>
<widget class="QCheckBox" name="prune">
<property name="toolTip">
<string>Disables some advanced features but all blocks will still be fully validated. Reverting this setting requires re-downloading the entire blockchain. Actual disk usage may be somewhat higher.</string>
<string>Enabling pruning significantly reduces the disk space required to store transactions. All blocks are still fully validated. Reverting this setting requires re-downloading the entire blockchain.</string>
</property>
<property name="text">
<string>Prune &amp;block storage to</string>
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3937,10 +3937,10 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
WalletLogPrintf("Fee Calculation: Fee:%d Bytes:%u Tgt:%d (requested %d) Reason:\"%s\" Decay %.5f: Estimation: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out) Fail: (%g - %g) %.2f%% %.1f/(%.1f %d mem %.1f out)\n",
nFeeRet, nBytes, feeCalc.returnedTarget, feeCalc.desiredTarget, StringForFeeReason(feeCalc.reason), feeCalc.est.decay,
feeCalc.est.pass.start, feeCalc.est.pass.end,
100 * feeCalc.est.pass.withinTarget / (feeCalc.est.pass.totalConfirmed + feeCalc.est.pass.inMempool + feeCalc.est.pass.leftMempool),
(feeCalc.est.pass.totalConfirmed + feeCalc.est.pass.inMempool + feeCalc.est.pass.leftMempool) > 0.0 ? 100 * feeCalc.est.pass.withinTarget / (feeCalc.est.pass.totalConfirmed + feeCalc.est.pass.inMempool + feeCalc.est.pass.leftMempool) : 0.0,
feeCalc.est.pass.withinTarget, feeCalc.est.pass.totalConfirmed, feeCalc.est.pass.inMempool, feeCalc.est.pass.leftMempool,
feeCalc.est.fail.start, feeCalc.est.fail.end,
100 * feeCalc.est.fail.withinTarget / (feeCalc.est.fail.totalConfirmed + feeCalc.est.fail.inMempool + feeCalc.est.fail.leftMempool),
(feeCalc.est.fail.totalConfirmed + feeCalc.est.fail.inMempool + feeCalc.est.fail.leftMempool) > 0.0 ? 100 * feeCalc.est.fail.withinTarget / (feeCalc.est.fail.totalConfirmed + feeCalc.est.fail.inMempool + feeCalc.est.fail.leftMempool) : 0.0,
feeCalc.est.fail.withinTarget, feeCalc.est.fail.totalConfirmed, feeCalc.est.fail.inMempool, feeCalc.est.fail.leftMempool);
return true;
}
Expand Down