Commit Graph

424 Commits

Author SHA1 Message Date
catbref
fef16e7620 Self-reward-share tests and fixes.
Added Transaction.isFeeValid() to allow transaction subclasses to override and allow zero fees, etc.

Added tests to cover self-reward-shares, including zero fee scenario.

Set 'dilbert' test account to level 8 in test genesis block.

Removed leftover mention of "previous_level" from HSQLDBAccountLevelTransactions,
and AccountLevelTransactionData. (Previous level makes no sense as ACCOUNT_LEVEL
transactions are genesis-block only).

Fixed some incorrect uses of PrivateKeyAccount.getSharedSecret() to
PrivateKeyAccount.getRewardSharePrivateKey() in tests.
2019-10-30 10:23:59 +00:00
catbref
491e79b8e6 ProxyForging->RewardShare massive refactor & more...
Unified terminology from block "generator", "forger", etc. to "minter"

Unified terminology "proxy forger" to "reward share" as it was
incorrect, or at least highly ambiguous, which account had which role.

AccountRepository.findRewardShares() has different arg order!

Account.canMint() now returns true if account has 'founder' flag set.
Added Account.canRewardShare() which returns whether acocunt can create
a reward-share (e.g. level 5+ or founder).

Fixed HSQLDBAssetRepository.getAllAssets() which had incorrect
resultSet column indexes.

Removed old traces of EnableForging transaction.

ACCOUNT_LEVEL and ACCOUNT_FLAGS (genesis-block-only transaction types)
now set target account's last-reference. This is allow later REWARD_SHARE
transactions in genesis block and post-genesis transactions by that account.

REWARD_SHARE transactions are now FREE, but only if minter is also recipient.
If a self-reward-share already exists, then unless share-percent is zero (to
terminate reward-share), any subsequent self-reward-share is invalid.

Updated SysTray i18n properties file.

BlockChain config file requires 'minAccountLevelToRewardShare' and optional
'minAccountLevelToMint'.

Added potential, but currently unused, memory-hard PoW algorithm.

Fixed/removed/disabled some unit tests.
BlockMinter.generateTestingBlock asks Controller to pretend mintingAccount is 'online'.
More testing needed!
2019-10-29 17:46:55 +00:00
catbref
843aad4930 Update BouncyCastle Ed25519 to X25519 key conversion shim 2019-10-25 13:22:08 +01:00
catbref
5798c69449 Code clean-up thanks to SonarLint & bugfix for ByteArray::compareTo! 2019-10-15 17:10:13 +01:00
catbref
a3751823eb Improve code dealing with increase account level due to generated blocks & add orphan equivalent. 2019-10-14 16:37:48 +01:00
catbref
6ba24e1820 Minor code tidying 2019-10-14 11:05:07 +01:00
catbref
319bfc8d75 Add account level change due to blocks generated.
Removed ENABLE_FORGING and related.

Still to do: 'orphan' version of Block.increaseAccountLevels
2019-10-10 13:52:00 +01:00
catbref
54d49e0f1d More work on block rewards in relation to account level/legacy qora held.
Rename Asset.QORA to Asset.QORT so we can also have Asset.LEGACY_QORA
as another hard-coded asset.

Add "is unspendable" aspect to assets where only the asset owner can
transfer/pay asset to other people. Asset trading is barred regardless,
as is use of asset for ATs.

Added "initial level" to account data in preparation for accounts levelling
up from generating blocks.

Added distribution/removal of block reward based on legacy-QORA held.

Removed "previous level" from ACCOUNT_LEVEL transactions as they're
only ever valid in genesis block and so previous level is never needed.
2019-10-08 14:58:00 +01:00
catbref
a1e83109a8 Qortal-style block rewards 2019-10-03 14:20:46 +01:00
catbref
a0be1273c7 Remove max coin supply aspects
Maximum amount/price for selling a name limited to 10 billion,
with 8 decimal prices, so encoding fits within 8 bytes.
2019-10-02 13:24:17 +01:00
catbref
4062bdb7bb Workaround for Handshaking sometimes not correctly dealing with connect-to-self. 2019-10-01 13:15:21 +01:00
catbref
1016d0ca16 Fix Synchronizer bugs
Synchronizer incorrectly tried to compare chain weights in the case
where we had no extra blocks after common block, and thus no blocks
to actually compare.

