Skip to content

Conversation

@sdaftuar
Copy link
Member

@sdaftuar sdaftuar commented Apr 6, 2018

Larger values seem to trigger a bug on macos+libevent (resulting in the rpc server stopping).

@sdaftuar
Copy link
Member Author

sdaftuar commented Apr 6, 2018

This is a quick fix for #12375. Not sure if further reducing this value as I've proposed here is acceptable, or if we should be trying to solve this problem at a different level?

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

utACK, just a ton of style nits.

Also, since you are touching the walletpassphrase code anyway, you might want to change the boost::bind into std::bind to preempt future pull request from doing that.

"1. \"passphrase\" (string, required) The wallet passphrase\n"
"2. timeout (numeric, required) The time to keep the decryption key in seconds. Limited to at most 1073741824 (2^30) seconds.\n"
" Any value greater than 1073741824 seconds will be set to 1073741824 seconds.\n"
"2. timeout (numeric, required) The time to keep the decryption key in seconds; capped at 100000000.\n"
Copy link
Member

Choose a reason for hiding this comment

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

nit: Could add a comment that the constant is about 3 years.

if (nSleepTime > (int64_t)1 << 30) {
nSleepTime = (int64_t)1 << 30;
// Clamp timeout
int64_t max_sleep_time = 100000000; // larger values trigger a macos/libevent bug?
Copy link
Member

Choose a reason for hiding this comment

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

I think we currently use constexpr (without static) and UPPER_CASE for compile time constants.

# Check a time less than the limit
expected_time = int(time.time()) + (1 << 30) - 600
self.nodes[0].walletpassphrase(passphrase2, (1 << 30) - 600)
max_value = 100000000
Copy link
Member

Choose a reason for hiding this comment

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

nit: Constants should be UPPER_CASE

expected_time = int(time.time()) + (1 << 30) - 1
self.nodes[0].walletpassphrase(passphrase2, (1 << 33))
expected_time = int(time.time()) + max_value - 1
self.nodes[0].walletpassphrase(passphrase2, max_value + 1)
Copy link
Member

Choose a reason for hiding this comment

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

Might want to be off by more than 1, since we have a "buffer" of 5? Maybe try off by 1000 or something?

@sdaftuar
Copy link
Member Author

sdaftuar commented Apr 6, 2018

Thanks @MarcoFalke, nits fixed in latest commit.

@promag
Copy link
Contributor

promag commented Apr 6, 2018

utACK, also add release note?

@sipa
Copy link
Member

sipa commented Apr 6, 2018

Is the fact that wallets get locked after 3+ years really observable?

@laanwj
Copy link
Member

laanwj commented Apr 8, 2018

From a principled point of view I'd still prefer to never unlock if a value higher than defined threshold is given, instead of clamping.
Because that's what users intend if they give a huge number like this. They don't expect the wallet to ever re-lock.
But I also agree with @sipa that no one is going to notice this in practice.

utACK - don't think this requires specific mention in the release notes.

@PierreRochard
Copy link
Contributor

Tested ACK 93e1798 (on macOS).

My view is that we should throw an error if the value provided is > MAX_SLEEP_TIME and we should have an explicit boolean never_timeout parameter. But in terms of fixing this macOS-related bug the PR lgtm.

@promag
Copy link
Contributor

promag commented Apr 8, 2018

Tested ACK 93e1798.

@jonasschnelli
Copy link
Contributor

utACK 93e1798

@maflcko
Copy link
Member

maflcko commented Apr 8, 2018

Please squash your commits according to https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits

sdaftuar added 2 commits April 8, 2018 10:44
Larger values seem to trigger a bug on macos+libevent (resulting in the
rpc server stopping).
@sdaftuar sdaftuar force-pushed the 2018-04-wallet-encryption-timeout branch from 93e1798 to 2b2b96c Compare April 8, 2018 14:45
@sdaftuar
Copy link
Member Author

sdaftuar commented Apr 8, 2018

Squashed 93e1798 -> 2b2b96c


#include <univalue.h>

#include <functional>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this include needed?

Copy link
Member

Choose a reason for hiding this comment

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

According to http://en.cppreference.com/w/cpp/utility/functional/bind, std::bind is "[d]efined in header <functional>".

@maflcko
Copy link
Member

maflcko commented Apr 8, 2018

utACK 2b2b96c (Checked that it is the same code as the previous 93e1798)

@PierreRochard
Copy link
Contributor

reACK 2b2b96c

@maflcko maflcko merged commit 2b2b96c into bitcoin:master Apr 8, 2018
maflcko pushed a commit that referenced this pull request Apr 8, 2018
2b2b96c Use std::bind instead of boost::bind to re-lock the wallet (Suhas Daftuar)
662d19f [rpcwallet] Clamp walletpassphrase value at 100M seconds (Suhas Daftuar)

Pull request description:

  Larger values seem to trigger a bug on macos+libevent (resulting in the rpc server stopping).

Tree-SHA512: 890f3b641f6c586e2f8f629a9d23bca6ceb8b237b285561aad488cb7adf941a21177d3129d0c2b8293c0a673cd8e401957dbe2b6b3b7c8c4e991bb411d260102
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request May 29, 2018
Larger values seem to trigger a bug on macos+libevent (resulting in the
rpc server stopping).

Github-Pull: bitcoin#12905
Rebased-From: 662d19f
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Jul 12, 2018
Larger values seem to trigger a bug on macos+libevent (resulting in the
rpc server stopping).

Github-Pull: bitcoin#12905
Rebased-From: 662d19f
HashUnlimited pushed a commit to chaincoin/chaincoin that referenced this pull request Jan 11, 2019
Larger values seem to trigger a bug on macos+libevent (resulting in the
rpc server stopping).

Github-Pull: bitcoin#12905
Rebased-From: 662d19f
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Mar 4, 2020
… seconds

2b2b96c Use std::bind instead of boost::bind to re-lock the wallet (Suhas Daftuar)
662d19f [rpcwallet] Clamp walletpassphrase value at 100M seconds (Suhas Daftuar)

Pull request description:

  Larger values seem to trigger a bug on macos+libevent (resulting in the rpc server stopping).

Tree-SHA512: 890f3b641f6c586e2f8f629a9d23bca6ceb8b237b285561aad488cb7adf941a21177d3129d0c2b8293c0a673cd8e401957dbe2b6b3b7c8c4e991bb411d260102
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants