Commit Graph

629 Commits

Author SHA1 Message Date
Chris Beams
37b669c710
Make Config option fields public and inline accessors
See updated Config Javadoc for rationale.
2020-01-20 16:47:54 +01:00
Chris Beams
3a6b0ce9d8
Normalize creation of appDataDir and subdirs
Prior to this commit, the way that the appDataDir and its subdirectories
were created was a haphazard process that worked but in a fragile and
non-obvious way. When Config was instantiated, an attempt to call
btcNetworkDir.mkdir() was made, but if appDataDir did not already exist,
this call would always fail because mkdir() does not create parent
directories. This problem was never detected, though, because the
KeyStorage class happened to call mkdirs() on its 'keys' subdirectory,
which, because of the plural mkdirs() call ended up creating the whole
${appDataDir}/${btcNetworkDir}/keys hierarchy. Other btcNetworkDir
subdirectories such as tor/ and db/ then benefited from the hierarchy
already existing when they attempted to call mkdir() for their own dirs.
So the whole arrangement worked only because KeyStorage happened to make
a mkdirs() call and because that code in KeyStorage happened to get
invoked before the code that managed the other subdirectories.

This change ensures that appDataDir and all its subdirectories are
created up front, such that they are guaranteed to exist by the time
they are injected into Storage, KeyStorage, WalletsSetup and TorSetup.
The hierarchy is unchanged, structured as it always has been:

    ${appDataDir}
    └── btc_mainnet
        ├── db
        ├── keys
        ├── wallet
        └── tor

Note that the tor/ subdirectory actually gets deleted and re-created
within the TorSetup infrastructure regardless of whether the directory
exists beforehand.
2020-01-20 16:46:57 +01:00
Chris Beams
2c7829948b
Replace uses of Spring CollectionUtils
See Javadoc in new bisq.common.util.CollectionUtils class.
2020-01-20 16:41:19 +01:00
Chris Beams
f5a1854762
Remove now unused BisqEnvironment class
In previous commits, BisqEnvironment functionality has been fully ported
to the new, simpler and more type-safe Config class. This change removes
BisqEnvironment and all dependencies on the Spring Framework Environment
interface that it implements.

The one exception is the pricenode module, which is separate and apart
from the rest of the codebase in that it is a standalone, Spring-based
HTTP service.
2020-01-20 16:41:19 +01:00
Chris Beams
86e1ae1008
Move 'rpcPort' option handling to Config 2020-01-20 16:40:30 +01:00
Chris Beams
be97190415
Rename Config.{NULL_INT=>DEFAULT_INT} for clarity 2020-01-20 16:39:34 +01:00
Chris Beams
326375e4e4
Remove now unused NetworkOptionKeys class 2020-01-20 16:39:34 +01:00
Chris Beams
8e4107d80a
Remove obsolete NETWORK_ID option key
NETWORK_ID has not been in use since commit de93a6fa1, except by
the DummySeedNode test class, where its use has been preserved as string
literals.
2020-01-20 16:39:34 +01:00
Chris Beams
2dbd72b358
Move message throttle option handling to Config 2020-01-20 16:39:34 +01:00
Chris Beams
ca3719a139
Move 'torStreamIsolation' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
25604c1b29
Move 'torControlUseSafeCookieAuth' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
e90b2566a9
Move 'torControlCookieFile' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
5966d0ddcb
Move 'torControlPassword' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
d25ad0d266
Move 'torControlPort' option handling to Config
Note the introduction of Config.NULL_INT to avoid needing to inject
nullable boxed Integers in cases like this.
2020-01-20 16:39:33 +01:00
Chris Beams
923ec69966
Move 'torrcOptions' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
fea3a641c0
Move 'torrcFile' option handling to Config 2020-01-20 16:39:33 +01:00
Chris Beams
5a0683e984
Move 'socks5ProxyHttpAddress' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
5c02b12043
Move 'socks5ProxyBtcAddress' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
8d6dbad484
Move 'maxConnections' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
0e48a3ef2c
Move 'useLocalhostForP2P' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
ef7196ef8a
Finish moving 'nodePort' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
c56c06d939
Move 'banList' option handling to Config 2020-01-20 16:39:32 +01:00
Chris Beams
e118165e9a
Move 'seedNode' option handling to Config
And eliminate @Named injection in favor of calling config.getSeedNodes()
2020-01-20 16:39:31 +01:00
Chris Beams
f6319fe66f
Finish moving 'logLevel' option handling to Config 2020-01-20 16:39:31 +01:00
Chris Beams
f3e0b853db
Move 'btcNetworkDir' and co from BisqEnvironment to Config 2020-01-20 16:37:56 +01:00
Chris Beams
b34d59c0a9
Introduce Config as replacement for BisqEnvironment
Prior to this commit, BisqExecutable has been responsible for parsing
command line and config file options and BisqEnvironment has been
responsible for assigning default values to those options and providing
access to option values to callers throughout the codebase.

This approach has worked, but at considerable costs in complexity,
verbosity, and lack of any type-safety in option values. BisqEnvironment
is based on the Spring Framework's Environment abstraction, which
provides a great deal of flexibility in handling command line options,
environment variables, and more, but also operates on the assumption
that such inputs have String-based values.

After having this infrastructure in place for years now, it has become
evident that using Spring's Environment abstraction was both overkill
for what we needed and limited us from getting the kind of concision and
type saftey that we want. The Environment abstraction is by default
actually too flexible. For example, Bisq does not want or need to have
environment variables potentially overriding configuration file values,
as this increases our attack surface and makes our threat model more
complex. This is why we explicitly removed support for handling
environment variables quite some time ago.

The BisqEnvironment class has also organically evolved toward becoming a
kind of "God object", responsible for more than just option handling. It
is also, for example, responsible for tracking the status of the user's
local Bitcoin node, if any. It is also responsible for writing values to
the bisq.properties config file when certain ban filters arrive via the
p2p network. In the commits that follow, these unrelated functions will
be factored out appropriately in order to separate concerns.

As a solution to these problems, this commit begins the process of
eliminating BisqEnvironment in favor of a new, bespoke Config class
custom-tailored to Bisq's needs. Config removes the responsibility for
option parsing from BisqExecutable, and in the end provides "one-stop
shopping" for all option parsing and access needs.

The changes included in this commit represent a proof of concept for the
Config class, where handling of a number of options has been moved from
BisqEnvironment and BisqExecutable over to Config. Because the migration
is only partial, both Config and BisqEnvironment are injected
side-by-side into calling code that needs access to options. As the
migration is completed, BisqEnvironment will be removed entirely, and
only the Config object will remain.

An additional benefit of the elimination of BisqEnvironment is that it
will allow us to remove our dependency on the Spring Framework (with the
exception of the standalone pricenode application, which is Spring-based
by design).

Note that while this change and those that follow it are principally a
refactoring effort, certain functional changes have been introduced. For
example, Bisq now supports a `--configFile` argument at the command line
that functions very similarly to Bitcoin Core's `-conf` option.
2020-01-20 16:37:54 +01:00
sqrrm
fa3fcb4a10
Merge pull request #3887 from cbeams/revert-kotlin
Revert introduction of Kotlin compilation to the build
2020-01-20 10:06:14 +01:00
Chris Beams
f4ae5d3128
Revert "Apply kotlin plugin and convert one unused class to kotlin"
This reverts commit 26c053dae8 because
Kotlin compilation slows down the build, was applied too broadly to all
modules instead of just the one that needed it, and most importantly
because we never actually went ahead with converting anything of
importance to Kotlin. The commit being reverted was basically a demo,
converting a single test type to show what kind of difference it would
make.
2020-01-10 19:48:26 +01:00
Christoph Atteneder
5b0638f4e3
Update data stores 2020-01-08 11:57:21 +01:00
Christoph Atteneder
3fe84975ad
Merge pull request #3747 from julianknutsen/clean-up-pse-objs
(6/6) Clean up technical debt in P2PDataStorage and ProtectedStorageEntry objects
2019-12-09 20:34:26 +01:00
Julian Knutsen
e8c8225635
[PR COMMENTS] Fix comment typo
s/change/chance/
2019-12-09 09:12:57 -08:00
Julian Knutsen
7b8d346aea
Remove filter for ExpirablePayload
ProtectedStorageEntry::backDate() already handles this
2019-12-04 17:28:17 -08:00
Julian Knutsen
b166009398
Remove expire optimization in onDisconnect
We already have a garbage collection thread that runs every minute
to clean up items. Doing it again during onDisconnect is an unnecessary
optimization that adds complexity and caused bugs.

For example, the original implementation did not handle the sequence
number map correctly and was removing entries during a stream iteration.

