Commit Graph

225 Commits

Author SHA1 Message Date
catbref
5f5b847bee Using m2e-aware version of package-info-maven-plugin (v1.0.2-m2e) 2019-03-26 11:03:50 +00:00
catbref
c5e5020369 In API call /assets/balances, change "ordering" to be optional but with default "ASSET_BALANCE_ACCOUNT" 2019-03-25 15:21:10 +00:00
catbref
a4d28d52cc Add variety of results ordering options to API GET /assets/balances 2019-03-25 12:24:22 +00:00
catbref
0fd8ee3547 Add API GET /assets/transfers/{assetid}/{address} 2019-03-25 11:55:03 +00:00
catbref
2a45e27048 Important FIX to payment-related isValid()!
Non-native-coin payments (e.g. transfer-asset) didn't build map
for checking whether sender had enough balance.

Also fixed raw layout description for TRANSFER_ASSET.

Also fixed ISSUE_ASSET deserialization to use empty string (instead
of null) for v1 transactions.
2019-03-25 11:23:18 +00:00
catbref
eb038b8f31 Controller debugging, including logging build version/timestamp 2019-03-25 11:22:57 +00:00
catbref
461c9211da Bump qora-core v2 hard fork timestamp to 00:00:00 June 1st 2019 2019-03-25 11:21:56 +00:00
catbref
315a3c33cf Add API error handler to log unexpected errors/exceptions
Fixed /admin/uptime to return text/plain instead of application/json
 as response is only a simple long.
Ditto /admin/stop.
2019-03-19 10:09:01 +00:00
catbref
048c54fc0a Add API call to support TRANSFER_ASSET + activity summary API call 2019-03-18 11:34:46 +00:00
catbref
91ee505ba9 Fix GET /assets/trades/recent regression + silence Jetty timeout warnings 2019-03-17 13:35:24 +00:00
catbref
76277ae9c3 Increase asset "data" size and make description/data optional in UPDATE_ASSET
Bumped Asset data size from 4K to 400K
2019-03-15 11:22:53 +00:00
catbref
1b3fa5c806 Automatically set/unset account's defaultGroupId + bugfix
FIX: somehow GET /groups/member/{address} HSQLDB's query broke
2019-03-14 13:12:20 +00:00
catbref
d53777f461 Added "data" field to assets, added UPDATE_ASSET tx + fixes 2019-03-13 14:06:52 +00:00
catbref
8f72d9d423 Don't return empty balances when requesting all asset holders. 2019-03-11 13:03:57 +00:00
catbref
cdd1f5e966 API modifications, remove blockchain defaultGroupId, Eclipse/git
GET /assets/trades/recent expanded to allow multiple otherAssetIds

When GET /assets/balances is called with address(es) but no assetIDs
then it will return balances for all assets, including zero balances
for assets the addresses don't own.

GET /addresses/{address} no long fakes a default groupID - in fact
defaultGroupId now removed from blockchain config.

Some Eclipse IDE files now hidden/removed from git repo.
2019-03-11 11:17:34 +00:00
catbref
43eec116b5 Reorder handshake to increase compat with v1 nodes + request remote peers 2019-03-06 10:40:39 +00:00
catbref
bf3f78e718 Add AssetOrders is_closed fix-up to DB updates + minor 2019-03-05 11:12:00 +00:00
catbref
4d69242cdb Added/improved assets-related API calls
Imported Block/BlockChain fixes from "minting" branch to do
with block timestamps.

GET /assets/holders/{assetid}
and
GET /assets/address/{address}
and
GET /assets/balance/{assetid}/{address}
all combined into
GET /assets/balances?address=...&address=...&assetid=...&assetid=...

New GET /assets/trades/recent?assetid=...&assetid=...
that returns most recent two trades for each asset-pair.

GET /assets/orders/{address}/{assetid}/{otherassetid} has
includeClosed and includeFulfilled repurposed as
isClosed (true/false/omitted) and isFulfilled (true/false/omitted).

ALSO, Order.isClosed is now set to true when isFulfilled is set to true
during processing (and correspondingly set to false during orphaning).

