ARK Core Upgrade To V2.4 — Introducing P2P WebSocketssteemCreated with Sketch.

in arkecosystem •  2 months ago 

ARK Core continues to evolve! For the 2.4 upgrade we focused on Peer 2 Peer
(P2P) layer switching from API to WebSockets. P2P is a communications layer
where interconnected nodes (“peers”) share resources amongst each other without
the use of a centralized administrative system. It is how nodes that run Core
interact with each other on the ARK Public Network. The switch to use WebSockets
brings better performance, higher resistance to some types of potential attacks
and real-time exchanging of information. This is only one of the changes in this
release. This post will cover the most significant changes in today’s upgrade.

In addition to Core v2.4 upgrade, there is a new Desktop Wallet update available
as well,
Please update your wallet to properly interact with the Core v2.4 update. There
will also be larger Desktop Wallet update coming soon, so please stay tuned.

**Download newest Desktop Wallet v2.4.1 that supports Core v2.4 at:

What’s New in Core v2.4?

Since the biggest change was the switch to WebSockets protocol, lets go over the
reasoning and benefits behind this first. Before the switch, P2P communication
was done via API (HTTP requests). Whenever nodes made a request (blocks,
transactions, wallets, …) a connection was opened, data was transferred, and
then after completion the connection was closed. This continuous opening and
closing creates a lot of overhead, and for ARK’s Core that relies on constant
responses or real time interactions, this isn’t the most viable long-term

WebSockets is a very flexible protocol for transferring data via P2P. Unlike
API, the socket that is connected to the server stays “open” for communication.
That means data can be “pushed” to the other node in real-time on demand,
without creating additional requests.

We chose Socketcluster**, **which is a pure
WebSocket framework solution, to help us with P2P WebSockets implementation.
Some of the features it supports:

  • Scales linearly as you add more CPU cores and workers.
  • Scales horizontally across multiple machines.
  • Resilient on both the client and backend — Process crashes, lost connections and
    other failures are handled seamlessly.
  • Supports custom codecs for compressing messages during transmission.
  • Supports both pub/sub channels and direct client-server communication.
  • Authorization via middleware functions (access control for emit, publish in,
    publish out, subscribe and handshake).
  • Client sockets automatically reconnect (by default) if they lose the connection.
  • Designed to work alongside any database/datastore.

Another new addition (which was scheduled to be implemented in a later version)
is initial implementation of parallel block downloading and batch block
database inserts when syncing
. Before v2.4, while syncing, nodes could only
download chunks of blocks from a single other node of the ARK network. With the
introduction of parallel block downloading, we have increased this number to 25
concurrent connections to different nodes throughout ARK network. This means
instead of only using a single node, it now downloads blocks simultaneously from
25 different peers. This not only speeds up the syncing process, but it also
levels out the network traffic by spreading it across multiple nodes.

The transaction pool has been improved to handle faulty data more accurately and
to make it even stricter for bad or malicious data to enter the pool, making it
more efficient and safe.

The JSON-RPC we offer, formerly known as Core-JSON-RPC, has received a rework
to turn it into a real RPC that is easier to use and maintain. The biggest
change is that it now offers programmatic use to make integration into ARK Core
easier while simultaneously allowing it to run as a standalone application
detached from a relay.

Various improvements have also been added to ARK Deployer, making bridgechain
deployment even easier and more user friendly. We have implemented Explorer as a
Core plugin and added a new Wallet API that caters to the needs of developers
and ease of integration in end user products.

We have also implemented replay command to verify blockchain data from block 0,
making it easier to do verification of all data in the database the same way it
is done during sync, but without storing the data again (replay blocks in-memory
from the local database).

What’s Next for Core?

While we just released v2.4, our v2.5 upgrade is almost complete as well and
will go live for testing on the public development network in the upcoming days.
This won’t be as tremendous of an upgrade as v2.3 to v2.4 was, but will focus on
deprecating API v1 support. You can read more on this
— **if you are still using API v1 for anything, make sure to update to API v2 as
soon as possible. Numerous improvements will also be made on making the code
leaner, removing obsolete (legacy) code, and making it even more developer

Our next major change will be v2.6, for which we can be certain will be THE
BIGGEST and most VALUABLE upgrade of the ARK network — AIP 11 (new transaction
types), AIP 18 (multisignatures) and full AIP 29 support (easy custom
transaction type integration) are just some of the major improvements coming to
the network, but since we don’t want to spoil everything in this blog post we’ll
cover this in one of our upcoming blog posts. Stay tuned!

All Changes From v2.3 to v2.4

*For node operators of the current ARK Core, in order to update, please follow
these migration instructions (v2.3 to v2.4) before you do the update: *

Changes In Numbers

  • **11 different developers **contributing to the Core.
  • 234 new commits to the Core.
  • 1,049 files changed in the Core.
  • **47,980 code additions **to the Core.
  • **37,603 code deletions **in the Core.

As we move towards 2.6 and the completion of AIP11, AIP18 and AIP29, there will
be various breaking changes. The main concern of most developers will be
breaking changes to @arkecosystem/crypto, so go through the commits listed
below and make sure you adjust everything in your application that is affected
by a change.