This also reduces the complexity of testing. There is one code path
responsible for reducing ttls and one code path responsible for
expiring entries. Much easier to reason about.
2019-12-04 17:25:39 -08:00
Julian Knutsen
df2e4cc013
Refactor P2PDataStorage::onDisconnect
1. Remove delete during stream iteration
2. Minimize branching w/ early returns for bad states
3. Use stream filter for readability
4. Implement additional checks that should be done when removing entries
2019-12-04 17:04:05 -08:00
Julian Knutsen
688405bc6d
[TESTS] Make onDisconnect tests more robust
Before refactoring the function ensure the tests cover all cases. This
fixes a bug where the payload ttl was too low in some instances causing
backDate to do no work when it should.
2019-12-04 16:55:41 -08:00
Julian Knutsen
c38ff9bf95
s/networkPayload/protectedStoragePayload
Helps readability when the variable name matches the type.
2019-12-04 16:01:52 -08:00
Julian Knutsen
01a7f79eec
Make CHECK_TTL_INTERVAL_SEC final
It is never changed
2019-12-04 16:00:11 -08:00
Christoph Atteneder
acd4350762
Update data stores, translations and bitcoinj checkpoints (#3748)
* Update bitcoinj checkpoint file

* Update translations

* Update data stores
2019-12-04 22:26:42 +01:00
Julian Knutsen
104984cc22
@NotNull MailboxStoragePayload::senderPubKeyForAddOperation
In proto3 this is intialized to an empty ByteString so there is no valid
use for it to be null.
2019-12-04 11:39:26 -08:00
Julian Knutsen
76e8c5736a
@NotNull ProtectedStorageEntry::protectedStoragePayload
The ProtectedStoragePayload.fromProto code will throw an exception if
this is null from the wire so there is no valid use for it to be null.
2019-12-04 11:39:25 -08:00
Julian Knutsen
0c676080b6
@NotNull ProtectedStorageEntry::ownerPubKey
In proto3 the initialized value is an empty ByteString and there are no
valid uses of passing in null here.
2019-12-04 11:39:25 -08:00
Julian Knutsen
24ecfc7055
Remove ProtectedStorageEntry::maybeAdjustCreationTimeStamp
There is only 1 caller can be replaced with Math.min()
2019-12-04 11:37:53 -08:00
Julian Knutsen
b6b00268af
Remove ProtectedStorageEntry::updateSignature
The only users were tests that can just pass a bad signature directly
into the constructor.
2019-12-04 11:20:24 -08:00
Florian Reimair
dbf621ab45
Fix memory leak
We had a small memory leak in the code base. Namely, there have been some
threadpools in use but not shutdown when they have been no longer needed.
Result was that the threads and the parent threads have been kept alive
which lead to hundreds of stale threads over the course of several days.
2019-12-04 10:21:08 +01:00
Julian Knutsen
17f4b7096e
[TESTS] Clean up mockito never() and eq(null) usages
never() and any() don't play well together for nullable types. Change
the broadcast mocks to user nullable() and fixup tests.
2019-12-03 12:38:02 -08:00
Julian Knutsen
1bd450b3bc
[REFACTOR] inline maybeAddToRemoveAddOncePayloads() private function
Now that there is only one user it can be inlined.
2019-12-03 12:35:07 -08:00
Julian Knutsen
5a174d546a
[REFACTOR] inline broadcastProtectedStorageEntry() private function
Now that it is identical the the broadcaster version it can be
inlined.
2019-12-03 12:35:06 -08:00
Julian Knutsen
6ff8756dd8
[REFACTOR] inline broadcast() private function
Now that it is identical the the broadcaster version it can be
inlined.
2019-12-03 12:35:06 -08:00
Julian Knutsen
4dc4532c91
Remove isDataOwner from P2PDataStorage
Remove all usages in code and tests now that the behavior is
internal to the BroadcastHandler
2019-12-03 12:33:29 -08:00
Julian Knutsen
bfdb8f5715
Make isDataOwner a private policy decision in BroadcastHandler
isDataOwner is used when deciding how many peer nodes should receive
a BroadcastMessage. If the BroadcastMessage originated
on the local node it is sent to ALL peer nodes with a small delay.

If the node is only relaying the message (it originated on a different
node) it is sent to MAX(peers.size(), 7) peers with a delay that is
twice as long.

All the information needed to determine whether or not the
BroadcastMessage originated on the local node is available at the final
broadcast site and there is no reason to have callers pass it in.

In the event that the sender address is not known during broadcast (which
is only a remote possibility due to how early the local node address
is set during startup) we can default to relay mode.

This first patch just removes the deep parameters. The next will remove
everything else. There is one real change in LiteNodeNetworkService.java
where it was using the local node when it should have been using the
peer node. This was updated to the correct behavior.
2019-12-03 12:33:29 -08:00
Julian Knutsen
9f69134568
[REFACTOR] Clean up ClientAPI for refreshTTL
Remove isDataOwner from the client API. All users pass in true. All test
users don't care.
2019-12-03 12:30:07 -08:00
Julian Knutsen
77413c9671
[REFACTOR] Clean up ClientAPI for remove
Remove isDataOwner from the client API. All users pass in true. All test
users don't care.
2019-12-03 12:30:06 -08:00
Julian Knutsen
0e6b1a2044
[REFACTOR] Clean up ClientAPI for addProtectedStorageEntry
Remove isDataOwner from the client API. All users pass in true. All test
users don't care.
2019-12-03 12:30:06 -08:00
Julian Knutsen
56a7661a02
[REFACTOR] Clean up ClientAPI for addPersistableNetworkPayload
Now that more callers have moved internal, the public facing API
can be cleaner and more simple. This should lead to a more maintainable
API and less sharp edges with future development work.
2019-12-03 12:30:06 -08:00
Julian Knutsen
0649323505
Make addPersistableNetworkPayloadFromInitialRequest private
Now that the only user is internal, the API can be made private and the
tests can be removed. This involved adding a few test cases to
processGetDataResponse to ensure the invalid hash size condition was
still covered.
2019-12-03 12:30:05 -08:00
Julian Knutsen
4fe19aeec2
[DEADCODE] Remove old request handler tests
Now that all the implementations are unit tested in P2PDataStorage,
the old tests can be removed.
2019-12-03 12:20:42 -08:00
Julian Knutsen
b1a06fe4e2
Remove @Nullable around supportedCapabilities in PreliminaryGetDataRequest
The only two users of this constructor are the fromProto path which
now creates an empty Capabilities object similar to GetDataResponse.
The other internal usage of Capabilities.app which is initialized to empty.
2019-12-03 12:20:42 -08:00
Julian Knutsen
c503bcbaed
Remove @Nullable around supportedCapabilities in GetDataResponse
The only two users of this constructor are the fromProto path which
already creates an empty Capabilities object if one is not provided and
the internal usage of Capabilities.app which is initialized to empty.

Remove the @Nullable so future readers aren't confused.
2019-12-03 12:20:41 -08:00
Julian Knutsen
a0fae12068
Remove @Nullable around persistableNetworkPayloadSet
Checking for null creates hard-to-read code and it is simpler to just
create an empty set if we receive a pre-v0.6 GetDataResponse protobuf
message that does not have the field set.
2019-12-03 12:20:41 -08:00
Julian Knutsen
ecae31eddb
[RENAME] LazyProcessedPayload to ProcessOncePersistableNetworkPayload
Name is left over from previous implementation. Change it to be more
relevant to the current code and update comments to indicate the
current usage.
2019-12-03 12:20:41 -08:00
Julian Knutsen
5db128587f
[REFACTOR] Clean up processGetDataResponse
- Add more comments
- Use Clock instead of System
- Remove unnecessary AtomicInteger
2019-12-03 12:20:40 -08:00
Julian Knutsen
f92893b097
[TESTS] Write synchronization integration tests
Write a few integration test that exercises the exercise interesting
synchronization states including the lost remove bug. This fails
with the proper validation, but will pass at the end of the new feature
development.
2019-12-03 12:20:40 -08:00
Julian Knutsen
3d6e9fbef5
Remove static from initialRequestApplied
Previously, multiple handlers needed to signal off one global variable.
Now, that this check is inside the singleton P2PDataStorage, make it
non-static and private.
2019-12-03 12:20:40 -08:00
Julian Knutsen
a34488b735
[TESTS] Add unit tests for processGetDataResponse
Add a full set of unit tests that uncovered some unexpected
behavior w.r.t. signalers.
2019-12-03 12:20:39 -08:00
Julian Knutsen
690b9808b1
[TESTS] Make verify() functions more flexible
Now that we want to unit test the GetData path which has different
behavior w.r.t. broadcasts, the tests need a way to verify that
state was updated, but not broadcast during an add.

This patch changes all verification function to take each state update
explicitly so the tests can do the proper verification.
2019-12-03 12:20:39 -08:00
Julian Knutsen
873271c5ce
[REFACTOR] Introduce processGetDataResponse
Just a code move for now.
2019-12-03 12:20:39 -08:00
Julian Knutsen
c7bce9e999
[TESTS] Add test of RequestDataHandler::onMessage
Add heavy-handed test that exercises the logic to use as a safeguard
for refactoring.
2019-12-03 12:20:38 -08:00
Julian Knutsen
00128d912d
[BUGFIX] Fix off-by-one in truncation logic
Now, the truncation is only triggered if more than MAX_ENTRIES could
have been returned.
2019-12-03 12:20:38 -08:00
Julian Knutsen
e7673407f1
[REFACTOR] Remove duplication in filtering functions
Introduce a generic function that can be used to filter
Map<ByteArray, PersistableNetworkPayload> or
Map<ByteArray, ProtectedStorageEntry>.

Used to deduplicate the GetData code paths and ensure the logic is the
same between the two payload types.
2019-12-03 12:20:37 -08:00
Julian Knutsen
4c5d8184b7
[REFACTOR] Inline filtering functions
Removes unnecessary calculations converting Set<byte[]> into
Set<ByteArray> and allows additional deduplication of stream operations.
2019-12-03 12:20:37 -08:00
Julian Knutsen
3aaf8a285e
[REFACTOR] Inline capability check for ProtectedStorageEntries
Move the capability check inside the stream operation. This should
improve performance slightly, but more importantly it makes the
two filter functions almost identical so they can be combined.
2019-12-03 12:20:37 -08:00
Julian Knutsen
703a9a0ddd
[REFACTOR] Move required capabilities log
Move the logging function to the common capabilities check
so it can run on both ProtectedStoragePayload and
PersistableNetworkPayload objects
2019-12-03 12:20:36 -08:00
Julian Knutsen
caf946dfe0
Remove redundant HashSet lookups in filter functions
The appendOnlyDataStoreService and map already have unique keys that
are based on the hash of the payload. This would catch instances
where:

PersistableNetworkPayload
- None: The key is based on ByteArray(payload.getHash()) which is the
        same as this check.

ProtectedStorageEntry
- Cases where multiple PSEs contain payloads that have equivalent
  hashCode(), but different data.toProtoMessage().toByteArray().
  I don't think it is a good idea to keep 2 "unique" methods on
  payloads. This is likely left over from a time when
  Payload hashCode() needed to be different than the hash of
  the payload.
2019-12-03 12:20:36 -08:00
Julian Knutsen
5630b35755
[TESTS] Unit tests of buildGetDataResponse
Write a full set of unit tests for buildGetDataResponse. This provides
a safety net with additional refactoring work.
2019-12-03 12:20:36 -08:00
Julian Knutsen
dafc76200a
[REFACTOR] Pass peerCapabilities into buildGetDataResponse
Remove the dependence on the connection object by having the handler
pass in the peer's capabilities. This now allows unit testing of
buildGetDataResponse without any connection dependencies.
2019-12-03 12:20:35 -08:00
Julian Knutsen
a6e8868563
[REFACTOR] Extract truncation logging
Move the logging that utilizes connection information into the request
handler. Now, buildGetDataResponse just returns whether or not the list
is truncated which will make it easier to test.
2019-12-03 12:20:35 -08:00
Julian Knutsen
54021551bf
[REFACTOR] Extract getDataResponse logging
Changed the log to reference getDataResponse instead of getData. Now
that we might truncate the response, it ins't true that this is exactly
what the peer asked.
2019-12-03 12:20:35 -08:00
Julian Knutsen
8208f78837
[REFACTOR] Extract connectionInfo String 2019-12-03 12:20:34 -08:00
Julian Knutsen
944b3fffbc
[REFACTOR] Introduce buildGetDataResponse
This is just a strict move of code to reduce errors.
2019-12-03 12:20:34 -08:00
Julian Knutsen
daffe6dc38
[TESTS] Add tests of GetDataRequestHandler
Add some basic sanity tests prior to the refactor to help catch issues.
2019-12-03 12:20:34 -08:00
Julian Knutsen
a927ed42ac
[TESTS] Add tests of new RequestData APIs
These are identical test cases to the requestHandler tests, but with much
fewer dependencies. The requestHandler tests will eventually be deleted,
but they are going to remain throughout development as an extra safety
net.
2019-12-03 12:20:33 -08:00
Julian Knutsen
1e814d9f1d
[REFACTOR] Introduce buildGetDataRequest variants
As part of changing the GetData path, we want to move all creation
and processing of GetData messages inside P2PDataStorage. This will allow
easier unit testing of the behavior as well as cleaner code in the
request handlers that can just focus on nonces, connections, etc.
2019-12-03 12:20:33 -08:00
Julian Knutsen
5fcd18c4b5
[TESTS] Add tests of requestData
This will allow us to push the GetData creation inside P2PDataStorage
safely.
2019-12-03 12:20:28 -08:00
Christoph Atteneder
3b384172a4
Update data stores 2019-11-27 10:26:24 +01:00
Christoph Atteneder
9c3c6182c2
Refactor checkMaxConnections (#3126)
* Change access level for checkMaxConnections to be tested

* Refactor checkMaxConnections

Fix connection limit checks so as to prevent the following warning:

> WARN  b.n.p2p.peers.PeerManager: No candidates found to remove (That
case should not be possible as we use in the last case all
connections).

* Add MockNode that allows for simulating connections

* Add PeerManagerTest

The old PeerManagerTest was located under network/p2p/routing, which is
no longer the correct location. Additionally, it was outdated so I
just removed it and added a new file under network/p2p/peers containing
tests for checkMaxConnections.

* Add testCompile dependency to core

This is necessary because bisq.network.p2p.MockNode imports
bisq.core.network.p2p.seed.DefaultSeedNodeRepository.

* Update based on review feedback

Mock the SeedNodeRepository superclass, thus eliminating the dependency
to core.
2019-11-26 15:16:07 +01:00
Christoph Atteneder
b15eb70485
(8/8) Persist changes to ProtectedStoragePayload objects implementing PersistablePayload (#3640)
* [PR COMMENTS] Make maxSequenceNumberBeforePurge final

Instead of using a subclass that overwrites a value, utilize Guice
to inject the real value of 10000 in the app and let the tests overwrite
it with their own.

* [TESTS] Clean up 'Analyze Code' warnings

Remove unused imports and clean up some access modifiers now that
the final test structure is complete

* [REFACTOR] HashMapListener::onAdded/onRemoved

Previously, this interface was called each time an item was changed. This
required listeners to understand performance implications of multiple
adds or removes in a short time span.

Instead, give each listener the ability to process a list of added or
removed entrys which can help them avoid performance issues.

This patch is just a refactor. Each listener is called once for each
ProtectedStorageEntry. Future patches will change this.

* [REFACTOR] removeFromMapAndDataStore can operate on Collections

Minor performance overhead for constructing MapEntry and Collections
of one element, but keeps the code cleaner and all removes can still
use the same logic to remove from map, delete from data store, signal
listeners, etc.

The MapEntry type is used instead of Pair since it will require less
operations when this is eventually used in the removeExpiredEntries path.

* Change removeFromMapAndDataStore to signal listeners at the end in a batch

All current users still call this one-at-a-time. But, it gives the ability
for the expire code path to remove in a batch.

* Update removeExpiredEntries to remove all items in a batch

This will cause HashMapChangedListeners to receive just one onRemoved()
call for the expire work instead of multiple onRemoved() calls for each
item.

This required a bit of updating for the remove validation in tests so
that it correctly compares onRemoved with multiple items.

* ProposalService::onProtectedDataRemoved signals listeners once on batch removes

#3143 identified an issue that tempProposals listeners were being
signaled once for each item that was removed during the P2PDataStore
operation that expired old TempProposal objects. Some of the listeners
are very expensive (ProposalListPresentation::updateLists()) which results
in large UI performance issues.

Now that the infrastructure is in place to receive updates from the
P2PDataStore in a batch, the ProposalService can apply all of the removes
received from the P2PDataStore at once. This results in only 1 onChanged()
callback for each listener.

The end result is that updateLists() is only called once and the performance
problems are reduced.

This removes the need for #3148 and those interfaces will be removed in
the next patch.

* Remove HashmapChangedListener::onBatch operations

Now that the only user of this interface has been removed, go ahead
and delete it. This is a partial revert of
f5d75c4f60 that includes the code that was
added into ProposalService that subscribed to the P2PDataStore.

* [TESTS] Regression test for #3629

Write a test that shows the incorrect behavior for #3629, the hashmap
is rebuilt from disk using the 20-byte key instead of the 32-byte key.

* [BUGFIX] Reconstruct HashMap using 32-byte key

Addresses the first half of #3629 by ensuring that the reconstructed
HashMap always has the 32-byte key for each payload.

It turns out, the TempProposalStore persists the ProtectedStorageEntrys
on-disk as a List and doesn't persist the key at all. Then, on
reconstruction, it creates the 20-byte key for its internal map.

The fix is to update the TempProposalStore to use the 32-byte key instead.
This means that all writes, reads, and reconstrution of the TempProposalStore
uses the 32-byte key which matches perfectly with the in-memory map
of the P2PDataStorage that expects 32-byte keys.

Important to note that until all seednodes receive this update, nodes
will continue to have both the 20-byte and 32-byte keys in their HashMap.

* [BUGFIX] Use 32-byte key in requestData path

Addresses the second half of #3629 by using the HashMap, not the
protectedDataStore to generate the known keys in the requestData path.

This won't have any bandwidth reduction until all seednodes have the
update and only have the 32-byte key in their HashMap.

fixes #3629

* [DEAD CODE] Remove getProtectedDataStoreMap

The only user has been migrated to getMap(). Delete it so future
development doesn't have the same 20-byte vs 32-byte key issue.

* [TESTS] Allow tests to validate SequenceNumberMap write separately

In order to implement remove-before-add behavior, we need a way to
verify that the SequenceNumberMap was the only item updated.

* Implement remove-before-add message sequence behavior

It is possible to receive a RemoveData or RemoveMailboxData message
before the relevant AddData, but the current code does not handle
it.

This results in internal state updates and signal handler's being called
when an Add is received with a lower sequence number than a previously
seen Remove.

Minor test validation changes to allow tests to specify that only the
SequenceNumberMap should be written during an operation.

* [TESTS] Allow remove() verification to be more flexible

Now that we have introduced remove-before-add, we need a way
to validate that the SequenceNumberMap was written, but nothing
else. Add this feature to the validation path.

* Broadcast remove-before-add messages to P2P network

In order to aid in propagation of remove() messages, broadcast them
in the event the remove is seen before the add.

* [TESTS] Clean up remove verification helpers

Now that there are cases where the SequenceNumberMap and Broadcast
are called, but no other internal state is updated, the existing helper
functions conflate too many decisions. Remove them in favor of explicitly
defining each state change expected.

* [BUGFIX] Fix duplicate sequence number use case (startup)

Fix a bug introduced in d484617385 that
did not properly handle a valid use case for duplicate sequence numbers.

For in-memory-only ProtectedStoragePayloads, the client nodes need a way
to reconstruct the Payloads after startup from peer and seed nodes. This
involves sending a ProtectedStorageEntry with a sequence number that
is equal to the last one the client had already seen.

This patch adds tests to confirm the bug and fix as well as the changes
necessary to allow adding of Payloads that were previously seen, but
removed during a restart.

* Clean up AtomicBoolean usage in FileManager

Although the code was correct, it was hard to understand the relationship
between the to-be-written object and the savePending flag.

Trade two dependent atomics for one and comment the code to make it more
clear for the next reader.

* [DEADCODE] Clean up FileManager.java

* [BUGFIX] Shorter delay values not taking precedence

Fix a bug in the FileManager where a saveLater called with a low delay
won't execute until the delay specified by a previous saveLater call.

The trade off here is the execution of a task that returns early vs.
losing the requested delay.

* [REFACTOR] Inline saveNowInternal

Only one caller after deadcode removal.

* [TESTS] Introduce MapStoreServiceFake

Now that we want to make changes to the MapStoreService,
it isn't sufficient to have a Fake of the ProtectedDataStoreService.

Tests now use a REAL ProtectedDataStoreService and a FAKE MapStoreService
to exercise more of the production code and allow future testing of
changes to MapStoreService.

* Persist changes to ProtectedStorageEntrys

With the addition of ProtectedStorageEntrys, there are now persistable
maps that have different payloads and the same keys. In the
ProtectedDataStoreService case, the value is the ProtectedStorageEntry
which has a createdTimeStamp, sequenceNumber, and signature that can
all change, but still contain an identical payload.

Previously, the service was only updating the on-disk representation on
the first object and never again. So, when it was recreated from disk it
would not have any of the updated metadata. This was just copied from the
append-only implementation where the value was the Payload
which was immutable.

This hasn't caused any issues to this point, but it causes strange behavior
such as always receiving seqNr==1 items from seednodes on startup. It
is good practice to keep the in-memory objects and on-disk objects in
sync and removes an unexpected failure in future dev work that expects
the same behavior as the append-only on-disk objects.

* [DEADCODE] Remove protectedDataStoreListener

There were no users.

* [DEADCODE] Remove unused methods in ProtectedDataStoreService
2019-11-26 14:47:38 +01:00
Christoph Atteneder
62aea83308
Cleanup fmxlview and javax imports (#3661)
* Remove @FxmlView from abstract view classes

* Use generic javax imports for DI

* Additional cleanup of redundant DI annotations
2019-11-26 14:36:01 +01:00
Julian Knutsen
44a11a0619
[DEADCODE] Remove unused methods in ProtectedDataStoreService 2019-11-25 17:54:52 -08:00
Julian Knutsen
3503fe3b10
[DEADCODE] Remove protectedDataStoreListener
There were no users.
2019-11-25 17:54:52 -08:00
Julian Knutsen
f3faf4bb63
Persist changes to ProtectedStorageEntrys
With the addition of ProtectedStorageEntrys, there are now persistable
maps that have different payloads and the same keys. In the
ProtectedDataStoreService case, the value is the ProtectedStorageEntry
which has a createdTimeStamp, sequenceNumber, and signature that can
all change, but still contain an identical payload.

Previously, the service was only updating the on-disk representation on
the first object and never again. So, when it was recreated from disk it
would not have any of the updated metadata. This was just copied from the
append-only implementation where the value was the Payload
which was immutable.

This hasn't caused any issues to this point, but it causes strange behavior
such as always receiving seqNr==1 items from seednodes on startup. It
is good practice to keep the in-memory objects and on-disk objects in
sync and removes an unexpected failure in future dev work that expects
the same behavior as the append-only on-disk objects.
2019-11-25 17:54:52 -08:00
Julian Knutsen
66f71e59f8
[TESTS] Introduce MapStoreServiceFake
Now that we want to make changes to the MapStoreService,
it isn't sufficient to have a Fake of the ProtectedDataStoreService.

Tests now use a REAL ProtectedDataStoreService and a FAKE MapStoreService
to exercise more of the production code and allow future testing of
changes to MapStoreService.
2019-11-25 17:54:44 -08:00
Julian Knutsen
3d571c4ca3
[BUGFIX] Fix duplicate sequence number use case (startup)
Fix a bug introduced in d484617385 that
did not properly handle a valid use case for duplicate sequence numbers.

For in-memory-only ProtectedStoragePayloads, the client nodes need a way
to reconstruct the Payloads after startup from peer and seed nodes. This
involves sending a ProtectedStorageEntry with a sequence number that
is equal to the last one the client had already seen.

This patch adds tests to confirm the bug and fix as well as the changes
necessary to allow adding of Payloads that were previously seen, but
removed during a restart.
2019-11-25 08:13:49 -08:00
Julian Knutsen
6e2ea6e3ed
[TESTS] Clean up remove verification helpers
Now that there are cases where the SequenceNumberMap and Broadcast
are called, but no other internal state is updated, the existing helper
functions conflate too many decisions. Remove them in favor of explicitly
defining each state change expected.
2019-11-22 08:42:58 -08:00
Julian Knutsen
0472ffc794
Broadcast remove-before-add messages to P2P network
In order to aid in propagation of remove() messages, broadcast them
in the event the remove is seen before the add.
2019-11-22 08:35:57 -08:00
Julian Knutsen
931c1f47b4
[TESTS] Allow remove() verification to be more flexible
Now that we have introduced remove-before-add, we need a way
to validate that the SequenceNumberMap was written, but nothing
else. Add this feature to the validation path.
2019-11-22 08:16:02 -08:00
Justin Carter
d4e7f86ff6
Use generic javax imports for DI 2019-11-22 14:50:21 +01:00
Julian Knutsen
372c26de74
Implement remove-before-add message sequence behavior
It is possible to receive a RemoveData or RemoveMailboxData message
before the relevant AddData, but the current code does not handle
it.

This results in internal state updates and signal handler's being called
when an Add is received with a lower sequence number than a previously
seen Remove.

Minor test validation changes to allow tests to specify that only the
SequenceNumberMap should be written during an operation.
2019-11-20 16:31:56 -08:00
Julian Knutsen
526aee5ed4
[TESTS] Allow tests to validate SequenceNumberMap write separately
In order to implement remove-before-add behavior, we need a way to
verify that the SequenceNumberMap was the only item updated.
2019-11-20 16:31:56 -08:00
Devin Bileck
e99d450725
Update based on review feedback
Mock the SeedNodeRepository superclass, thus eliminating the dependency
to core.
2019-11-20 16:29:06 -08:00
Julian Knutsen
793e84d888
[DEAD CODE] Remove getProtectedDataStoreMap
The only user has been migrated to getMap(). Delete it so future
development doesn't have the same 20-byte vs 32-byte key issue.
2019-11-20 16:23:41 -08:00
Julian Knutsen
455f7d2689
[BUGFIX] Use 32-byte key in requestData path
Addresses the second half of #3629 by using the HashMap, not the
protectedDataStore to generate the known keys in the requestData path.

This won't have any bandwidth reduction until all seednodes have the
update and only have the 32-byte key in their HashMap.

fixes #3629
2019-11-20 16:20:38 -08:00
Julian Knutsen
e212240b88
[BUGFIX] Reconstruct HashMap using 32-byte key
Addresses the first half of #3629 by ensuring that the reconstructed
HashMap always has the 32-byte key for each payload.

It turns out, the TempProposalStore persists the ProtectedStorageEntrys
on-disk as a List and doesn't persist the key at all. Then, on
reconstruction, it creates the 20-byte key for its internal map.

The fix is to update the TempProposalStore to use the 32-byte key instead.
This means that all writes, reads, and reconstrution of the TempProposalStore
uses the 32-byte key which matches perfectly with the in-memory map
of the P2PDataStorage that expects 32-byte keys.

Important to note that until all seednodes receive this update, nodes
will continue to have both the 20-byte and 32-byte keys in their HashMap.
2019-11-20 16:15:52 -08:00
Julian Knutsen
849155a92a
[TESTS] Regression test for #3629
Write a test that shows the incorrect behavior for #3629, the hashmap
is rebuilt from disk using the 20-byte key instead of the 32-byte key.
2019-11-19 12:39:43 -08:00
Julian Knutsen
a8139f3a04
Remove HashmapChangedListener::onBatch operations
Now that the only user of this interface has been removed, go ahead
and delete it. This is a partial revert of
f5d75c4f60 that includes the code that was
added into ProposalService that subscribed to the P2PDataStore.
2019-11-19 08:37:40 -08:00
Julian Knutsen
eae641ee73
Update removeExpiredEntries to remove all items in a batch
This will cause HashMapChangedListeners to receive just one onRemoved()
call for the expire work instead of multiple onRemoved() calls for each
item.

This required a bit of updating for the remove validation in tests so
that it correctly compares onRemoved with multiple items.
2019-11-19 08:37:39 -08:00
Julian Knutsen
489b25aa13
Change removeFromMapAndDataStore to signal listeners at the end in a batch
All current users still call this one-at-a-time. But, it gives the ability
for the expire code path to remove in a batch.
2019-11-19 08:37:38 -08:00
Julian Knutsen
4f08588717
[REFACTOR] removeFromMapAndDataStore can operate on Collections
Minor performance overhead for constructing MapEntry and Collections
of one element, but keeps the code cleaner and all removes can still
use the same logic to remove from map, delete from data store, signal
listeners, etc.

The MapEntry type is used instead of Pair since it will require less
operations when this is eventually used in the removeExpiredEntries path.
2019-11-19 08:37:38 -08:00
Julian Knutsen
b281566e14
[REFACTOR] HashMapListener::onAdded/onRemoved
Previously, this interface was called each time an item was changed. This
required listeners to understand performance implications of multiple
adds or removes in a short time span.

Instead, give each listener the ability to process a list of added or
removed entrys which can help them avoid performance issues.

This patch is just a refactor. Each listener is called once for each
ProtectedStorageEntry. Future patches will change this.
2019-11-19 08:37:38 -08:00
Julian Knutsen
3bd67bab05
[TESTS] Clean up 'Analyze Code' warnings
Remove unused imports and clean up some access modifiers now that
the final test structure is complete
2019-11-19 08:30:24 -08:00
Julian Knutsen
617585d859
[PR COMMENTS] Make maxSequenceNumberBeforePurge final
Instead of using a subclass that overwrites a value, utilize Guice
to inject the real value of 10000 in the app and let the tests overwrite
it with their own.
2019-11-19 08:30:24 -08:00
Julian Knutsen
bdfe32bd18
[BUGFIX] Validate Entry.receiversPubKey for MailboxPayloads
The remove code checks to ensure these fields match, but the add code
never did. This could lead to a situation where a MailboxStoragePayload
could be added, but never removed.
2019-11-14 10:19:28 -08:00
Julian Knutsen
9ffbcf795e
[REFACTOR] Use common path for updating map/data store on remove
Previously, the expire path, the remove path, and the onDisconnect
all used separate logic for updating the map, signaling listeners, and
removing PersistablePaylod objects from the data store. This led to a
bug where the onDisconnect path did not update the protectedDataStore.

Combine the three code paths to ensure that the same state is updated
regardless of the context.
2019-11-14 10:08:08 -08:00
Julian Knutsen
b10a603ead
[BUGFIX] Correctly remove PersistablePayload in onDisconnect path
The code to remove expired Entrys in the onDisconnect path was not
correctly removing the Entry from the protectedDataStore.

This patch adds a test that failed and fixes the bug.
2019-11-14 10:08:07 -08:00
Julian Knutsen
8ecb5b9cb1
[REFACTOR] Clean up removeExpiredEntries
* All of this work is done on the UserThread so there is no need to
clone the map.

* ArrayList objects are faster to iterate than HashSets and the data is
  guaranteed to be unique since the source is a ConcurrentHashMap

* Finding all items to remove first, then removing them all is an easier
  to read code pattern instead of removing during iteration.
2019-11-14 10:04:59 -08:00
Julian Knutsen
bdef1e46ea
Add payload safety checks in ProtectedStorageEntry
It is currently possible to construct a valid Payload object
that implements both the ProtectedStoragePayload and
PersistableNetworkPayload interfaces even though this combination is
invalid.

Instead of depending on future reviewers to catch an error, assert that
ProtectedStoragePayloads and PersistableNetworkPayloads are incompatible
as objects inside a ProtectedStorageEntry.

This allows cleanup of removeExpiredEntries that branched on this
behavior.
2019-11-14 08:42:47 -08:00
Devin Bileck
b45765feb5
Add PeerManagerTest
The old PeerManagerTest was located under network/p2p/routing, which is
no longer the correct location. Additionally, it was outdated so I
just removed it and added a new file under network/p2p/peers containing
tests for checkMaxConnections.
2019-11-12 23:30:31 -08:00
Devin Bileck
6f80b8a964
Add MockNode that allows for simulating connections 2019-11-12 23:15:57 -08:00
Julian Knutsen
c81f8a6da3
[TESTS] Rename P2PDataStoreTest
File name now reflects the actual tests run after everything
was split up.
2019-11-12 18:06:47 -08:00
Julian Knutsen
14c78c1c85
[TESTS] Add missing license text to test files 2019-11-12 18:05:25 -08:00
Julian Knutsen
fc553121bf
[TESTS] Make SavedTestState ctor private to TestState
All test callers now just ask the TestState for a SavedTestState instead
of SavedTestState ctor. This makes more sense with the object
relationship since SavedTestState is only used internally to TestState.
2019-11-12 18:05:25 -08:00
Julian Knutsen
fa82c177f1
[TESTS] Clean up TestState static methods
All users pass in an instance of TestState, just make it an instance
method instead of static.
2019-11-12 18:05:25 -08:00
Julian Knutsen
10384acdcc
[TESTS] Split monolithic P2PDataStoreTest into separate files
One monolithic test was useful when it was under development to reduce
code churn, but now that the tests are complete it is easier to find
and run a specific test when separated into separate test files.

This also fixes a downside of Enclosed.class that didn't allow individual
tests to be run in intellij.
2019-11-12 18:05:20 -08:00
Julian Knutsen
eb2f8f315e
[TESTS] Add JavaDocs for test objects
Add JavaDocs for the various Stub and Fake objects that are used
in the P2PDataStore test so future developers can understand why they
exist.
2019-11-12 17:59:16 -08:00
Julian Knutsen
c652528ca1
[DEAD CODE] Remove obsolete tests 2019-11-12 17:47:34 -08:00
Julian Knutsen
d980932748
[DEAD CODE] Remove unused functions and imports 2019-11-12 17:47:33 -08:00
Julian Knutsen
26afd11bbf
[TESTS] Remove dead tests and code
Purge all the superseded tests and helper functions now that everything
can be unit tested.
2019-11-12 17:47:30 -08:00
Julian Knutsen
285214803e
[TESTS] Start deprecating integrations tests
Now that the unit tests cover all of the per-Entry validation,
the tests that create specific configuration of ProtectedStorageEntry
and ProtectedMailboxStorageEntry objects can be removed in favor
of mockable Entrys.

Using mocks prior to this patch was impossible due to the relationship
between the Entry objects and the P2PDataStorage helper functions. Now
that the objects are properly abstracted and tested, real unit tests
can be written for the P2PDataStore module.

This patch leaves the tests and adds an @Ignore so the reviewer can see
which unit test now supersedes the integration test.
2019-11-12 17:44:33 -08:00
Julian Knutsen
5d35d08b00
[PR COMMENTS] Logging format and function rename
Use a more compact version of string formatting
in log messages

Rename isMetadataEquals to matchesRelevantPubKey
which is more descriptive of the actual check
2019-11-12 16:36:35 -08:00
Julian Knutsen
5ae9dd1e17
Combine remove() and removeMailboxData()
Now that all the code is abstracted and tested, the remove()
and removeMailboxData() functions are identical. Combine them and update
callers appropriately.

Now, any caller don't need to know the difference and it removes the
sharp edge originally found in #3556
2019-11-12 16:22:03 -08:00
Julian Knutsen
53b5feb7a0
[TESTS] Update remove validation with BroadcastMessage type
Make the remove validation more robust by asserting that the
correct remove message is broadcast. This will provide a better
safety net when combining the remove functions.
2019-11-12 16:19:58 -08:00
Julian Knutsen
289788e374
Introduce isMetadataEquals and use it
Let the objects compare their metadata instead of doing it for them. This
allows for actual unit testing and paves the way for deduplicating the
remove code paths.

This patch also removes an unnecessary check around comparing the hash
of the stored data to the new data's hash. That check can't fail since
the hash was a requirement for the map lookup in the first place.
2019-11-12 16:19:44 -08:00
Julian Knutsen
0c07883c17
Remove duplicate check in refreshTTL
The current check verifies that the stored Payload.ownerPubKey == stored Entry.ownerPubKey.

This is the same check that was done when the item was originally added
and there is no reason to do it again.
2019-11-12 16:18:02 -08:00
Julian Knutsen
28a7bc887c
[REFACTOR] Move receiversPubKey check behind isValidForRemoveOperation()
This mailbox-only check can now exist inside the object for which it
belongs. This makes it easier to test and moves closer to allowing
the deduplication of the remove() methods.
2019-11-12 16:18:02 -08:00
Julian Knutsen
f915a03ff9
[REFACTOR] Move signature validation behind isValidForRemoveOperation()
Move the signature checks into the objects to clean up the calling code
and make it more testable.
2019-11-12 16:18:01 -08:00
Julian Knutsen
9c7dc0c1ad
[REFACTOR] Move signature validation behind isValidForAddOperation()
Move the signature checks into the objects to clean up the calling code
and make it more testable.

The testing now has to take real hashes so some work was done in the fixtures
to create valid hashable objects.
2019-11-12 16:18:01 -08:00
Julian Knutsen
40337ff1b8
Clean up toString() methods
Add toString() for ProtectedStorageEntry so log messages have useful
information and clean up the formatting.
2019-11-12 16:18:01 -08:00
Julian Knutsen
217a321bbe
[REFACTOR] Remove checkPublicKeys()
Now that the objects can answer questions about valid conditions
for add/remove, ask them directly.

This also pushes the logging down into the ProtectedStorageEntry and
ProtectedMailboxStorageEntry and cleans up the message.
2019-11-12 16:18:00 -08:00
Julian Knutsen
a6317779ed
[REFACTOR] ProtectedStorageEntry::isValidForRemoveOperation()
Extract code from P2PDataStore, test it, and use new methods.
2019-11-12 16:18:00 -08:00
Julian Knutsen
ebf33e2ff1
[REFACTOR] ProtectedStorageEntry::validForAddOperation()
Method bodies are copied from P2PDataStore to separate refactoring
efforts and behavior changes.

Identified a bug where a ProtectedMailboxStorageEntry mailbox entry
could be added, but never removed.
2019-11-12 16:18:00 -08:00
Julian Knutsen
54b4b4df15
[TESTS] Add more tests around mis-wrapped ProtectedStorageEntrys
The code around validating MailboxStoragePayloads is subtle when
a MailboxStoragePayload is wrapped in a ProtectedStorageEntry. Add tests
to document the current behavior.
2019-11-12 16:17:59 -08:00
Julian Knutsen
2c2a57ef9d
[REFACTOR] Remove duplicated code in refreshTTL
The custom code to verify the refreshTTLMessage's signature and update
an entry isn't necessary. Just have the code construct an updated
ProtectedStorageEntry from the existing and new data, verify it,
and add it to the map.

This also allows the removal of the ProtectedStorageEntry APIs
that modify internal state.
2019-11-12 16:13:47 -08:00
Julian Knutsen
454b2d79e1
[TESTS] Lower entries required for purge in tests
The original test would take over 5 seconds. Allow tests to set the number
of required entries before purge to a lower value so the tests
can run faster with the same confidence.
2019-11-12 15:59:57 -08:00
Julian Knutsen
898d7fcd4a
[TESTS] Test onBootstrapComplete()
Add tests for removing expired entries and optionally purging
the sequence number map. Now possible since these tests have
control over time with the ClockFake.

The remove validation needed to be improved since deletes through
the expire path don't signal HashMap listeners or write sequence numbers.
2019-11-12 15:59:48 -08:00
Julian Knutsen
89ad234c43
[TESTS] Use ClockFake in tests to control time
Reduces non-deterministic failures of the refreshTTL tests that resulted
from the uncontrollable System.currentTimeMillis().

Now, all tests have extremely fine control over the elapsed time between
calls which makes the current and future tests much better.
2019-11-12 15:58:36 -08:00
Julian Knutsen
10eb9c0d01
Use Clock in ProtectedStorageEntry
Switch from System.currentTimeMills() to
Clock.millis() so dependency injection can
be used for tests that need finer control of time.

This involves attaching a Clock to the resolver
so all fromProto methods have one available when they
reconstruct a message. This uses the Injector for the APP
and a default Clock.systemDefaultZone is used in the manual
instantiations.

Work was already done in #3037 to make this possible.

All tests still use the default system clock for now.
2019-11-12 15:58:01 -08:00
Julian Knutsen
42680037bd
[REFACTOR] Clean up ProtectedStorageEntry ctor
Deduplicate some code in the ProtectedStorageEntry constructors in
preparation for passing in a Clock parameter.
2019-11-12 15:55:34 -08:00
Julian Knutsen
de72d3954d
Use dependency injected Clock in P2PDataStore
Use the DI Clock object already available in P2PDataStore, instead
of calling System.currentTimeMillis() directly. These two functions
have the same behavior and switching over allows finer control
of time in the tests.
2019-11-12 15:55:34 -08:00
Devin Bileck
22e93d9ecd
Change access level for checkMaxConnections to be tested 2019-11-12 00:55:30 -08:00
Devin Bileck
6b22690578
Refactor checkMaxConnections
Fix connection limit checks so as to prevent the following warning:

> WARN  b.n.p2p.peers.PeerManager: No candidates found to remove (That
case should not be possible as we use in the last case all
connections).
2019-11-12 00:55:30 -08:00
Julian Knutsen
e5f9261d97
Update behavior of P2PDataStorage::remove() & removeMailboxData() on duplicate sequence #s
Remove operations are now only processed if the sequence number
is greater than the last operation seen for a specific payload.

The only creator of new remove entrys is the P2PService layer that always increments
the sequence number. So, this is either left around from a time where
removes needed to work with non-incrementing sequence numbers or just
a longstanding bug.

With the completion of this patch, all operations now require increasing
sequence numbers so it should be easier to reason about the behavior in
future debugging.
2019-11-11 08:49:31 -08:00
Julian Knutsen
cbda653aba
Update behavior of P2PDataStorage::refreshTTL() on duplicates
Now returns false if the sequence number of the refresh matches
the last operation seen for the specified hash. This is a more expected
return value when no state change occurs.

The only callers are either P2PService users that always increment the
sequence number or the onMessage() handler which doesn't verify the return
so there will be no visible change other than the increased readability
of the code and deduplication of the code paths.
2019-11-11 08:49:31 -08:00
Julian Knutsen
c1ad6b408b
Update behavior of P2PDataStorage::addProtectedStorageEntry() on duplicates
Now returns false on duplicate sequence numbers. This matches more of
the expected behavior for an add() function when the element previously exists.

The only callers are either P2PService users that always increment the
sequence number or the onMessage() handler which doesn't verify the return
so there will be no visible change other than the increased readability
of the code and deduplication of the code paths.
2019-11-11 08:49:27 -08:00
Julian Knutsen
86c8c839d1
[PR COMMENTS] Clean up logging messages
Removed duplicate log messages that are handled inside the various helper methods
and print more verbose state useful for debugging.

Updated potentially misleading comments around hashing collisions
2019-11-11 08:37:38 -08:00
Julian Knutsen
66e3ece63e
[REFACTOR] P2PDataStorage::removeMailboxData()
Refactor for readability and add comments for future readers.
2019-11-11 08:36:47 -08:00
Julian Knutsen
a569852524
[REFACTOR] P2PDataStorage::remove()
Refactor for readability and add comments to help future readers.
2019-11-11 08:36:47 -08:00
Julian Knutsen
ae502709ee
[REFACTOR] P2PDataStorage::refreshTTL()
Refactor for readability and add comments for future readers.
2019-11-11 08:36:46 -08:00
Julian Knutsen
f2f6399cac
[REFACTOR] P2PDataStorage::addProtectedStorageEntry()
Refactor addProtectedStorageEntry for more readability and add comments
to help future readers.
2019-11-11 08:36:38 -08:00
Julian Knutsen
5512f34566
[REFACTOR] P2PDataStorage::addPersistableNetworkPayload()
Add comments and refactor the body in order to make it easier to
understand.
2019-11-11 08:23:22 -08:00
Julian Knutsen
de5ffd43e3
[BUGFIX] Don't try and remove() if addMailboxData() fails
Fix a bug where remove() was called in the addMailboxData()
failure path.

1. Sender's can't remove mailbox entries. Only
   the receiver can remove it so even if the previous add() failed and
   left partial state, the remove() can never succeed.

2. Even if the sender could remove, this path used remove() instead
   of removeMailboxData() so it wouldn't have succeed anyway.

This patch cleans up the failure path as well as adds a precondition
for the remove() function to ensure future callers don't use them for
ProtectedMailboxStorageEntrys.
2019-11-11 08:18:52 -08:00
Julian Knutsen
e0c04ffcac
Merge branch 'master' into add-tests 2019-11-07 20:54:24 -08:00
Christoph Atteneder
585ccd3088 Update data stores and bitcoinj checkpoints (#3570) 2019-11-07 10:36:32 +01:00
Julian Knutsen
48d6ac4955
[PR COMMENTS] Use Client API in comments
Change the use of "public api" to "Client API" to describe the set of
callers that use the pattern addProtectedStorageEntry(getProtectedStorageEntry())
as a contrast to the onMessage handler users or the GetData users.
2019-11-06 09:17:32 -08:00
Julian Knutsen
52e4656e74
Merge branch 'master' into add-tests 2019-11-06 09:12:18 -08:00
chimp1984
b976bec492 Limit max. nr. of PersistableNetworkPayload and ProtectedStorageEntries (#3562)
* Limit max. nr. of PersistableNetworkPayload and ProtectedStorageEntry to 10000

To avoid that seed nodes get overloaded with requests for too many
PersistableNetworkPayload and ProtectedStorageEntry data we limit nr. of
entries to max 10000.

* Add peers node address to logs

* Improve logs

- Add log of size to GetBlocksResponse.toProtoNetworkEnvelope method
- Log in kb

* Log connection UID if not peer address available

* Add cleanup code or invalid objects

We have an invalid Filter object in the live network (prob. some dev
made some mistake). This code helps so clean that up.

* Add log
2019-11-05 20:50:38 +01:00
Julian Knutsen
6d983dec8d
[PR COMMENTS] Don't use the real Alert class
Instead, create a ProtectedStoragePayloadStub class which mocks out the required
protobuf Message for hashing. The hash is equal to the ownerPubKey so they are unique.
2019-11-05 08:08:28 -08:00
Julian Knutsen
80928663c0
[TESTS] Add tests for P2PDataStorage in order to safely refactor
These tests create real versions of the supported Payload & Entry types and
run them through the 3 entry points (onMessage, Init, standard add()/remove()/refresh(),
to verify the expected return values, internal state changes, and
external signals (listeners, broadcasts).

The tests are involved and I am proposing future work to make many of the objects
more testable that will greatly reduce the work and tests cases needed.

This work identified a few unexpected scenarios and potential bugs that are addressed
in dependent pull requests.

Code coverage when running P2PDataStorageTest:

Before:
Line: 4%
Branch: 0%

After:
Line: 78%
Branch 76%
2019-11-04 10:16:34 -08:00
Christoph Atteneder
b976570426
Release/v1.2.0 (#3532)
* New trade protocol (#3333)

* Remove arbitration key, cleanup

* Add BuyerAsMakerProcessDepositTxAndDelayedPayoutTxMessage

* Adopt trade protocol

- Add handler for DepositTxAndDelayedPayoutTxMessage
- Change handler for DepositTxPublishedMessage
- Add MakerSetsLockTime
- Rename MakerProcessPayDepositRequest to MakerProcessPayDepositRequest
- Rename MakerSendPublishDepositTxRequest to MakerSendsProvideInputsForDepositTxMessage
- Rename DepositTxPublishedMessage to DelayedPayoutTxSignatureRequest
- Rename MakerProcessDepositTxPublishedMessage to MakerAsBuyerProcessSignDelayedPayoutTxMessage

* Remove arbitratorKey

* Add new classes

* Add new message classes

* Add new task classes

* Renamed classed (no functional change yet)

* Add lockTime

* Add delayedPayoutTxSignature field

* Add useReimbursementModel field

* Add new classes

* Add setting.preferences.useReimbursementModel

* Apply renamed classes (new classes not added yet)

* Add useReimbursementModel

* Add preferences param

* Add new methods, cleanup

* Add daoFacade param, apply renaming

* Add delayedPayoutTx, lockTime and delayedPayoutTxId

- Support daoFacade param

* Remove DirectMessage interface

* Rename emergencySignAndPublishPayoutTx method, add new one for 2of2 MS

* Apply new protocol

* Apply new protocol

* Add renaming (no functional change yet)

* Add new messages, apply renaming

* Remove unneeded P2SHMultiSigOutputScript

* Remove PREFERRED_PROJECT_CODE_STYLE

* Refactor: Rename class

* Use InputsForDepositTxRequest instead of TradeMessage in handleTakeOfferRequest

* Do not sign deposit tx if maker is seller

We change behaviour that the maker as seller does not send the pre
signed deposit tx to the taker as the seller has more to lose and he
wants to control the creation process of the delayed payout tx.

* Apply new trade protocol to seller as maker version

* Apply new trade protocol

Delayed payout tx are now working for all scenarios but we use a small
hack to get around an issue with not receiving confirmations and the
peers tx.
We add a tiny output to both peers, so we see the tx and confirmation.
Without that only the publisher sees the tx and confirmations are not
displayed. Need further work to get that working without that extra
outputs.

* Set TRADE_PROTOCOL_VERSION to 2

* Add PeerPublishedDelayedPayoutTxMessage

We need add the delayed payout tx to the wallet once the peer publishes
it. We will not see the confidence as we do not receive or sent funds
from our address. Same is with dispute payouts where one peer does not
receive anything. Then the confidence is not set. It seems that is a
restriction in BitcoinJ or it requires some extra handling. We set the
confidence indicator invisible in the dispute case and that might be an
acceptable option here as well.

* Add refund agent domain

* Add refundAgentNodeAddress

* Apply refund domain

* Add refund views

* Apply refundAgent domain

* Support refundAgent

* Remove useReimbursementModel field

We dont need in the offer anymore the decision if reimbursement or
arbitration is chosen.

* Apply refundAgent payout

* Handle tx info and balances

* Remove mediation activation

* Add new tac accepted flag for v1.2.0 and adjust text

* Fix params for test classes

* Signed witness trading (#3334)

* Added basic UI for account signing for arbitrators

* Add domain layer for signed account age witnesses (credits ManfredKarrer and oscarguindzberg)

* Remove testing gridlines

* Arbitrator sign accountAgeWitnesses

Automatically filter to only sign accounts that
- have chargeback risk
- bought BTC
- was winner in dispute

* Handle chargebackrisk by currency

* Check winners only for closed disputes

* Show sign status of paymentaccounts in AccountsView

* Rename service to accountAgeWitnessService

* Refactor: Move account signing helpers to AccountAgeWitnessService

* Refactor: rename hasSignedWitness to myHasSignedWitness

* Show if witness is signed in offerbook view

* Use witness sign age for age comparison

* Refactor: rename to isTaker... to isMyTaker...

* Allow trading with signed witnesses

* Use witness age for showing account age icon

* Move AccountAgeRestrictions into AccountAgeWitnessService

* Handle trade limit of unverified accounts as normal case

* Avoid optional as argument

* Set trade limit depending on trade direction

* Avoid optional arguments

* Add text for seller as signer

* Seller with signer privilege signs buyer witness

* Fix merge issues

* Remove explicit check for risky offers

* Remove sellers explicit account age check

* Add limit check based on common accountAgeWitness function

* Fix arbitrator key event handling

* Filter accounts on tradelimit instead of maturity

* Fix test

* Buyer sign seller account

Add SIGNED_ACCOUNT_AGE_WITNESS capability

* Fix checks for signing at end of trade

Get correct valid accounts for offer

* Rename BuyerDataItem -> TraderDataItem

* Arbitrator sign both parties in a buyer payout dispute

* Only sign unsigned accountAgeWitnesses

* Remove unused code

* Add demo for material design icons

* Use different account age limits for sell/buy

* Fix signing interface for arbitrator

* Add signing state column to offer book

* Add signing state to fiat accounts overview

* Add signing state to selected fiat account

* Fix popover padding

* Add account signing state to peer info popup

* Retrieve only unsigned witnesses for arbitrator to sign

* Accounts signed by arbitrators are signers

* Disable test due to travis issues

* Improve witness handling (#3342)

* Fix comparison

* Add display strings for witness sign state

* Fix immaturity check

* Use accountAgeWitness age for non risky payment methods

* Show information about non risky account types

* Fix peer info icon account age text

* Complete new trade protocol (#3340)

* Improve handling of adding tx to wallet

* Add delayedPayoutTx to dispute

* Fix test

* Use RECIPIENT_BTC_ADDRESS from DAO for trade fee

* Set lockTime to 10 days for altcoins, 20 days others.

- Devmode uses 1 block

* Fix params

* Update text

* Update docs

* Update logging

if (log.isDebugEnabled()) only matches if logLevel is debug not
if it is INFO

* Remove log

* Remove arbitrator checks

* Remove arbitrator address

- It works not if not legacy arbitrator is registered.
We cannot remove too much from arbitration as we would risk to break
account signing and display of old arbitration cases.
Though if testing time permits we should try to clean out more of
arbitration domain what is not needed anymore.

* Use account signing state in accounts view (#3365)

* Add account signing icons to signing state in account display

* Remove unnecessary "." that caused layout issues in the past

* Add additional warning in the received payment popup for account signer

* Fix Revolut padding issues for currencies

* Hide signing icon for non-high-risk payment methods

* Add correct icon state and info text for account signing state

* Remove not implemented notification part

* Test self signing witnesses

* Change verified account limit factor to 0.5

* Account Signing: Add information popups for signing state (#3374)

* Add account signing icons to signing state in account display

* Remove not implemented notification part

* Hide time since signing column when not needed

* Remove fiat rounding popup as feature was introduced a long time ago already

* Add information popups for new signed states (only shown once for user) and minor clean-ups

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: sqrrm <sqrrm@users.noreply.github.com>

* Account Signing: Improve signed state notificaton (#3388)

* Remove new badge from Altcoin instant feature

* Remove new badge from percentage user deposit feature

* Fix line break issues in received payment confirmation popup

* Check if received payload fulfills signing state condition and not any personal witness

* Show additional badge for account sections to guide user to check out new signing states

* Fix account signing state in offer book (#3390)

* Account Signing: Fix verified usage (#3392)

* Rename witnessHash -> accountAgeWitnessHash

* Add enum for SignedWitness verification method

* Fix usage of isValidAccountAgeWitness

* Revert icon for signstate change

* Account signing: add signing state to payment account selection (#3403)

* Clean up dead code parts

* Add account signing state to payment account selection

* Account signing: revert dev date setting for trusted accounts (#3404)

* Revert temporary value for dev testing

* Only enable button if there are accounts to be signed

* Add trade limit exceptions (#3406)

* Remove dead code

* Add trade limit exception for accounts signed by arbitrator

* Update translations to adapt to new unified delay (#3409)

* NTP: Fix a couple of UI issues in the New Trade Protocol (#3410)

* Add badge support for refund agent (new arbitrator) tickets

* Fix translation typo

* Clean up arbitrator issues in translation

* Only show refund agent label to support staff

Every user should still see this role as arbitration

* NTP: Improve differentiation between mediation and new arbitration (#3414)

* Clean up property exposure

* Improve differentiation between mediation and arbitration cases

* Go to new refund view if it is no mediation and not open mediation notification if refund is already in progress

* Don't sign filtered accounts

* NTP: merge with master (#3420)

* Temporarily disable onion host for @KanoczTomas's BTC node

* Add Ergo (ERG) without Bouncy Castle dependency.

See #3195.

* List CTSCoin (CTSC)

* Tweak the English name of Japan Bank Transfer payment method

* Add mediator prefix to trade statistics

* List Faircoin (FAIR)

* List uPlexa (UPX)

* Remove not used private methods from BisqEnvironment

* Add onInitP2pNetwork and onInitWallet to BisqSetupListener

- Rename BisqSetupCompleteListener to BisqSetupListener
- Add onInitP2pNetwork and onInitWallet to BisqSetupListener
- make onInitP2pNetwork and onInitWallet default so no impl. required

* Start server at onInitWallet and add wallet password handler

- Add onInitWallet to HttpApiMain and start http server there
- Add onRequestWalletPassword to BisqSetupListener
- Override setupHandlers in HttpApiHeadlessApp and adjust
setRequestWalletPasswordHandler (impl. missing)
- Add onRequestWalletPassword to HttpApiMain

* Add combination (Blockstream.info + Mempool.space) block explorer

* Revert "Temporarily disable onion host for @KanoczTomas's BTC node"

This reverts commit d3335208bb.

* Temporarily disable KanoczTomas btcnode on both onion and clearnet

* Refactor BisqApp - update scene size calculation

* Refactor BisqApp - update error popup message build

* Refactor BisqApp - move icon load into ImageUtil

* Remove unused Utilities

* Increase minimum TX fee to 2 sats/vByte to fix #3106 (#3387)

* Fix mistakes in English source (#3386)

* Fix broken placeholders

* Replace non existing pending trades screen with open trades screen

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update message in failed trade popup

* Refactor BisqEnvironment

* Account Signing: Improve arbitrator signing flow (#3421)

* Pre-select a point of time 2 months in the past

So all arbitrator signed payment accounts will have their limits lifted completely

* Only show payment methods with high chargeback risk to be signed

* Show connected Bitcoin network peer info

* List Ndau (XND)

- Official project URL: https://ndau.io/
- Official block explorer URL: https://explorer.service.ndau.tech

* List Animecoin (ANI)

* Apply rule to not allow BSQ outputs after BTC output for regular txs (#3413)

* Apply rule to not allow BSQ outputs after BTC output for regular txs

* Enforce exactly 1 BSQ output for vote reveal tx

* Fix missing balance and button state update

* Refactor isBtcOutputOfBurnFeeTx method and add comments and TODOs

No functional change.

* Handle asset listing fee in custom method

We need to enforce a BSQ change output

As this is just tx creation code it has no consequences for the hard
fork.

* Use getPreparedBurnFeeTxForAssetListing

* Update comments to not use dust output values

* Fix missing balance and button state update

* Use same method for asset listing fee and proof of burn

Use same method for asset listing fee and proof of burn as tx structure
is same.
Update comments to be more general.

* Use getPreparedProofOfBurnTx

* Require mandatory BSQ change output for proposal fee tx.

We had in the doc stated that we require a mandatory BSQ change output
but it was not enforced in the implementation, causing similar issues
as in Asset listing and proof of  burn txs.

* Add fix for not correctly handled issuance tx

* Use new method for issuance tx

// For issuance txs we also require a BSQ change output before the issuance output gets added. There was a
    // minor bug with the old version that multiple inputs would have caused an exception in case there was no
    // change output (e.g. inputs of 21 and 6 BSQ for BSQ fee of 21 BSQ would have caused that only 1 input was used
    // and then caused an error as we enforced a change output. This new version handles such cases correctly.

* Handle all possible blind vote fee transactions

* Move check for invalid opReturn output up

* Add dust check at final sign method

* Fix incorrect comments

* Refactor

- Remove requireChangeOutput param which is always false
- Remove method which is used only by one caller
- Cleanup

* Add comment

* Fix comments, rename methods

* Move code of isBlindVoteBurnedFeeOutput to isBtcOutputOfBurnFeeTx

* Update account signing strings for v1.2 release (#3435)

* Update account signing strings for v1.2 release

* Add minor corrections from ripcurlx review

* Adjust tradeLimitDueAccountAgeRestriction string

So that it describes why an account isn't signed (in general) instead of
why it wasn't signed by an arbitrator.

* Account Signing/NTP: More improvements and fixes (#3436)

* Select the the correct sub view when a dispute is created

* Require capability REFUND_AGENT to receive RefundAgent Messages

* Remove unused return type for account signing

* Add new feature popup for account signing and new trade protocol

* Return void from account signing

* Fix bug with not updating vote result table at vote result block

* NTP: improve backwards compatibility for mediation (#3439)

* Improve readability of offer update

* Add type safeguard for dispute lists

* Set not existing dispute support type for clients < 1.2.0 from message support type

* Enable handling of mediation cases for old trade protocol disputes in 1.2.0 clients

* Remove unnecessary forEach

* Use correct formatter and add missing value for placeholder

* Bump version number

* Add sign all checkbox. Fix list entry display (#3450)

* Add sign all checkbox. Fix list entry display

* Add summary to log and clipboard

* Use safe version for seednodes (#3452)

* Apply shutdown and memory check again

To not risk issues with the release and seed nodes we merge back the
old code base for handling memory check and shutdowns.
The newly added changes for cross connecting between seed nodes cause
out of memory issues and require more work and testing before it can be
used.

* Revert code change for periodic updates between seed nodes.

The periodic updates code caused out of memory issues and require more
work and testing before it can be used.

* Arbitrator republish signedWitnesses on startup (#3448)

* Arbitrator republish signedWitnesses on startup

* Keep republish internal to SignedWitnessService

* Improve new feature popup for ntp and account signing (#3453)

* Do not commit delayedPayoutTx to avoid publishing at restart

Fixes https://github.com/bisq-network/bisq/issues/3463

BitcoinJ publishes automatically committed transactions.
We committed it to the wallet to be able to access it later after a
restart. We stored the txId in Trade and used that to request the tx
from the wallet (as it was committed). Now we store the
bitcoin serialized bytes of the tx and do not commit the tx before
broadcasting it (if a trader opens refund agent ticket).

* [1.2.0] Update client resources (#3456)

* Update bitcoinj checkpoint file

* Update data stores

* Update translations

* [1.2.0] Improve new feature popup (#3465)

* Improve layout of new feature popup

* Extract external hyperlinks into component to make it easier to update

* Comment in necessary showAgain check

* Add Raspberry Pi to build process (#3466)

* Add Raspberry Pi to build process

* Rename deploy variable to improve readability

* Update informational prompt upon creating fiat account with account signing details (#3467)

* Update informational prompt upon creating fiat account with account signing details

* Fix wrong buyer limit for first 30 days

* Set delayedPayoutTxBytes when setting delayedPayoutTx

Fixes https://github.com/bisq-network/bisq/issues/3473

The delayedPayoutTx is not committed to the wallet as long it is not
published. The seller who creates the delayedPayoutTx has not stored the
delayedPayoutTxBytes which caused a nullpointer after restart.

* Minor updates (#3474)

* Remove unnecessary log statement

This seems to be a left over log statement from debugging.

* Use a small delay for MakerSetsLockTime on regtest

When testing on regtest, not in devmode, we want a relatively short
delay to be able to test the delay period.

* Clarify payment limits up to 30 days after signing

* Update RECIPIENT_BTC_ADDRESS for regtest (#3478)

Use an address that is owned by the regtest wallet in the dao-setup.zip
file. This allows for easily verifying BTC trading fees are sent to
this address correctly. Also, it helps verify spending of the time lock
payout.

* Remove btc nodes from Manfred Karrer (#3480)

* Avoid null objects (#3481)

* Avoid null objects

* Remove check for type

Historical data can be arbitration instead of mediation (arbitration
was fallback at last update), so we need to tolerate the incorrect type
here. Is only for tickets from pre 1.2.

* Display appropriate account age info header

Depending on charge back risk type, accounts should show
accountAgeWitness age or time since signing

* Set amount for delayed payout tx to 0 (#3471)

We have shown the spent funds from the deposit tx to the bisq donation
address before. But that was incorrect from the wallet perspective and
would have lead to incorrect summary of all transaction amounts. We set
it now to 0 as we are not spending funds nor receiving any in our wallet.

* Check for result phase at activate method

Fixes https://github.com/bisq-network/bisq/issues/3487

* Only show warning for risky payment menthods (#3497)

* Fix style issues with dark mode (#3495)

* Addresses issues mentioned in https://github.com/bisq-network/bisq/issues/3482#issuecomment-546812730 (#3496)

* Clean up trade statistics from duplicate entries (#3476)

* Clean up trade statistics from duplicate entries

At software updates we added new entries to the extraMap which caused
duplicate entries (if one if the traders was on the new and the other on
the old version or at republishing). We set it now json exclude so avoid
that in future and clean up the map.

* Avoid repeated calls to addPersistableNetworkPayloadFromInitialRequest

For trade stat cleanup we don't want to apply it multiple times as it
is a bit expensive. We get from each seed node the initial data response
and would pollute with the second response our map again and if our node
is a seed node, the seed node itself could not get into a clean state and
would continue pollution other nodes.

* Refactor

Remove not used param
Rename method
Inline method
Cleanups

* Change unsigned to N/A

* [1.2.0] Update data stores and adding SignedWitnessStore (#3494)

* Update data stores and adding SignedWitnessStore

* Update translations

* Update cleaned TradeStatistics2Store and changes in other stores

* VoteResultView update results on any block in result phase

Avoid updating the result more than once per result phase but make
sure it's done if activated during the result phase

* [1.2.0] Format maker fee for BTC and BSQ correctly (#3498)

* Format maker fee for BTC and BSQ correctly

* Update tests

* Only automatically open popup if result wasn't accepted and disable action button when being accepted (#3503)

* Fix tradestatistics (#3469)

* Remove delayed re-publishing of tradeStatistics

This was done earlier when only maker was publishing trade statistics.
Now both traders do it so we get already higher resilience.

* Remove unused method

Forgot in prev. commit to remove also the method.

* Remove support for TradeStatistics2.ARBITRATOR_ADDRESS

* Add comment and set ARBITRATOR_ADDRESS deprecated

* Remove setting of arbitrator data from makers side

The 2 arbitrator related fields in Trade are only set by the maker and
not used anymore for reading, so it can be removed. The whole arbitrator
domain should be cleaned out some day, but because of backward
compatibility issues it id difficult to do it entirely at release date.
With release after v 1.2. when no old offers are out anymore we are
able to clean up that domain.

* Remove dev log

* Update translations

* [1.2.0] Improve dispute section (#3504)

* Improve wording for mediation summary and add specific next steps for refund agent case

* Select the first dispute case when entering the support section

* Revert to SNAPSHOT version

* Fix but with initialRequestApplied (#3512)

* Fix resource name (#3514)

* Remove minor version number in news popup

* Fix copy SignedWitnessStore db script

* Not show payment account details for blocked offers

* Use age of accountAgeWitness as basis for sell limits

* Bump version number

* Revert to SNAPSHOT version

* Merge v1.2.0/v1.2.1 with master (#3521)

* List Krypton (ZOD)

* Temporarily disable onion host for @KanoczTomas's BTC node

* Add Ergo (ERG) without Bouncy Castle dependency.

See #3195.

* List CTSCoin (CTSC)

* Tweak the English name of Japan Bank Transfer payment method

* List Animecoin (ANI)

* Add mediator prefix to trade statistics

* List Faircoin (FAIR)

* List uPlexa (UPX)

* Remove not used private methods from BisqEnvironment

* Add onInitP2pNetwork and onInitWallet to BisqSetupListener

- Rename BisqSetupCompleteListener to BisqSetupListener
- Add onInitP2pNetwork and onInitWallet to BisqSetupListener
- make onInitP2pNetwork and onInitWallet default so no impl. required

* Start server at onInitWallet and add wallet password handler

- Add onInitWallet to HttpApiMain and start http server there
- Add onRequestWalletPassword to BisqSetupListener
- Override setupHandlers in HttpApiHeadlessApp and adjust
setRequestWalletPasswordHandler (impl. missing)
- Add onRequestWalletPassword to HttpApiMain

* Add combination (Blockstream.info + Mempool.space) block explorer

* Revert "Temporarily disable onion host for @KanoczTomas's BTC node"

This reverts commit d3335208bb.

* Temporarily disable KanoczTomas btcnode on both onion and clearnet

* Refactor BisqApp - update scene size calculation

* Refactor BisqApp - update error popup message build

* Refactor BisqApp - move icon load into ImageUtil

* Remove unused Utilities

* Increase minimum TX fee to 2 sats/vByte to fix #3106 (#3387)

* Fix mistakes in English source (#3386)

* Fix broken placeholders

* Replace non existing pending trades screen with open trades screen

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update message in failed trade popup

* Refactor BisqEnvironment

* List Ndau (XND)

- Official project URL: https://ndau.io/
- Official block explorer URL: https://explorer.service.ndau.tech

* Show connected Bitcoin network peer info

* Not show payment account details for blocked offers (#3425)

* Add GitHub issue template for user reported bugs (#3454)

* Add issue template with steps to reproduce and actual/expected behavior

* Fix typo in .github/ISSUE_TEMPLATE.md

* Fix wrong auto merge

* Add CapabilityRequiringPayload to TradeStatistics2

With v1.2.0 we changed the way how the hash is created.
To not create too heavy load for seed nodes from
requests from old nodes we use the SIGNED_ACCOUNT_AGE_WITNESS
capability to send trade statistics only to new nodes.
As trade statistics are only used for informational purpose it will
not have any critical issue for the old nodes beside that they don't see the latest trades.

* Fix tradestat hash issue (#3529)

* Recreate hash from protobuf data

To ensure all data are using the new hash method (excluding extraMap) we
do not use the hash field from the protobug data but pass null which
causes to create the hash new based on the new hash method.

* Add filter.toString method and log filter in case of wrong signature

We have atm a invalid filter (prob. some dev polluted a test filter to mainnet)

* Change log level, add log

* Refactor: Move code to dump method

* Add TRADE_STATISTICS_HASH_UPDATE capability

We changed the hash method in 1.2.0 and that requires update to 1.2.2
for handling it correctly, otherwise the seed nodes have to process too
much data.

* Add logs for size of data exchange messages

* Add more data in log

* Improve logs

* Fix wrong msg in log, cahnge log level

* Add check for depositTxId not empty

* Remove check for duplicates

As we recreate the hash for all trade stat objects we don't need that
check anymore.

* Add logs

* Temporarily remove this part of the statistics

It prevents merging with master because through auto merge a duplication of this part of the code is happening and prevents Travis from succeeding
2019-10-31 12:49:26 +01:00
Florian Reimair
3303b90e48 periodical UpdateDataReq for Seednodes (#3202)
* Refactored logging into subroutine

* Only do recurring updatedatareq if seednode

* UpdateDataReq is run periodically

* Only store PeristablePayloads once
2019-09-26 13:42:26 +02:00
Christoph Atteneder
7f88bbf30b
Update data directories 2019-09-23 09:30:41 +02:00
Christoph Atteneder
cc3128d4e0
Merge branch 'master' of github.com:bisq-network/bisq into release/v1.1.6
# Conflicts:
#	core/src/main/java/bisq/core/offer/OfferUtil.java
#	core/src/main/resources/i18n/displayStrings.properties
#	desktop/src/main/java/bisq/desktop/main/MainView.java
#	desktop/src/main/java/bisq/desktop/main/MainViewModel.java
#	desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java
#	desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java
#	desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java
#	desktop/src/main/java/bisq/desktop/main/overlays/windows/OfferDetailsWindow.java
#	desktop/src/main/java/bisq/desktop/main/portfolio/openoffer/OpenOffersViewModel.java
#	desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesView.java
#	desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java
#	desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java
2019-09-17 15:52:51 +02:00
Christoph Atteneder
f28d262a8a
Update data stores 2019-09-13 14:45:10 +02:00
chimp1984
d55114e019 Add mediation support (#3221)
* Refactoring: Move arbitration package inside dispute package

* Use abstract base class DisputeResolver for arbitrator

* Refactoring: Move mediator to mediator package.

* Let Mediator inherit DisputeResolver.

* Do not use protobuf inheritance

- Do not use protobuf inheritance for Arbitrator and Mediator as it
would break backward compatibility (and protobuf inheritance sucks
anyway)

* Refactoring: Move ArbitratorModule to parent package

* Refactoring: Rename ArbitratorModule to DisputeModule

* Add mediators to Filter

* Add mediators to filter window

* Use abstract DisputeResolverService as base class for ArbitratorService

- Add common base class for ArbitratorService and MediatorService

* Fix test

* Use abstract DisputeResolverManager as base class for ArbitratorManager

- Add common base class for ArbitratorManager and MediatorManager

* Refactor: Move arbitratorregistration package inside register pkg

* Refactor: Rename arbitratorregistration package to arbitrator

* Add registration view for mediator

- With cmd+D one can open the mediator regisration in account screen.
For arbitrator its cmd+R

* Separate pub key list for mediator (no new keys added yet)

* Set new pubkeys for mediator registration

- Before release set new keys from maintainer who manages keys

* Set disputes @Nullable. Add null checks

* Remove pre v0.9 handling for supported arbitrators from offer

- We changed handling of arbitrator selection with v0.9 so the
supported arbitrators in the offer is not used anymore. As we
enforced v1.2 a while back for trading we can be sure no pre v0.9
clients are used anymore and we can remove the optional code part.

* Remove supported arbitrators info in offer details window

- As we do not use supported arbitraors in offer anymore since v0.9
we can remove that.

* Remove check for matching arbitrator languages

As we do not use the supported arbitratos from offer since v0.9 we can
remove that check.

* Remove not used classes

* Remove checks for arbitrator and mediator in offer

We do not use those fields anymore. We still need to keep the fields
not nullable as old clients have the check still.

* Add check if sig of proto object is not empty

We got in dev testing sometimes an empty protobuf Alert. Might be
caused from protobuf copatibility issues during development but not
100% clear.
As it causes an exception and corrupted user db file we prefer to set
it to null.

* Remove TakerSelectMediator

This is not used anymore. Currently we would get an exception in the
trade but with follow up changes we will fix that...

Mediator handling and selection will be done the same way like
arbitrator. The current mediator handling was a relict from earlier
partial support for mediators which never got completed. As still a
null check is in place we need to ensure backward compatibility.

* Set arbitratorNodeAddresses and mediatorNodeAddresses to deprecated

We do not use arbitratorNodeAddresses and mediatorNodeAddresses anymore
but as there is a null check we still need to keep the field ans set it
to an empty arrayList.

* Make ArbitratorSelection generic. Add MEDIATOR_ADDRESS

We want to use the same selection algorithm for mediators as for
arbitrators, so we make ArbitratorSelection generic.
We add MEDIATOR_ADDRESS as extraMap entry to TradeStatistics2 to be
able to track number of trades with specific mediators.

ExtraMap is used to add new data to existing protobuf definitions which
is supported also by not updated clients. Adding a new protobuf field
would only be supported by new clients. As mediator support is a new
feature we could add a new field but to keep it in the same style like
arbitrator we prefer to use the map here as well.

* Refactor: Rename ArbitratorSelection to DisputeResolverSelection

* Add mediator to OfferAvailabilityResponse and mediatorNodeAddress to OpenOffer

WIP for supporting mediator selection the same way like arbitrators.

* Make arbitrator not nullable

We can ensure that all users are post v0.9 so we can remove the nullable
 support.

* Add selectedMediator to OfferAvailabilityModel

Remove nullable support in ProcessOfferAvailabilityResponse as we can
ensure all clients are post v0.9

* Refactor: Rename method

* Add todo for using more generic keys for display strings

* Refactor: Rename method

* Fix wrong handling of registeredMediator

Fix copy/paste error

* Add mediatorNodeAddress to trade

* Handle nullable mediator in ProcessOfferAvailabilityResponse

We do not get the mediator set from old clients but we expect a not null
value so we use the DisputeResolverSelection in case it is null.
We need to pass mediatorManager and tradeStatisticsManager to the
OfferAvailabilityModel.

* Change log level, cleanup

* Revert changes in OfferPayload due backward compatibility issues

Because of backward compatibility issues we needed to revert the removal
of arbitratorNodeAddresses and mediatorNodeAddresses. The signature
check for the offer  would fail as an old client would send a not-empty
list but new clients would have had an empty list, so the hash
would be different and the sig check fail and we would not accept that
offer. That is the reason why we still need to support those data even
it is not used anymore.

This is one of the more tricky cases for backward compatibility issues.

This version now is tested between new and old clients and trade and
disputes work.

* Add checks if any mediator is available

* Cleanup classes

* Fix test

* Add mediator DisputeStates

Add isMediationDispute to Dispute class.

If a dispute opening gets requested we check if state is
DisputeState.NO_DISPUTE and the open mediation. If state is
DisputeState.MEDIATION_REQUESTED we open arbitration.

* Cleanup; support isMediationDispute

* Handle mediator data in Dispute domain

- Add getConflictResolverNodeAddress method to Dispute to resolve
arbitrator or mediator address based on isMediationDispute flag.

- Rename arbitratorPubKeyRing to conflictResolverPubKeyRing in Dispute.
We cannot rename arbitratorPubKeyRing in the protobuf definition
as it would break backward compatibility.

* Add support for mediation in dispute domain

- Add isMediationDispute method to ChatSession
- Add isMediationDispute method to DisputeCommunicationMessage
- Add isMediationDispute to dispute id
- Refactor findDispute method
- Add null checks
- Cleanups

* Remove impossible case

Reserved and locked funds are used for offers and trades only.

* Fix typos

* Handle mediator and arbitrator strings

- Work in progress of adjusting correct terms.
- Cleanups

* Refactor: Rename arbitrator package to disputeresolvers

* Refactor: Rename ArbitratorDisputeView classes to DisputeResolverView

* Add support for close ticket from mediator (WIP)

In mediator case we do not create any transaction but only send the
dispute result which contains the mediators recommended payout
distribution. At teh traders we set the disputeState in the trade to
closed. This will be used in the next commits to update the trade so
that the traders get displayed the recommended payout and get asked if
they agree to that.

* Refactoring: Rename class

Rename MessageDeliveryFailedException to
DisputeMessageDeliveryFailedException

* Refactoring: Move dispute classes to dispute package

* Refactoring: Move Attachment class to dispute package

* Refactoring: Move package one level up

Move bisq.core.dispute.arbitration.messages to
bisq.core.dispute.messages

* Add todo comment

* Use ARBITRATION instead of DISPUTE

* Make DisputeManager abstract base class for ArbitrationDisputeManager

WIP for separating DisputeManager to ArbitrationDisputeManager and
MediationDisputeManager

* Add MediationDisputeManager

* Add MediationDisputeManager and ArbitrationDisputeManager to test

* Add mediationDisputeManager to relevant classes

There are some cases where arbitrationDisputeManager only is used.
Those are usually related to the payout tx. As mediators do not do a
payout we don't need it there.

* Add TradersArbitrationDisputeView and TradersMediationDisputeView

WIP for separating TraderDisputeView

* Refactor:  Rename class

* Refactor: Rename support.tab.support to support.tab.mediation.support

I am aware that committing non default translation files is not
recommended, but I think in that case it helps to avoid to show errors
for developers who use non-english locale. The changes will be
overwritten by transifex once it gets synced...

* Add DisputeView as common base class

Further refactor separation of diff. dispute views

* Refactor: Rename package

* Refactor: Rename DisputesView to SupportView

* Refactor: Rename package

* Add MediationDisputeManager to CorePersistedDataHost

* Add MediationDisputeList as db file, refactor DisputeList

WIP for making Dispute domain more generic. We want to separate
arbitration and mediation clearly.

* Further refactoring to split mediation and arbitration

* Further refactoring to split mediation and arbitration

Move methods used for arbitration only to ArbitrationDisputeManager

* Refactor: Rename package

Rename bisq.core.dispute to bisq.core.support

No other changes in that commit.
We want to improve the data structure with the trader chat.
Support will be the top level.
Then dispute containing arbitration and mediation.
Next to dispute will be trader chat.

bisq.core.support
bisq.core.support.dispute.arbitration
bisq.core.support.dispute.mediation
bisq.core.support.traderchat  (not happy with name for that yet)

* Refactor: Move dispute domain classes into isq.core.support.dispute package

* Refactor: Move classes

Move bisq.core.chat.ChatSession to bisq.core.support.ChatSession
Move bisq.core.chat.ChatManager to bisq.core.support.ChatManager
Move bisq.core.trade.TradeChatSession to bisq.core.support.traderchat.TradeChatSession

* Refactor: Move DisputeCommunicationMessage

* Refactor: Rename DisputeCommunicationMessage to ChatMessage

* Add comments

* Refactor: Move class

* Refactor: Rename class

* Refactor: Rename addDisputeCommunicationMessage and strings and variables

Rename disputeCommunicationMessage to chatMessage

* Refactor: Rename method

* Refactor: Rename methods and strings

* Add ArbitrationChatMessage and DisputeChatMessage

* Refactor: Rename class

* Move ChatMessage.Type to SupportType

Add to all supportMessages the SupportType so that we can filter in our
chatSessions the messages we are interested in.

* Refactor: Move classed to new package

* Refactor: Rename package

* Refactor: Move classed to new package

* Refactor: Move classed to new package

* Refactor: Rename classes

* Refactor: Rename package

* Refactor: Rename classes

* Refactor: Rename classes

* Remove empty DisputeModule

* Refactor: Rename classes

* Refactor SupportManager domain (WIP)

* Refactor SupportSession domain (WIP)

* Remove methods from SupportSession

* Dont expose p2pService in SupportManager

* Remove supportType in SupportSession

* Remove supportSession from getPeerNodeAddress method

* Remove isBuyer from supportSession

* Move creation of ChatMessage to SupportManager

* Remove isMediationDispute fielf in ChatMessage

* Remove chatMessage.isMediationDispute()

* Refactor: Rename trade.getCommunicationMessages()

* Move creation of ChatMessage to Chat

* Refactor: Rename class

* Refactor: Move ChatView class

* Refactor: Move PriceFeedComboBoxItem class to shared package

* Refactor: Use 'public abstract' instead of 'abstract public'

* Refactor: Use 'protected abstract' instead of 'abstract protected'

* Add traderChatManager.onAllServicesInitialized() to BisqSetup

* Remove unused param

* Refactor: Rename addChatMessage to addAndPersistChatMessage

* Fix missing check at ack msg handling

Various WIP refactorings/improvements

* Remove addAndPersistChatMessage from SupportSession

* Remove disputeManager from DisputeSession

* Fix missing getConcreteDisputeChatSession impl.

* Refactor: Rename package

* Refactor: Rename classes

Avoid trader as it might confuse with trader chat.
As for mediation/arbitration the agent (mediator/arbitrator) are acting
a bit like a server we use the client terminology for the traders.

* Refactor: Move classes to new package

* Fix missing protobuf data

- Add missing SupportType to protobuf
- Remove is_mediation_dispute from Dispute protobuf
 definition
- Add getAgentNodeAddress method
- Var. other refactorings, cleanups

* Clone list at persisting to avoid ConcurrentModificationException

* Fix order of SupportType

Old clients fall back to enum at slot 0.

* Add getDisputeState_StartedByPeer template method

* Add trade protocol tasks for mediation result tx signing and msg sending

* Complete protocol tasks for mediation

* Refactor: Remove unneeded SuppressWarnings type: "WeakerAccess"

* Complete mediation result protocol

Works now all but not much tested....

* Add activation date and capability

We need to make sure that not updated users cannot cause problems once mediation is supported. We would get mixed cases where one has a mediation ticket and the not updated user an arbitration ticket. To avoid that we set an activation date with about 10 days from release. Until that date mediation is not supported.
Additionally we use OfferRestrictions.REQUIRE_UPDATE_DATE for hiding offers from users how have not updated (we use the fact that mediator and arbitrator has been same in old version, in new version they are different).
An old client cannot take an offer from a new maker as he does not has set the new MEDIATION capability. He will get an null value as AvailabilityResult as he has not the new entry MISSING_MANDATORY_CAPABILITY.
We will also use the min version for trading in the filter, so that not updated users get a popup telling them to update and they see all offers deactivated.

* Various fixes

* Remove code part which does not make sense (anymore)

Maybe in older versions there was use of openDisputes and closedDisputes
but now it does not make sense anymore and arbitrator never gets 4 cases
opened if offline.

* Add check of balance is > 0

* Only close trade if payout tx is set

* Add missing check if arbitrator and mediator are available

* Fix wrong key

* Improve handling of checks and popup display

For create and take offer we check certain conditions and show a
popup if not met. This commit moves that to GuiUtils.

* Rename any occurrance of DisputeResolver to DisputeAgent

* Fix handling of mediatorPubKeyRing

* Remove disputeSummaryWindow.evidence fields

* Add missing persistence for MediationResultState

* Fix tests

* Make text more compact to not exceed space

* Refactor NotificationGroup

* Improve text, add dev testing feature for popups

* Improve text

* Renamed a key and assigned a new text

* Fix states

* Do not set errorMessage

Do not set errorMessage if both peers have opened a dispute and agent
was not online

* Remove logs used for dev testing

* Fix getMedian method with empty list

* Add new methods and tests

Add fromCommaSeparatedOrdinals and toCommaSeparatedOrdinals to convert
from string representations (used for handling backward compatibility
with mediation release).

Add check if int >= 0 to fromIntList

* Move error log outside of delayed call

* Add capabilities entry to extraDataMap in offer

The previous implementation did not work for supporting updates and
hiding offers from not updated clients.
We use now the capabilities converted to a string list and put it into
the extraDataMap. If a use with old persisted offers updates his offers
gets converted to add the capabilities. Updated clients will ignore
offers without the mediation capability set in the offer.

* Rename non sync protobuf definitions

As Christoph Sturm pointed out we can rename protobuf entries.
Only index number must not be changed.

* Fix UI state when arbitration has started

Only set mediation state if we are not in arbitration state.

* Remove restriction

* Fix typo; remove errorMessage

If both have opened a dispute and agent was not online we dont treat it
as error.

* Improve text

* Store full address for localhost dev testing

The arbitrator/mediator selection is based on statistics of usage of
agents in past trades. We put the first 4 chars into the trade
statistics, but for localhost that would be same vale for 2 diff nodes.

* Remove errorMessage

If both have opened a dispute and agent was not online we dont treat it
as error.

* Improve text

* Keep accept or reject button enabled after accept

- If peer never accepts the trader who has accepted first can change
to reject to open a arbitration dispute.
We could improve that by adding a new state to open arbitration
directly and show a diff. button text and popup. But I think for now
thats ok as well....

* Cleanups (no functional change)

- remove unused params
- remove not used code
- reformat
- clean up comments
- fix log levels
- remove redundant annotations

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: Steve Jain <mfiver@gmail.com>

* Improve text

* Auto fill remaining amount in custom payout

If mediator or arbitrator are doing a custom payout, we auto-fill
counterpart field with remaining amount, so he does not need to
calculate.
2019-09-09 20:51:57 +02:00
chimp1984
fee097dadf
Add CapabilityRequiringPayload interface to BundleOfEnvelopes 2019-09-07 13:18:36 +02:00
Christoph Atteneder
5fbe2e3d0a
Fix broken build because of removed Hex util in release branch 2019-09-06 17:27:31 +02:00
Christoph Sturm
4d49697a28
Only build string when its actually output 2019-09-06 17:12:12 +02:00
Christoph Sturm
1c8f869ed6 Only build string when its actually output 2019-09-06 16:20:53 +02:00
Christoph Atteneder
211eb1b4f1
Merge pull request #3213 from christophsturm/cleanup-thread-handling
Simplify thread handling and ensure proper they all have names
2019-09-06 16:15:15 +02:00
Christoph Sturm
372ff50b8b
Implement reviewer suggestions also in NetworkNode 2019-09-06 14:51:48 +02:00
Christoph Sturm
3666ed2911
Don't build debug strings when debug is not enabled. 2019-09-06 14:51:35 +02:00
Christoph Sturm
e5e49dc5bd
Don't build debug strings when debug is not enabled. 2019-09-06 14:51:24 +02:00
Christoph Sturm
84f3ef818d More debug logging optimizing 2019-09-06 12:25:30 +02:00
Christoph Sturm
ecaf592a60 Implement reviewer suggestions also in NetworkNode 2019-09-06 12:00:13 +02:00
chimp1984
93e6d86e95
Remove CapabilityRequiringPayload from AckMessage
We do not have any old versions anymore which might not support
AckMessages, so we can remove it. It might also fix issues that
AckMessages are not sent as the capabilities are not known yet.
2019-09-06 11:33:34 +02:00
Christoph Sturm
a3bf6ab4cb Don't build debug strings when debug is not enabled. 2019-09-06 11:24:35 +02:00
Christoph Sturm
7173bb71b5 Don't build debug strings when debug is not enabled. 2019-09-06 11:14:19 +02:00
Christoph Sturm
4223036f47 name connection thread 2019-09-06 11:07:34 +02:00
Christoph Sturm
bcaac51830 Assign more thread names at thread creation. 2019-09-06 11:07:34 +02:00
Christoph Atteneder
285e5f236d
Merge pull request #3189 from gordonel/patch-1
Change trader-facing language to gender-neutral
2019-09-04 10:33:23 +02:00
battleofwizards
7719851658
Replace bouncycastle Hex with guava Hex
Hex encoding and decoding compatibility has been verified regarding
null, "", character case handling, and incorrect digits handling.
2019-09-03 13:54:32 +02:00
Gordon E
a25aeef9e7
Update GetDataRequestHandler.java 2019-09-03 12:16:15 +03:00
Gordon E
73d097566b
gender-neutral language change in P2PService.java 2019-09-03 12:06:51 +03:00
Christoph Atteneder
e2a17dcb8e
Update data stores 2019-09-02 11:14:59 +02:00
chimp1984
9db4d69276
Improve RequestDataHandler
- Remove processDelayedItems list as we do not delay anymore the data
items and protectedStoragePayloads do not get an extra treatment if
they are marked as LazyProcessedPayload.
- Add duration logging
- Replace checkArgument with an if check
- Apply code inspection
- Cleanup
2019-09-01 23:03:29 +02:00
chimp1984
40de3c528d
Improve logging
- Add better logs and duration measurements for expensive operations
- Convert debug logs to trace to avoid flooding the output in debug log
mode.
- Cleanups
2019-09-01 22:57:40 +02:00
chimp1984
adac3bd7e5
Do check after supportedCapabilities are applied 2019-08-29 18:21:38 +02:00
chimp1984
d7845d0eb1
Move check for empty capability.
- Move check for empty capability to connection class.
- Add MANDATORY_CAPABILITIES_NOT_SUPPORTED
- Add comment that capabilities can be empty
2019-08-29 18:15:17 +02:00
chimp1984
55092edb6c
Disconnect nodes which do not have the mandatory capability 2019-08-28 21:06:17 +02:00
chimp1984
ab4aa64424
Smal performance optimisations, cleanups 2019-08-28 20:51:01 +02:00
chimp1984
bb628dc851
Avoid that removed mailbox messages get added again 2019-08-28 20:31:06 +02:00
chimp1984
a0e690997a
Merge branch 'master_upstream' into Fix-small-P2P-network-issues
# Conflicts:
#	core/src/main/java/bisq/core/setup/CoreNetworkCapabilities.java
2019-08-28 19:49:18 +02:00
chimp1984
ca0a42ba42
Use node address for thread name; cleanup 2019-08-28 01:21:43 +02:00
chimp1984
72e291cf9c
Call supportedCapabilitiesListener on Userthread 2019-08-28 01:21:16 +02:00
chimp1984
f95a7f5d3f
Add missing listener notification and clean up class 2019-08-27 22:03:23 +02:00
wiz
f3f04ddad9
Update data storage on expired data removal 2019-08-28 01:55:52 +09:00
wiz
f5d75c4f60
Improve TempProposal processing (fixes #3143) 2019-08-27 22:36:37 +09:00
Florian Reimair
0731579a35
Merge pull request #3115 from christophsturm/only-add-kotlin
Apply kotlin plugin and convert one unused class to kotlin
2019-08-21 12:40:00 +02:00
sqrrm
f2f62c7033
Merge pull request #3112 from freimair/optimizations
Various optimizations
2019-08-20 22:08:19 +02:00
Christoph Sturm
26c053dae8 Apply kotlin plugin and convert one unused class to kotlin
just to check that everything works and to show how much simpler
kotlin code looks.
2019-08-20 16:07:07 +02:00
Florian Reimair
01e91cc35c
Adjust log levels of P2P connection class 2019-08-20 12:08:02 +02:00
Florian Reimair
53362868e0
Optimize initial tradestats processing 2019-08-20 11:14:43 +02:00
Florian Reimair
a56fc947e5
Use same seednodes for updatedDataReq 2019-08-20 11:06:40 +02:00
Christoph Sturm
2ccecd2738 fix formatting 2019-08-19 18:26:39 +02:00
Christoph Sturm
79b3e5baf3 inject storage where possible 2019-08-19 17:21:35 +02:00
Christoph Sturm
b543c7f148 remove unused test method 2019-08-19 17:08:20 +02:00
Christoph Sturm
b77cff9e26 inject CorruptedDataFilesHandler instead of making it static 2019-08-19 16:54:46 +02:00
Christoph Sturm
2383d7ea50 restore the test that was lost in a rebase of my test branch 2019-08-19 16:35:18 +02:00
Christoph Sturm
8a93edec65 comment out obsolete test 2019-08-14 17:58:04 +02:00
Christoph Sturm
d62d440068 start testing p2p data storage 2019-08-14 17:58:04 +02:00
Christoph Sturm
0babe82d09 remove jmockit 2019-08-13 19:47:40 +02:00
sqrrm
62cfaf09c3
Update resources 2019-08-07 23:08:21 +02:00
sqrrm
47c7910e88
Move Clock binding to P2PModule 2019-08-01 11:43:43 +02:00
sqrrm
360dc0b4e8
Merge pull request #3037 from christophsturm/inject-clock
inject clock for usage in isDateInTolerance
2019-07-30 16:12:48 +02:00
Christoph Sturm
c38ef06d04 inject clock for usage in isDateInTolerance 2019-07-30 15:27:32 +02:00
Christoph Sturm
2f26140b6d fix warnings 2019-07-30 13:07:12 +02:00
Christoph Atteneder
db25293d62
Merge branch 'master' of github.com:bisq-network/bisq into hotfix-for-v1.1.3
# Conflicts:
#	build.gradle
#	desktop/package/linux/Dockerfile
#	desktop/package/linux/package.sh
#	desktop/package/linux/release.sh
#	desktop/package/macosx/create_app.sh
#	desktop/package/macosx/finalize.sh
#	desktop/package/macosx/insert_snapshot_version.sh
#	desktop/package/windows/package.bat
#	desktop/package/windows/release.bat
#	relay/src/main/resources/version.txt
2019-07-29 19:00:37 +02:00
sqrrm
2570e9b728
Merge pull request #2999 from christophsturm/christoph/rename-clock
rename Clock to ClockWatcher
2019-07-29 14:39:22 +02:00
sqrrm
70b7660e6c
Merge pull request #3005 from christophsturm/christoph/split-pb
split the pb.java file into multiple files
2019-07-26 16:14:57 +02:00
Christoph Atteneder
4c8a0ea00b
Update data stores 2019-07-26 10:35:48 +02:00
Christoph Sturm
de4e1d7b58 move protobuf to proto package 2019-07-25 14:08:00 +02:00
Christoph Sturm
1c0fe2673f split pb.java file into separate files. 2019-07-25 13:40:02 +02:00
Christoph Sturm
b4a0d620fc fix format string 2019-07-25 10:26:04 +02:00
Christoph Sturm
c3d21806c4 rename Clock to ClockWatcher
* this class is not a clock but it watches the clock, detects standby
and runs periodic tasks.
* there is already a jdk method called clock
First i thought it should be called PeriodicTaskManager, now i find
ClockWatcher more fitting.
2019-07-24 16:39:03 +02:00
Christoph Atteneder
7f26f20e79
Update data stores 2019-07-15 10:02:50 +02:00
Christoph Atteneder
d9e088f469
Merge pull request #2952 from freimair/envelope_of_envelopes
Envelope of envelopes #2
2019-07-12 10:29:22 +02:00
Florian Reimair
31a4ba3ff6
Only send bundle if necessary 2019-07-10 16:32:53 +02:00
Florian Reimair
b44cb452f9
Rename stuff 2019-07-10 16:31:58 +02:00
Christoph Atteneder
7b29511415
Merge pull request #2939 from freimair/envelope_of_envelopes
Bundle of envelopes
2019-07-08 19:45:34 +02:00
Florian Reimair
7b6c55808d
Formatting 2019-07-08 18:48:35 +02:00
Florian Reimair
7a942cfbd7
Cleanup 2019-07-08 16:23:36 +02:00
Florian Reimair
3fb8be3481
Rename 2019-07-08 09:33:50 +02:00
Florian Reimair
8dd993fd54
Still maintain DoS protection 2019-07-06 14:24:12 +02:00
Florian Reimair
0733379141
Split on resulting message size 2019-07-06 14:23:24 +02:00
Florian Reimair
bdc860be9f
Optimized memory footprint of DoS protection 2019-07-05 09:19:41 +02:00
Florian Reimair
f73fa94984
Use EnvelopeOfEnvelopes message type 2019-06-24 16:59:56 +02:00
Florian Reimair
b101035d99
Sketch of businesslogic regarding EnvelopeOfEnvelopes 2019-06-24 16:55:58 +02:00
Florian Reimair
16392f5f0a
Added EnvelopeOfEnvelopes Network Message 2019-06-24 16:53:53 +02:00
Devin Bileck
ac66c97728
Fix AckMessage failure
When taking an offer, ack messages for
OfferAvailablilityRequest/Response were failing to be sent with the
following error.

> Jun-23 22:35:38.129 [JavaFX Application Thread] ERROR
> b.c.o.a.OfferAvailabilityProtocol: AckMessage for
> OfferAvailabilityResponse failed. AckMessage=AckMessage{
>      uid='8779f9ae-22e9-4f16-bbbb-4da89fe23cdf',
>      senderNodeAddress=localhost:3333,
>      sourceType=OFFER_MESSAGE,
>      sourceMsgClassName='OfferAvailabilityResponse',
>      sourceUid='df1a50c5-c6e7-4c81-8ad4-a100d622a053',
>      sourceId='pexluolj-2e5e5d9f-5aca-4a3d-b66a-60b72afe3d2c-112',
>      success=true,
>      errorMessage='null'
> } NetworkEnvelope{
>      messageVersion=12
> }, makersNodeAddress=localhost:3632, errorMessage=We did not send the
> EncryptedMessage because the peer does not support the capability.
2019-06-23 22:50:38 -07:00
Christoph Atteneder
abc0909ffe
Merge pull request #2870 from freimair/monitor-bsqblocks
Monitor knows about the DAO
2019-06-06 14:02:16 +02:00
Florian Reimair
afcc7c00f5
Renamed classes 2019-06-05 19:39:54 +02:00
Florian Reimair
4e5cd50e64
Increase max message size until a greater refactoring 2019-06-05 17:50:59 +02:00
Florian Reimair
7442d2a428
Fix NullPointerEx in Monitor 2019-06-05 17:50:58 +02:00
Christoph Atteneder
fbd49a2cce
Update stores 2019-06-04 10:14:58 +02:00
Manfred Karrer
96138e759b
Cleanups 2019-05-11 12:55:29 +02:00
Manfred Karrer
fa07957c24
Call setAllowDisconnectSeedNodes from LiteNode after blocks received
Instead of the 3 minutes delay we set the flag from the lite node once
the blocks are received. We delay 20 seconds to allow multiple getBlocksRequests
to finish.
2019-05-11 12:55:09 +02:00
Manfred Karrer
a8b1524d8d
Fix issue with too early disconnect to seeds
As soon we are over our connection target we start disconnecting seed
nodes though that can be too early as getBlocks requests are still
pending. We delay the disconnect seed handling to 3 minutes after our
first connection so give it enough time to receive the getBlocksResponse.
2019-05-11 12:22:59 +02:00
Christoph Atteneder
1d18029b1c
Update dbs 2019-05-02 18:00:35 +02:00
Manfred Karrer
1008e9bc51
Add UTF8 for getBytes calls
Fixes https://github.com/bisq-network/bisq/issues/2729
2019-04-17 19:56:21 -05:00
Manfred Karrer
ab0c81804c
Make GetBlocksRequest implement SendersNodeAddressMessage and SupportedCapabilitiesMessage
When we request at startup the blocks from a seed which has not yet
received out capabilities or node address we will not get a response.
We do not want to depend on the state in the getData domain in the
p2p network by using only a seed which has already responded but we
prefer to make sure the seednode will get all the data by our request
to be able to respond.
2019-04-16 22:52:20 -05:00
Manfred Karrer
7e0a7a4f02
Only set capabilities if not null 2019-04-16 22:48:32 -05:00
Manfred Karrer
b0fef9819b
Add check for nullable senderNodeAddress 2019-04-16 22:33:46 -05:00
Manfred Karrer
ba4a3a8918
Avoid logging calls from monitor nodes
Monitor nodes have only one capability set. We don't want to get tons
of logs from those (trade statistics, account witness,....).
2019-04-16 15:09:52 -05:00
Manfred Karrer
2410f38796
Apply formatting (no code change) 2019-04-16 15:07:14 -05:00
Christoph Atteneder
1664a72788
Update Mainnet dbs and remove old test dbs 2019-04-15 14:13:53 +02:00
Christoph Atteneder
27a2772875
Update DBs 2019-04-08 11:11:00 +02:00
Manfred Karrer
e86238d840
Remove unneeded db files, add trade stats 2019-04-01 13:48:12 -05:00
Christoph Atteneder
38728a1132
Update DBs 2019-04-01 15:43:53 +02:00
Manfred Karrer
4d56ce9a10
Apply ExtraDataMapValidator for all extraDataMap fields 2019-03-31 17:35:14 -05:00
Manfred Karrer
9b2c5a2d2a
Increase timeouts
See discussion at https://github.com/bisq-network/bisq/issues/2547
2019-03-25 12:44:54 -05:00
Manfred Karrer
eb8feece58
Add missing @EqualsAndHashCode(exclude = {"date"})
Was unintendely removed in latest refactorings
2019-03-22 20:44:37 -05:00
Manfred Karrer
68894ea2ce
Update db files 2019-03-22 12:25:45 -05:00
Manfred Karrer
b20cb39e5a
Update db files 2019-03-22 12:19:17 -05:00
Manfred Karrer
628705787f
Merge pull request #2552 from freimair/refactor_capabilities
Refactor capabilities
2019-03-18 14:08:40 -05:00
Manfred Karrer
a7dacbf4d5
Merge pull request #2538 from devinbileck/fix-handling-exception-during-tor-setup
Fix exception handling during Tor setup
2019-03-18 14:00:25 -05:00
Florian Reimair
afc241c52a
Renamed hasCapabilities to isEmpty 2019-03-18 12:59:09 +01:00
Florian Reimair
ede3a3c721
Introduced Capabilities.addAll 2019-03-18 12:55:19 +01:00
Florian Reimair
837b4dffb3
Refactor Capabilities for Peer 2019-03-18 12:46:32 +01:00
Florian Reimair
7a03aba02e
Refactor Capabilities for Connection 2019-03-18 12:29:09 +01:00
Manfred Karrer
0b152466f4
Add updated db files 2019-03-16 12:43:12 -05:00
Manfred Karrer
e93358428d
Remove db store file 2019-03-16 12:09:03 -05:00
Manfred Karrer
ccbb5780ab
Add peer to log 2019-03-15 22:58:04 -05:00
Devin Bileck
8ccbe9e39e
Fix exception handling during Tor setup
A recent change in the netlayer is now seeing exceptions wrapped in
a TorCtlException if an error occurs while setting up Tor.

So when an issue such as "Auth cookie not created" (#2398) occurs,
which was previously raised as an IOException, it was restarting Tor
rather than showing the error message to the user.
2019-03-14 16:33:39 -07:00
Manfred Karrer
03023d6338
Remove myAddress from docs and scripts as it is not used/needed anymore 2019-03-08 10:58:53 -05:00
Florian Reimair
b27befed63
--myAddress property is not needed anymore 2019-03-07 17:08:49 +01:00
Florian Reimair
de93a6fa1b
Revert "Revert 2473067b090603dec983fa18995453bdd6d8de94"
This reverts commit a9ee15d9f6.
2019-03-07 17:08:49 +01:00
Manfred Karrer
80fa5c029f
Merge pull request #2507 from freimair/monitor
Monitor tweaks, fixes and a new Metric
2019-03-07 10:46:41 -05:00
Florian Reimair
9f464b3d50
Remove HS from Snapshot Metrics 2019-03-07 12:51:54 +01:00
Manfred Karrer
13dfadddcb
Change log level for log when msgThrottle is triggered 2019-03-06 22:46:02 -05:00
Manfred Karrer
9638f58f7b
Add callSuper = true to EqualsAndHashCode in Peer 2019-03-06 18:39:43 -05:00
Florian Reimair
4bafea83ee
Inline declaration of default value 2019-03-06 09:50:30 +01:00
Florian Reimair
22b4ef921b
Use Lombok Getter 2019-03-06 09:50:30 +01:00
Florian Reimair
7c5210856b
Capabilities optimizations 2019-03-06 09:50:11 +01:00
Florian Reimair
24501178e4
Removed closeConnectionReason from class scope 2019-03-06 09:35:06 +01:00
Florian Reimair
3bb38b81ce
Compressed shutdown members 2019-03-06 09:35:06 +01:00
Florian Reimair
b85075affe
Removed superfluous imports 2019-03-06 09:35:06 +01:00
Florian Reimair
b501a203f4
Removed field that is only used once 2019-03-06 09:35:06 +01:00
Florian Reimair
d21bf3d710
Merged methods that did the same 2019-03-06 09:35:06 +01:00
Florian Reimair
0320261901
Simplified connection shutdown 2019-03-06 09:35:06 +01:00
Florian Reimair
4d21d25fa9
Get rid of 'InputHandler' in 'Connection' class 2019-03-06 09:35:06 +01:00
Florian Reimair
7fa5c190aa
Get rid of 'sharedModel' in 'Connection' class 2019-03-06 09:35:06 +01:00
Florian Reimair
ed799b7018
Removed duplicate and superfluous code 2019-03-06 09:29:46 +01:00