AccountBalanceData now includes optional assetName field for use with API
but generally not set for internal use.
2019-03-04 18:53:54 +00:00
catbref
752361ecff Performance fix & other minor fixes
Fixed bug in GenesisBlock which wasn't stripping
out ISSUE_ASSET transactions for v1 blockchains.

Updated blockchain.json for v1 qora blockchain to
fall into line with new BlockChain config
unmarshalling code.

Improved TransactionData.equals when comparing
exact same object.

Improved HSQLDBBlockRepository.getHeightFromTimestamp to use OffsetDateTime
object, which includes time zone info, to fix incorrect SQL full-scan
so that DB now does index-scan instead. Also converted use of MAX(column)
to ORDER BY column DESC as MAX() not optimized when MVCC in effect.

Added corresponding INDEX to Blocks on columns (generation, height);

Similar MAX(column) to ORDER BY column DESC improvement for getBlockchainHeight().

Bumped size of HSQLDB TYPE ATTags from VARCHAR(32) to VARCHAR(80)

Improved reflection-based method calls to rethrow underlying exceptions
like DataException, TransformationException, etc. instead of losing
them in general InvocationTargetException.

Re-added atTransaction.toBytes() method so v1 transactions can be verified.

Fixed extraneous additional copy of voter's public key when serializing
in VoteOnPollTransactionTransformer.toBytes()

Fix-up of v1feeder
2019-03-04 11:41:30 +00:00
catbref
dbf365472f Suppress Reflections log entry using log4j2.properties 2019-02-27 14:43:01 +00:00
catbref
edcbf4f318 Add support for "only one registered name per account" + de-static brokenMD160 blockchain flag 2019-02-27 10:34:25 +00:00
catbref
ec5eba9c60 Fix up some group-approval related issues
UPDATE_NAME requires txGroupId to match original txGroupId used in REGISTER_NAME
UPDATE_GROUP requires txGroupId to match original txGroupId used in CREATE_GROUP

Extraneous JAXB unmarshal code removed from various transaction constructors.
Incorrect, old, groupID vs txGroupId checks removed from various transactions.

Fix bug in UPDATE_GROUP fromBase() method using mismatched column indexes.

Fix bug in API's pending transaction fetch not checking admin is of the same
group as the txGroupId. (Fix actually in HSQLDBTransactionRepository).
Similar fix in GroupApprovalTransaction.
2019-02-26 16:52:22 +00:00
catbref
c7123df79d Better logging for settings/blockchain JSON file parsing 2019-02-26 11:20:44 +00:00
catbref
deae03f1a4 Fix blockchain config logic error 2019-02-26 11:07:44 +00:00
catbref
c80ac9e321 Asset API additions, txGroupId minor fix, testnet blockgen fix
GET /assets/orderbook/{assetid}/{otherassetid} renamed to
GET /assets/openorders/{assetid}/{otherassetid}

Replacement /assets/orderbook/{assetid}/{otherassetid} now
returns aggregated orders, with entries containing only
"price" and "unfulfilled" (amount).

Added /assets/orders/{assetid}/{otherassetid}/{address} to return
orders by specific account, for a specific asset-pair.

Block timestamp validity extracted to separate method so that
BlockGenerator can test timestamp and generate blocks at the usual
rate, even for testnets. This still allows testnets to a way to
generate blocks on demand as Block's isValid skips some timestamp
validity checks if testnet.

txGroupId was sometimes incorrectedly checked for approval-less tx types.
2019-02-26 10:56:19 +00:00
catbref
16c1b13ab2 Proper JSON unmarshalling for settings, blockchain config, genesis block
GenesisBlock (v4) now supports various transaction types (issue-asset, etc.)
 with generated signatures (like genesis transaction signature) and
 missing references inserted.

JUnit reverted back to v4 for Eclipse support (for now).
2019-02-25 13:31:05 +00:00
catbref
86a35c3b71 Work on groups
Some dev/testing API calls are now turned off by default in production mode,
 see "restrictApi" settings entry, returning NON_PRODUCTION API error.

Corrections to how account's defaultGroupId works, removing "effective groupID"
 which overly complicated matters.
