Twitter: the Night Is Darkest Before the Dawn?

This week we invite you to discuss Vitalik’s statements, have a closer look at the value of blockchain and be surprised by Gwyneth Paltrow

I'm not sure that blockchain 'determines' what we agree on so much as it provides more options for agreement than were previously available via matching & filtering valuable data. Perhaps mechanically 'resolving' a dispute only counts as half an agreement?

  • @GwynethPaltrow: ‘Great piece with @billbarhydt on @goop today’
  • @iamjosephyoung: ‘I've been in crypto since 2013. The only thing I can say with absolute certainty is, when you think you know the short-term trend of the market, you really don't. Crypto never fails to amaze me’
  • @asglidden: ‘The problem with all these 'X on the blockchain' is that you need reliable data. But a blockchain is a mechanism for resolving intersubjective 'truths', not a mechanism for resolving *objective* truths. They determine what we agree on, not what's real.’
  • @zooko: ‘As 'Plasma' Stalls, SNARKs Become New Hope for Scaling Ethereum Now' — via @CoinDesk

Related news

Why we stopped using ‘npm start’ for running our blockchain core’s child processes

You shouldn’t start applications through npm when you have child processes natively supported by Node.js. In this article, we will provide a list of best practices for Node.js applications with a code snippet that outlines the core problem and shows you how to reproduce the issue in 3 steps. In short, we stopped using npm start to run our blockchain’s core and instead opted for using the native node command.Introduction to npm and its most well-known command ‘npm start’.Npm is the go-to node package manager when you are working on a JavaScript project. It allows you to install other people’s code packages into your own project so you don’t have to code everything you need from scratch. Npm also became famous because of its industry-wide usage of script commands that can be entered in the shell to start your application. Of course, the most well-known command is npm start that acts as a wrapper for node app.js.Our challenge: npm runs app.js files as a child process of npm.However, what many don’t know is that while using npm start to trigger node app.js, npm is actually running your app.js file as a child process of npm which manages this. In 99% of the cases, you shouldn’t care about this, but things can get tricky when working with child processes in your own project. Can you feel the inception happening here? #child-process-inceptionIf you want to know more about Lisk first, check out this short explainer clip and our documentation!To give you a better understanding of how this is relevant to our “npm vs node” problem, let’s talk about how we are running Lisk Core. For those who don’t know what Lisk Core is, essentially, it is a program that implements the Lisk Protocol which includes consensus, block creation, transaction handling, peer communication, etc. Every machine must set it up to run a node that allows for participation in the network.Intro to PM2, a production process manager for Node.js apps.In our case, we use PM2 to restart the application upon failure. PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.A few weeks ago, we decided to provide the ability to run the http_api module as a child process to improve the overall efficiency of the Lisk Core application while using the same allocated resources.Rationale behind the decision to run http_api module as a child process.The idea behind this decision was mainly funded by the fact that functionally isolated components can form the basis of a multi-process application, in order to utilize the potential of multiple hardware cores of the physical processor if available. Also, to design each component in a resilient way to tackle brittleness of the multi-processing. This means that a failure of one component will have minimal impact on other components and that components can recover individually. More information about child processes can be found in our proposal to introduce a new flexible, resilient and modular architecture for Lisk Core.We were not able to gracefully exit Lisk Core with npm.While implementing child processes for the http_api module, Lightcurve Backend Developer Lucas Silvestre discovered that Lisk Core was not exiting gracefully while running the http_api module as a child process using PM2. This resulted in a tricky situation where the http_api kept on running in the background whenever the main process (Lisk Core) crashed.Whenever this happens, PM2 will attempt to recover the Lisk Core process. However, this would spawn a new http_api process which was not possible as the port was already in use because of the cleanup process not being called. The resulted in PM2 not being able to restore the application which is a big issue when running a blockchain node that is part of the network. In this case, the user has to manually restart the blockchain node which we absolutely want to avoid.Running Lisk Core with node commandThis issue made us aware of the difference between npm and node and made us reconsider the way we were running Lisk Core. Previously, we just accepted the npm start industry standard as the go-to way of running an application.Later, we found the best practices provided by the docker-node GitHub repository dedicated to Dockerizing Node.js applications. Here, a clear warning message can be found about the usage of npm inside of a Dockerfile or any other higher-level application management tool like PM2.“When creating an image, you can bypass the package.json’s start command and bake it directly into the image itself. First off this reduces the number of processes running inside of your container. Secondly, it causes exit signals such as SIGTERM and SIGINT to be received by the Node.js process instead of npm swallowing them.”Whenever we tried to exit Lisk Core or the application crashed, a SIGINT signal is sent to the application. In Node.js, you can listen for this signal and execute a cleanup function in order to gracefully exit the application. In our case, we are removing various listeners and pass the SIGINT signal to the child process in order to exit this one gracefully as well.As stated by docker-node, npm swallows this signal and does not trigger our listeners for the SIGINT signal causing the application to not being able to clean up gracefully. That’s also the reason why the http_api module kept running inside of PM2.Nick Parson, an expert when it comes to running Node applications with PM2 also mentions the fact that it is important to gracefully shut down your application in order to maximize robustness and enable fast startup (no downtime) when using PM2.Termination signals: what are SIGKILL, SIGTERM and SIGINT?We have to dive quite deep to find out what these signals are about. These signals are part of a collection of signals to tell a process to terminate, actually many more exist, and can be found in the documentation provided by under section 24.2.2 Termination Signals.SIGKILL: “The SIGKILL signal is used to cause immediate program termination. It cannot be handled or ignored, and is therefore always fatal. It is also not possible to block this signal.”SIGTERM: “The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL, this signal can be blocked, handled, and ignored. It is the normal way to politely ask a program to terminate.” Interesting to know that the shell command kill generates SIGTERM by default.SIGINT: “The SIGINT (‘program interrupt’) signal is sent when the user types the INTR character (normally C-c).” Developers will probably be more familiar with the CTRL/CMD+C command to interrupt a running process in the shell.Moving Docker and PM2 to Node.This made us decide to get rid of npm start and replacing it by the node command. The start command was being used in both the Dockerfile as the PM2 run file.The following image shows a snippet of the typical ENTRYPOINT for Docker. Previously, this would contain ENTRYPOINT ["npm", “start"] . This file can be found now in our new Lisk Core repository which is extracted from the Lisk-SDK Monorepo.Lisk-SDK Dockerfile.Also, the same applies to the pm2-lisk.json file which contains the PM2 configuration for starting Lisk Core. The script property now contains the relative path to the index file.Lisk-SDK pm2-lisk.jsonLearn how to reproduce the issue in 3 steps.We can find a cool snippet created by GitHub user EvanTahler addressing the above-mentioned issue. Let’s reproduce this!Step 1. Create package.json and app.jsTo emulate this issue, you need to create two files (package.json and app.js ) in the same directory. Make sure you have Node.js version 10.x or higher installed on your machine to run the snippet with the node command. As we don’t need any code dependencies, we don’t have to install anything else.Package.json clarification — The snippet will print a dot every 0.5 seconds and listens for the SIGINT and SIGTERM signals. Once one of the two termination signals is received, we will delay the shutdown by 5 seconds (5 * 1000ms) and print out “bye!”.Before running this snippet, I want to show you how a killed process is indicated in your terminal when hitting CTRL/CMD+C. You can notice it by the ^C characters.Shows Lisk Core running for exactly 17 minutes after getting killed with the SIGINT signal.Step 2. Run the snippet with nodeNow we know how the SIGINT is represented in our terminal, let’s start the snippet with node app.js. Let it run for 5 seconds, and hit CTRL/CMD+C. You will see that the kill signal is properly handled by Node and waits for 5 more seconds before shutting down.Step 3. Run the snippet with npm startHowever, when we run the snippet with npm start, you will notice two kill signals being received. As we now know, the start command will run node app.js as a child process. So, when receiving ^C, it will try to exit the npm process and pass this termination signal to the child which causes the problem that the main process exits but the child is still active for 5 more seconds.As explained before, this will give all sorts of problems when you try to listen for termination signals while running applications with npm start, especially when operating child processes.Interested in learning how to set up and run your own Lisk node? More information can be found in the Lisk Core documentation on the website. You can choose between the binary setup which is the default (and most simple) installation technique. Other options include running Lisk Core with Docker to support other platforms or for more advanced users, it is possible to build from Lisk Core.Because of this “child process inception”, the http_api module could not gracefully exit and kept on running. The only way to stop this process is by using a shell command that kills all Node processes: sudo killall node (or target the specific process ID to be killed). Luckily, this could be easily resolved by using node to start the application.Best Practices for Handling Node.js ApplicationsFelix Geisendörfer, an early contributor of Node.js, makes it very clear how to handle crashed applications:Source: Node.js Best Practices SlideShareWhat does the above teach us? Avoid spinning up your application through npm start but use node instead. Also, if something goes wrong, exit the process gracefully and accept it. Felix recommends using higher level tools like PM2 to deal with recovering and restarting the application.We learned from this that you not always should take standards for granted. It is sometimes better to keep things simple and run it with a simple node command.To conclude what we did at Lisk, we decided to solve the issue by changing the npm start command to node src/index in both the PM2 run configuration and Dockerfile. Now, upon receiving a SIGINT signal, the node process receives this directly and can communicate the SIGINT signal to its child processes so every process can be exited gracefully.Therefore, PM2 can easily restart the application without any downtime. Running our application via this setup allows us to deploy a more stable application which is utterly important for creating a stable blockchain network.Lisk empowers individuals to create a more decentralized, efficient and transparent global economy. We welcome you to join us in our mission:NewsletterLisk ResearchLisk.chatRedditWhy we stopped using ‘npm start’ for running our blockchain core’s child processes was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.