During chain compare, when more block summaries are needed from peer,
the block signature sent to peer wasn't updated from the last batch
and so the same common block signature was sent. This caused the
code to incorrectly bail out with
"Peer respond with invalid block summary" error as the block heights
didn't match.

Post chain-compare/orphan (if any), and when fetching block signatures,
the code referenced peerBlockSummaries where it should have been
referencing peerBlockSignatures instead. This caused to code to incorrectly
bail out with the "Peer failed to respond with more block signatures..."
error.
2019-10-01 13:02:23 +01:00
catbref
381c032cec Fixed Network's broken choice of next connectable peer.
Slight improvement to comment in Peer.
2019-10-01 12:59:54 +01:00
catbref
568a1f8a30 Migration to Java 11
Updated pom.xml.
Updated dependencies, including various minor code mods, esp. bitcoin-related.

Starts up and talks to Java 8 nodes!

Dev environment should be at least Eclipse 4.11 with m2e 1.9.1+
2019-09-30 18:06:00 +01:00
QORT
b95eea6763
add Qortal Project to title 2019-09-29 17:13:27 -07:00
catbref
305bb38446 Remove "generating balance", and all related aspects/code.
Block forging is now allowed by level 1+ accounts,
instead of accounts with "minting flag" set.
2019-09-27 15:16:12 +01:00
catbref
4c6656dd17 New synchronizer and other improvements
API call GET /addresses/online reports online accounts,
including both addresses relating to the proxy-forge public key.

New PeerChainTipData class to replace the broken "peer data lock"
that was supposed to make sure peer's last height/blockSig/timestamp
were all in sync. Now peer's chain tip data is a single object
reference that can be replaced in one go.

Removed pointless API calls /blocks/time and /blocks/{generatingbalance}.

Various changes, mostly in Block class, to do with switching to BlockTimingByHeight
from old min/max block time.