In relation to above, DEFAULT_GROUP (0) no longer exists and NO_GROUP(-1) now has
 the value 0 instead.
So transactions can no longer have txGroupId of DEFAULT_GROUP, which in turn
 required all the erroneous "effective groupID" code.

API call /addresses/{address} now supplies blockchain-wide defaultGroupId if
 account doesn't exist or if account's default not set and NO-GROUP not allowed.

API /transactions/pending now offloaded to repository instead of Java-based
 processing and filtering.

Transaction approval checks added to Block.isValid

Groups now have min/max approval block delays.
 Checks added to incoming unconfirmed, block generator, block.isValid, etc.

'needing approval' and 'meets approval threshold' now split into separate calls.

NB: settings.json no longer part of git repo
2019-02-20 12:25:30 +00:00
catbref
00656f6724 Interim safety commit due to large number of changes!
log4j2.properties now has debugging entries removed.
log4j2-test.properties (not in repo) takes priority
 so using that in development instead.

Unconfirmed transactions no longer wiped on start-up
 by default - see Settings

Reworking of {Public,Private,Genesis}Accounts as it seemed
 possible to silently lose public key in repository.
The use of AccountData didn't work and so field-specific
 repository calls have been made instead
 (e.g. setLastReference) that try to opportunistically
 store public key too, if available (i.e. caller is
 PublicKeyAccount subclass, or better).

Added API call GET /addresses/{address} to return
 general account info in one go. (Essentially the
 AccountData object as fetched from repository).

Initial work on adding default groupID to accounts,
 along with corresponding SET_GROUP transaction type.
In additional, added blockchain-wide default groupID
 and flag to allow/disallow no-group/groupless
 transactions.

Initial work on group-admin approval of transactions
 tied to a specific group via txGroupId.

More work needed on transaction's "effective txGroupId"!

API call /transactions/pending to list transactions
 pending group-admin approval. However, this needs more
 work (see effective txGroupId above) and potentially
 offloading to HSQLDB repository if possible.

Minor CIYAM AT renames to help static reflection initializers.

Block.orphan() no longer adds orphaned transactions back to
 unconfirmed pile as they are themselves deleted during
 Transaction.orphan(). Maybe the answer is to NOT delete
 them during Transaction.orphan() but to add them to
 unconfirmed pile at that point? Very old transactions
 leftover from major resync would simply expire, whereas
 recently transactions leftover from minor resync could
 still make it into a new block on synced chain fork.

Changes/tidying/improvements to block generator regarding
 removing invalid transactions and dealing with transactions
 pending group approval.

Approval threshold added to groups.

Mass refactoring of transaction-related classes to unify
 constructors, particularly field ordering, to fall in line
 with raw transaction layout.
e.g. constructors now reflect that raw transactions mostly
 start with type, timestamp, txGroupId, publicKey, reference
e.g. JAXB afterUnmarshal methods added where needed and corresponding
 nasty code in Transaction subclass constructors ripped out.
e.g. TransactionTransformer subclasses contain less duplicated code.

Fixed bug with repository save points thanks to swapping to Deque.

Some fixes to do with missing transaction types being passed to JAXB
 TransactionData subclass constructors.

Ripped out obsolete toJSON in TransactionTransformers as this
 is all nicely taken care of by Swagger/OpenAPI (thanks @Kc)
2019-02-18 19:00:37 +00:00
catbref
82e9e1e7dc Improved peer addresses.
Added short sleep() to GET /admin/stop to allow time for HTTP response body to be sent back.

Improved documentation for /peers API resources. Added examples, tidied API output models.
Fixed issue where IPv6 literals with port couldn't be parsed. Now uses RFC5952/RFC3986 style
literal IPv6 addresses with ports, e.g. [::1]:9084

Fixed NPE in Controller.potentiallySynchronize() where peer might not have sent height yet.

Improved Handshake to discard inbound connections if we already have an outbound connection
to a peer with that ID. This prevents us from having two connections to the same peer, one
in each direction.

Network.mergePeers() now runs in a separate thread as acquiring the lock might block.

Network.creationConnection() exits fast based on number of outbound connections, instead of
number of total connections.