Major Differences Between Cosmos and Polkadot; Two Distinct Philosophy of Inter-Blockchain

Cosmos and Polkadot adopt similar strategies to realize blockchain interoperability, but there are subtle differences in protocol and design, respectively. Individual vs Overall Security Cosmos and Polkadot work in two completely different security modes.In short, Polkadot works as follows: Parachains (parallel chains) are block chains in Polkadot networks. These Parachains have their own state machines, they make their own rules and they are individual block producers (collators, proofreaders). Each Parachain is actually an independent state machine that can take advantage of any type of unique function, consensus algorithms, transaction cost structures, and so on. In Polkadot networks, all Parachains are subchains of chain called Relay Chain. Relay chain has its own consensus algorithm, GRANDPA consensus, which can quickly finalize blocks on Parachain.The validator in Relay chain has the final say on any state change made by a parachain. The validator may constantly reject blocks created by collators (proofreader, block producer) from a particular parachain and permanently prevent the parachain process from being included in the global state. So Polkadot attempts to reduce the occurrence of this problem by disrupting the verifier, so that the verifier can randomly verify the parachain, reducing the possibility that a particular verifier will review a particular parachain. In addition, Polkadot also has another type of verifier called Fishermen, who constantly checks whether the verifier has malicious behavior. In contrast, the structure of Cosmos networks is totally different: In Cosmos networks, each blockchain is independent and self-protective, rather than using a local/global mode like Polkadot to ensure security. Each block chain will run its own consensus mechanism, and the verifier of each chain is only responsible for ensuring the security of the chain. Compared with Polkadot structure, we can find that the biggest difference of Cosmos is that the security of each zone (independent blockchain) is guaranteed only by the verifier of this blockchain. If a zone wants high security, it will need to  add more validators, which may be difficult for small applications. Governance & Membership The second difference between Polkadot and Cosmos is their governance and membership. In Polkadot networks, there is only one Relay Chain and a certain number of Parachains (supported by the Verifier of Relay Chain). Currently, the Polkadot network is expected to accommodate 100 parachains, but this number may increase or decrease in the future. The Polkadot network allocates parachain slots through an auction mechanism — the highest bidder will be able to obtain a slot by locking DOT (the original token of the Polkadot network) in a PoS system. On the other hand, there is no fixed membership rule in Cosmos networks – anyone can build a Hub chain or a Zone chain. Hub itself is a sovereign (control) block chain, built to connect with other blockchains. One example is the Cosmos Hub recently built by the Tendermint team, Another example is the Iris Hub  that is planned to link those block chains working mainly in China and other parts of Asia. In Polkadot networks, governance decisions are determined by the number of DOT tokens held by voters. There will be a formal voting mechanism on the chain, but this has not been decided yet. Cosmos networks do not have a unitary governance process. Each Hub chain and Zone chain has its own governance process, and there is no central rule set applicable to the whole block chain network. Another difference between Polkadot and Cosmos is their structure and design goals in Inter-blockchain communication protocols. Polkadot’s goal is to deliver arbitrary messages between Parachains, which means that Parachain A can invoke smart contracts in Parachain B, transfer token between two chains, or any other type of communication. On the other hand, Cosmos focuses on asset transfer among blockchain, which is a simpler protocol. Polkadot uses the concept of Fishermen, a bounty hunter who monitors malicious activities on the Polkadot network. In a sense, this is the “second line of defense” of the Polkadot network against malicious acts. If the validator of a particular Parachain determines an invalid block, Fishermen can submit a proof to Relay Chain and effectively roll back the entire state of the Polkadot network and related Parachains. Cosmos, by contrast, takes a completely different approach to inter-blockchain communication. Because each chain has its own verifier in Cosmos network, ther may be some “malicious” Zone chains containing collusion verifiers, which means Zone A needs to trust the verifiers in Cosmos Hub and Zone B when one Zone chain wants to communicate with another Zone chain. Substrate vs Cosmos SDK Both Polkadot and Cosmos provide a software development package, namely Substrate  and Cosmos SDK. The purpose of these two development packages is to make it easier for developers to start building their own blockchain, including various instant modules (including governance module), staking module, authentication module and so on. The main difference between the two development packages is that Cosmos SDK supports the Go language, while Substrate is more flexible as it supports any WASM (Web Assembly) compatible language. Both packages are new frameworks for building blockchain and will be equipped with more function in the next few years. If  the problem of data availability in Polkadot can be solved, inter-blockchain messaging under shared security will become easier. But Cosmos has more flexible for specific projects, such as Binance. And Cosmos focuses on providing easier asset transfers.

Hot news

By continuing to browse, you agree to the use of cookies. Read Privacy Policy to know more or withdraw your consent.