New block 'weight' based on number of online accounts
and 'distance' of perturbed generator public key from 'ideal' public key
(for that particular block's height).

New sub-chain 'weight' based on accumulating block weights,
currently by shifting previous accumulator left by 8 bits then
adding next block's weight.

More validation of BlockChain config. Helpful for debugging, probably
not very useful to end-users.

BlockGenerator now uses unified Peer predicates from Controller, like:
Controller.hasMisbehaved, Controller.hasNoRecentBlock, etc.

Controller now keeps a list of chain-tip signatures that are for inferior
chains, so it doesn't try to synchronize with peers with inferior chains.
(This list is wiped when node's blockchain changes/block is generated).

Controller now asks Gui to display error box if it can't parse Settings.

Controller.potentiallySynchronize() does more filtering of potential peers
before calling actuallySynchronize(). (Mostly moved from Synchronizer,
so now we expect actuallySynchronize() to do something rather than bail
out because it doesn't like the peer after all).

If synchronization discovers that peer has an inferior chain,
then Controller notifies that peer of our superior chain, to help keep
the network in sync.

Renamed OnlineAccount to OnlineAccountData, as it is in package org.qora.data
after all...

Synchronizer reworked to request block summaries so it can judge which chain
is better, and hence whether to sync with peer or abort.

Slight optimization of Peer.readChannel() to exit earlier if no more network
messages can be extracted from buffer.

More tests.
Improved documentation and logging.
2019-09-26 17:43:50 +01:00
catbref
c889e95da4 ByteArray tests 2019-09-26 17:25:39 +01:00
catbref
14e9ae8887 ExecuteProduceConsume no longer spawns a pointless, new thread if we have an excess of non-consuming threads 2019-09-26 17:25:05 +01:00
catbref
344b9436ca Much improved ByteArray, with unsigned compareTo() & "raw" renamed to "value" 2019-09-26 17:23:46 +01:00
catbref
40d879813d Added exists() test to BlockRepository & HSQLDB implementation 2019-09-26 17:22:03 +01:00
catbref
c00481a750 Added fatal error pop-up and exit to Gui 2019-09-26 17:20:57 +01:00
catbref
a1cfe31574 Block size and transaction expiry period now in BlockChain config
Block.MAX_BLOCK_BYTES now BlockChain.getMaxBlockSize()

Network.MAXIMUM_MESSAGE_SIZE now Network.getMaxMessageSize() as
it depends on block size (above).
2019-09-23 17:01:25 +01:00
catbref
e009147956 Additional checks on byte lengths in BlockTransformer, especially before buffer allocation 2019-09-23 16:46:16 +01:00
catbref
aa54ec212f Convert TransactionTransformer LOGGER.trace to use lambda for speed 2019-09-23 16:45:26 +01:00
catbref
4b5ed79c5a Added testNtpOffset settings field (+ minor settings docs changes) 2019-09-23 16:44:47 +01:00
catbref
0dd5b1e65a More work on online accounts / blocks
Block data now includes number of online accounts, as encoded online account indexes can't be
validated by ConciseSet it seems.
Corresponding changes to repository, transformer, block validation, data object, block summaries...

Block timestamps are now calculated using parent block data and generator's public key,
instead of old qora1 generating balance code.

Generators are valid to forge if they have forging flag enabled. This will probably change
to an account-level check in the near future.

Added trimming of old online accounts signatures from blocks.

Tidied up SysTray/BlockGenerator generation enabled/possible flag.

Although we perform online accounts tasks (currently) every 10 seconds,
only broadcast our online accounts every 60 seconds.

In Controller.main(), if args are present then use first as a filename to
settings JSON file (overriding the default filename).

Still to do: change Block/BlockChain/Synchronizer to prefer blocks with more online accounts,
failing that use generator nearest 'ideal', etc.
2019-09-18 14:49:47 +01:00
catbref
aa81c86cf1 Rename timestampSignatures to onlineAccountsSignatures 2019-09-16 11:11:42 +01:00
catbref
504cfc6a74 Interim commit: online accounts and account levels
Safety commit in case of data loss!

Lots of changes to do with "online accounts", including:

* networking
	+ GET_ONLINE_ACCOUNTS * ONLINE_ACCOUNTS messages & handling
	+ Changes to serialization of block data to include online accounts info
* block-related
	+ Adding online accounts info when generating blocks
	+ Validating online accounts info in block data
	+ Repository changes to store online accounts info
* Controller
	+ Managing in-memory cache of online accounts
	+ Updating/broadcasting our online accounts
* BlockChain config

Added "account levels", so new code/changes required in the usual places, like:

* transaction data object
* repository
* transaction transformer
* transaction processing
2019-09-13 14:32:32 +01:00
catbref
2cc926666b Qortal-specific Settings changes
Mostly changes to default port numbers
2019-09-13 14:32:32 +01:00
catbref
b9a96019a4 Qortal-specific Network changes
Changed message magics
Changed initial peers
Corrected filtering of potential peers for new connection.
2019-09-13 14:32:32 +01:00
catbref
cfc86d567c Qortal splash image and icons 2019-09-13 14:32:32 +01:00
catbref
978a22cab3 Added ProxyKeys standalone for generating proxy keys 2019-09-13 14:32:32 +01:00
catbref
06095d633e Modify pom.xml for Qortal & add ConciseSet
ConciseSet provided by io.druid.extendedset
but we need to exclude older versions of jackson-xml
2019-09-13 14:32:32 +01:00
catbref
158631e68a Fix forging bit mask for account flags 2019-09-13 14:32:32 +01:00
catbref
8149e18f49 Fix incorrect tx type values in transaction layouts 2019-09-13 14:32:32 +01:00
catbref
a9122cc6cb Improve choosing which peer to connect to 2019-08-21 09:45:41 +01:00
catbref
f7c6978151 Add threading to VanityGen 2019-08-21 09:44:52 +01:00
catbref
4330782bb7 Added Ed25519 signature verify test JavaScript
JS uses tonyg/js-nacl libsodium port.

First sig shows disagreement with WhisperSystems-based legacy crypto.
2019-08-16 12:33:21 +01:00
catbref
2889d04633 Fix incorrect orphaning of BUY_NAME transactions.
Orphaning a BUY_NAME transaction would not reinstate the
sale price. Sale price could be nullified by (e.g.) orphaning
a SELL_NAME transaction.

Also added test case to cover above and other test-related support,
e.g. test-mode in NTP.
2019-08-16 11:48:30 +01:00
catbref
f83dc26ae0 ExecuteProduceConsume and networking improvements
Added "volatile" to more fields, for thread-safety on reads.
Changes to field values are done inside synchronized blocks
so no need for AtomicInteger/AtomicBoolean. (Could be changed
in the future to show intention/readability though).

Added more statistics (tasks produced/consumed).

Limited Network's EPC executor to 10 threads max.
2019-08-16 08:28:26 +01:00
catbref
c597f11c37 Fix fetching asset-related transactions from DB where asset might not exist.
Some asset-related transactions (CREATE_ASSET_ORDER and TRANSFER_ASSET)
also try to fetch asset names at the same time.

If one of these transactions, and a corresponding ISSUE_ASSET transaction,
have been orphaned then it's possible that the asset no longer exists.

Thus the SQL "JOIN" fails during transaction retrieval, causing an error.

Changing the table-join to "LEFT OUTER JOIN" makes the asset name aspect
optional. Repercussions might be nameless assets when fetching transaction
info via API.
2019-08-16 08:19:12 +01:00
catbref
3b3888ae0d Fix asset ordering for old-pricing orders 2019-08-16 08:18:34 +01:00
catbref
6abc3f4d39 Networking improvements
Fix issue where sometimes the channelSelector.select(1000) would
block processing of queued messages.

Improve support with older v1 peers.
2019-08-14 15:15:20 +01:00
catbref
ea3528015a Add support for v1-protocol BLOCK message 2019-08-14 15:14:47 +01:00
catbref
84e812484b Fix GenesisBlock ISSUE_ASSET transactions for v1 chains 2019-08-14 15:14:28 +01:00
catbref
e631e69fa1 Use bindAddress from Settings for UI, API and P2P. 2019-08-14 15:11:20 +01:00
catbref
8a0d93f304 Fix up after epic git history rebuild due to LFS issue 2019-08-13 10:27:28 +01:00
catbref
fa0b7615a6 Fixing peer disconnections due to slow processing & Transaction expiry
Transaction expiry wasn't happening. Use NTP.getTime to check whether
transactions have expired. Also reject expired transactions when trying
to add them to unconfirmed pool.

Sometimes producing a task took way too long, causing massive
spikes in the number of threads and peer disconnections.

This is down to a repository pool exhaustion, so
RepositoryManager.getRepository() would block (for up to 5 minutes).

The key method at fault was Network.getConnectablePeer().

Various fixes:

NetworkProcessor's executor now reaps old threads after only 10 seconds
instead of the usual 60 seconds.

Change logging in Network to help diagnose disconnection and repository
issues.

RepositoryManager now has a tryRepository() call that is non-blocking
and returns null if repository pool is exhausted.

Repository pool size increased from default (10) to 100.

Pruning peers is now opportunistic, using tryRepository(), and returns
early if repository pool is exhausted.

getConnectablePeer() is now opportunistic, using tryRepository(), and
returns null (no peer candidate for connection) if repository pool
is exhausted.

Merging peers is not opportunistic, using tryRepository().

Peer ping interval increased from 8s to 20s.

HSQLDBRepositoryFactory now logs when getConnection() takes over 1000ms.

Added more trace-level logging to ExecuteProduceConsume to
highlight slow produceTask() calls.
2019-08-13 09:54:35 +01:00
catbref
1094db288e Catch SystemTray.isSupported errors (and act as if no support).
Symptoms were on Ubuntu with 8u222:

Exception in thread "Controller" java.awt.AWTError: Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper
        at java.awt.Toolkit.loadAssistiveTechnologies(Toolkit.java:807)
        at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:886)
        at java.awt.SystemTray.isSupported(SystemTray.java:219)
        at org.qora.gui.SysTray.<init>(SysTray.java:50)
        at org.qora.gui.SysTray.getInstance(SysTray.java:249)
        at org.qora.controller.Controller.updateSysTray(Controller.java:480)
        at org.qora.controller.Controller.run(Controller.java:368)

(Underlying cause not known)

This would cause Controller thread to silently exit, and so no
synchronization would occur. Node would still have connections
and thus happily generate its own blocks on its on fork.

Maybe other peers would try to sync with this node but would
likely reject this node's chain after a short while.
2019-08-13 09:54:25 +01:00