Network no longer sends 'local' peer addresses to non-local peers.
e.g. it won't send localhost:9084 to node4.qora.org:9084

Added try-catch to Network.broadcast for when we try to broadcast while shutting down.

Added PeerAddress class to deal with the whole hostname/IPv4/IPv6 address situation.

Reworked PEERS_V2 message type to only send sized-strings instead of separate port,
and potentially IPv6 byte arrays.

Change to HSQLDB database shape.
Corresponding changes to HSQLDBNetworkRepository.
2019-02-12 18:50:49 +00:00
catbref
174a1a5909 Re-assert HSQLDB concurrency control mode 2019-02-11 18:36:29 +00:00
catbref
7a53ac17a6 Synchronization, peer management + fixes
Peers now broadcast height after successful synchronization.

Added support for sending unconfirmed transactions to other peers.
This is done on connect and also after a new unconfirmed transaction is submitted via API.

Fixed synchronizer to handle blocks with transactions correctly.

Fixed network-related PoW to not use class-global SHA256 message digester!
(It was being corrupted by simulataneous access by different threads - whoops)

Surrounded Network.mergePeers with a lock to prevent HSQLDB deadlocks.
Also changed HSQLDB concurrency model to MVCC (only takes effect if DB rebuilt).

Added support for logging other HSQLDB sessions in the event of exception.
(Currently only used by HSQLDBSaver)

Transaction transformer modifications to help deserialize TransactionMessages.
2019-02-11 17:37:52 +00:00
catbref
7f4511cb7b Networking and repository
Some pom.xml changes to reduce maven-shade-plugin conflicting classes warnings.

Repository now supports SAVEPOINT and ROLLBACK TO SAVEPOINT.
HSQLDB concurrency/transaction model changed from LOCKS to MVCC to help with
 transaction deadlocks/rollbacks.

More XXXs and TODOs added to Block.java for investigation/fix/improvements.
Also used new repository SAVEPOINT feature when validating transactions
 instead of rolling back entire transaction. This fixes problem during
 synchronization where the rollback would undo previously synchronized,
 but not yet committed, blocks!

Transactions orphaned by Block.orphan ARE now added to unconfirmed pile,
 unlike before.

Concurrent lock now prevents simultaneous block generation and synchronization,
 including synchronization via multiple peers.

Lots of new networking code: peer lists, block signatures, blocks,
 blockchain synchronization.

PEERS_V2 message now supports hostnames, IPv6 and port numbers.

Fixed bug with block serialization for transport over network.
2019-02-01 14:03:06 +00:00
catbref
0db43451d4 Interim networking code commit in case of dev catastrophe!
DB shape change from v29 to add peer info.
New NetworkRepository to handle above.

Peer handshaking with v2 anti-DoS PoW code.
Handshaking refactored into a state-machine-like enum.
Some peer-related API calls added.

Peers exchange pings, heights, peers.

No actual peer sync yet.

Other changes:

Peer version info taken from Maven build properties/resource file.
AnnotationPostProcessor more resilient when fetching PathItems.
Per-repository session debugging flag that can be toggled at will.
HSQLDBRepository.delete() now returns int so callers can detect
 whether anything was actually deleted.
Some renaming to settings.
2019-01-30 18:24:10 +00:00
catbref
79b3074d01 Reworked reflection code in Transaction static init to appease Maven compiler!? 2019-01-25 15:56:17 +00:00
catbref
6eb3520295 Asset-related transactions API + performance improvements + fix
Moved as much reflection out to class-static initializers as possible.

Renamed some classes to fall in line with transaction type name
to class name conversion, e.g. DEPLOY_AT -> DeployAt
2019-01-25 15:22:56 +00:00
catbref
4be58514c0 Unify API calls that return lists + offload pagination to repository
API calls that return lists now take limit, offset and reverse params.

API calls that used to return data & optional list (e.g. blockWithTransactions)
now only return base data. The optional lists can be fetched via
a different API call.