Breaking Changes

  • Implement WebSockets with SocketCluster
  • Switch transaction expiration from seconds to chain height
  • Implement Block.fromHex, Block.fromBytes and Block.fromData methods in
  • Implement BlockFactory in @arkecosystem/crypto
  • Implement TransactionFactory in @arkecosystem/crypto
  • Purge invalid transactions after a milestone change
  • Make transaction amount required
  • Always use crypto identities to work with keys and addresses
  • Enforce BigNumber for satoshi based values
  • Move in-memory wallet logic to core-state
  • Replace bignumify with Utils.BigNumber.make
  • Replace Joi with AJV for internal validation
  • Bind plugin options before registering the plugin
  • Extend the node.js event emitter
  • Move the wallet interfaces to @arkecosystem/core-state
  • Simplify the transaction pool by not using insertion order
  • Drop no longer needed pagination from @arkecosystem/core-webhooks
  • Extract transaction signing and utils out of the model in @arkecosystem/crypto
  • Extract transaction verification out of the model in @arkecosystem/crypto
  • Make all Slots.* methods static in @arkecosystem/crypto
  • Move interfaces, types and models in @arkecosystem/crypto
  • Move mainnet exceptions to config in @arkecosystem/crypto
  • Remove extraneous Client class in @arkecosystem/crypto
  • Split the Crypto class into Hash and Transaction in @arkecosystem/crypto
  • Replaced @arkecosystem/core-json-rpc with
    @arkecosystem/core-exchange-json-rpc (Use
    @arkecosystem/core-exchange-json-rpc programmatically)

  • Remove unused methods to get/set/reset height from Slots


  • Implement in @arkecosystem/core-state to manage the state of in-memory data
  • Implement a blockchain replay command
  • Save blocks in batches during sync
  • Implement v2/node/fees endpoint
  • Allow setting a vendor field for transactions created via
  • Limit the number of accepted peers per subnet
  • Parallel block download
  • In-memory storage for last N blocks and transactions
  • Require the user to choose a snapshot if the blocks flag is missing in
    @arkecosystem/core commands
  • Integrate end-to-end tests
  • Initial Implementation of core-wallet-api
  • Accept block height to list block transactions in core-api
  • Functional test matchers for core-jest-matchers
  • Don’t trust headers and verify config and plugin connectivity of peers
  • Proxy API calls to core-api until fully developed
  • Add database configuration command to CLI
  • Add command to generate network configuration CLI
  • Initial implementation of core-explorer


  • Insert the genesis block as soon as the database is ready
  • Use public API to auto-configure @arkecosystem/core-tester-cli
  • Parse only the last line of pm2 stdout to avoid parsing faulty input
  • Delete bad rounds after unclean shutdown
  • Divide blocks into smaller chunks for batch processing
  • Remove forged transactions from pool before discarding block
  • Various sync issues with devnet and mainnet
  • Do not suspend peer for AppNotReady
  • Allow use of old and new block IDs via core-json-rpc
  • Assign calculated delegate ranks from temp wallets to prevent wrong ranks on
    boot (#2611)
  • Camelize block keys before bignum transformation for snapshots
  • Deserialize transactions before they leave the pool to remove bad ones
  • Require all properties in schema and handle 404 resources for core-webhooks
  • Check if transactions can still be applied before forging
  • Off by one error in transaction confirmations via API
  • Set the correct channel if core was directly installed with @next
  • Invalid orderBy causes Internal Server Error via API ([#2653)
  • Avoid trying to INSERT duplicates in rounds via core-snapshots
  • Handle failing optional plugins gracefully
  • Correctly purge invalid transactions from disk on start
  • Don’t append duplicate rounds rows to a snapshot
  • Use temporary wallets for transaction validation
  • Correctly display second signature if available via core-api
  • Missing block confirmations on v2 API endpoints
  • Delay transaction purge on start until after StateBuilder finished
  • Check claimed state of peer
  • Ignore overheight blocks and keep forging


  • Replace Joi with AJV for internal validation
  • Remove height difference ban for peers
  • Move mainnet exceptions to config in @arkecosystem/crypto
  • Invalidate blocks with expired transactions
  • Transaction type agnostic wallet bootstrap to support AIP29
  • Return all schema errors in hapi-ajv (#2571)
  • Clean up SocketCluster shutdown and logging (#2560)
  • Remove timeout banning (#2597)
  • Use dayjs as it now has official UTC support
  • Require a minimum of 0 as pubKeyHash
  • Expire transactions that don’t have an expiration


  • Remove peer caching (#2606)
  • Remove peer banning (#2612)
  • Remove coldstart period
  • Remove whitelist access log

Special Thanks

Thanks to all who have helped test the newest Core on the Development Network,
prior to moving it to Public Network, by providing valuable feedback, reporting
issues, and helping to resolve issues by opening pull-requests.

Especially delegate Alessio, who reported a few security vulnerabilities in
testing phase of newest Core (prior to Core v2.4 going on Mainnet), making it
even more secure and robust —
a big thank you

For those running your own servers with ARK Core, if you experience any errors
or issues, please open a Github issue report for easier tracking and resolution:

Don’t forget we also have a development program for all who want to help improve
ARK and earn some ARK:

Follow us on social media ( Twitter | Facebook | Reddit | YouTube), join our community ( Slack | Discord ) and stay tuned to our blog on Medium.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!