Also: SLF4J now routes logging to log4j2 so start up output cleaned up.
Suppressed extraneous Jersey warning about Providers during start-up injection.
2019-01-24 16:42:55 +00:00
catbref
782bc2000f Added raw transaction layout API call to help build raw transactions.
Converted unwieldy tx-type switch statements to use reflection.
2019-01-17 09:01:05 +00:00
catbref
6a10df85ab Hide internal-use references from some objects emitted by API 2019-01-16 15:46:35 +00:00
catbref
c81a3838fc Added API call to list registered names that are for sale 2019-01-16 15:37:18 +00:00
catbref
e04f9df0dc Groups API: get invites by group ID or invitee
+ fixed API response models that were incorrectly NOT arrays
2019-01-16 15:22:15 +00:00
catbref
bc4de8f063 Groups: refactored to use group ID, not group name, plus fixes, etc. 2019-01-16 15:00:25 +00:00
catbref
3b4c12da56 Group ban/unban & pre-conversion to groupID & pre-tidy/refactor 2019-01-15 14:41:36 +00:00
catbref
90f1676c7c Account group invite/cancel-invite and kick
Account group join for a group that is closed/invite-only
and has no corresponding invite is now turned into a "join request".
This can be accepted by an admin sending a corresponding invite tx.
2019-01-14 14:36:43 +00:00
catbref
df730d9fb9 Add/remove account group admins (by owner) 2019-01-11 14:07:16 +00:00
catbref
02a620d57b Join/Leave account groups + API calls 2019-01-11 10:42:42 +00:00
catbref
760cb6cd37 JOIN Group + improved specific group info from API 2019-01-10 17:28:13 +00:00
catbref
83abede8ab Account groups: create group + update group + API calls
(Also minor fix for orphan.java).

Note use of afterUnmarshal() in TransactionData-subclass to replace trash code in Transaction-subclass constructor.
See UpdateGroupTransactionData.afterUnmarshal() compared to RegisterNameTransaction constructor.
2019-01-10 15:45:00 +00:00
catbref
74bf930698 API: added support for sell, cancel-sell and buy name transaction builders 2019-01-09 16:03:07 +00:00
catbref
22c87a6e08 API + fix for names in HSQLDB
Added POST /names/update for building an UPDATE-NAME transaction.

BlockGenerator now tries to validate new block after adding each
unconfirmed transaction in turn. If block becomes invalid then
that transaction is removed/skipped. This should further prevent
block jams. Skipped transactions might be deleted as the next block
is forged when unconfirmed transactions are collated/filtered/expired.

Add Block.deleteTransaction() for use during block generation above.

Block.addTransaction() and Block.deleteTransaction() use transaction
signatures to test for presence in Block's existing transactions.

Names shouldn't have stored registrant's public key!
"registrantPublicKey" removed from NameData Java object/bean.
Corresponding column removed from HSQLDB using ALTER TABLE but
also from the original CREATE TABLE definition. Remove the ALTER
TABLE statement just prior to rebuilding database!

(This needs to be applied to Polls too as some point).

Also, UpdateNameTransactions and BuyNameTransactions tables now
allow name_reference to be NULL as this column value isn't set
until the corresponding transactions are processed/added to a
block. (name_reference is a link to previous name-related
transaction that altered Name data like "owner" or "data" so
that name-related transactions can be orphaned/undone).
2019-01-09 14:41:49 +00:00
catbref
95d640cc8c API + new tx restrictions
Added GET /names to list all registered name.
Added GET /names/{name} for more info on a specific name.
Added GET /names/address/{address} for names owned by address.

Renamed GET /assets/all to GET /assets in line with above.

Fixed edge cases with AnnotationPostProcessor.

Fixed incorrectly exposed "blockHeight" in API UI examples/values.
Changed example transaction timestamp.

Added checks on building/signing/processing new transactions via API
so that they are not too old (older than latest block's timestamp),
too new (more than 24 hours in the future) or the tx creator doesn't
already have a lot of existing unconfirmed transactions (default 100).

Configurable via settings.json properties maxUnconfirmedPerAccount
and maxTransactionTimestampFuture.

Improved /transactions/search to not return unconfirmed transactions
and to order by timestamp.

Transaction.getCreator() now returns PublicKeyAccount, not Account.
2019-01-08 17:30:23 +00:00