hyperhyperspace / pulsar

Pulsar: The Web Blockchain
MIT License
5 stars 2 forks source link
blockchain blockchain-technology cryptocurrency dapp typescript vdf vrf web3

Pulsar: The Web Blockchain

GOAL: A Proof-of-Stake Blockchain that can fully run its the consensus on the browser with support for different CPUs speed and tolerance to Winner-Takes-All, Nothing-At-Stake and other attacks.

Installation

Run console version (Hawking Testnet):

NodeJS: Expected version "^16.14.0 || >=18.0.0". Also install TypeScript if not already available:

npm install -g typescript

To build, create a new local keypair (coinbase) and start mining in a new network:

wget https://raw.githubusercontent.com/hyperhyperspace/pulsar/main/boot-pulsar.sh;
chmod +x ./boot-pulsar.sh;
sh ./boot-pulsar.sh;

To run/mine with an existing network use option --network= or -n and create a new local coinbase keypair wallet:

yarn start --network="butcher fire flag"

To run/mine with an existing coinbase keypair wallet use option --coinbase= or -c:

yarn start --coinbase="depth curious pound"

Develop & Testing:

yarn test  # and good to test

Setup for AWS Linux

# 0) git
sudo yum update -y
sudo yum install git -y
# 1) nodejs
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install node
# 2) yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
# 3) extras
npm install typescript -g
npm install microbundle-crl -g
# 4) start a new console

Features

Specification

Roadmap

Browser Wallet client available

Stake delegation for convenience

Montecarlo Testnet (Testnet1) has no transactions.

Core (Las Vegas Testnet [Testnet2] and Monaco Testnet [Testnet3] )

  1. transfer(to,amount): only if balance(sender) >= amount.
  2. increaseAllowance(to,amount).
  3. decreaseAllowance(to,amount).
  4. transferFrom(from,to,amount): only if allowance(from,sender) >= amount.

Convenience

  1. stake(amount): moves to staked balance the amount of sender.
  2. unstake(amount): this transaction frees the funds after 7 days.
  3. delegateStake(to,amount): moves to delegatedStake of to the amount of sender.
  4. undelegateStake(to,amount): this transaction frees the funds after 7days.
  5. delayedTransfer(to,amount,delay): lock amount until blocktime+delay seconds happens.

Advanced

  1. lockedTransfer(to,amount,hash): lock amount until an unlock happens. Generates an unique txId.
  2. unlockTransfer(txId,x,sig): only transfers txId.amount locked before if H(x) == txId.hash and if sender == txId.to.
  3. lockTimedTransfer(to,amount,delay): lock amount until blocktime+delay seconds happens, then it expires. Generates an unique txId.
  4. unlockTimedTransfer(txId,x,sig): only transfers txId.amount locked before time blocktime+delay and if sender == txId.to.
  5. initMultiSig(n,[sign_1, ..., sign_n],m): makes sender address to become a multisig wallet with n signataries, and needing m signataries to validate a transfer.
  6. multiSigTransfer(from,to,amount): if sender is in the list of signataries of multisig from then the signer is voting to execute the transfer, if #signers >= m then the transfer gets executed.
  7. multiSigReset(from): for sender in the list of signataries, the resetting of the wallet is voted, if #signers >= m then all incomplete votings on the address from are removed.

References

  1. Proof-of-Stake Longest Chain Protocols: Security vs Predictability https://arxiv.org/abs/1910.02218

Appendix A: FAQ

How can you use Longest-Chain like Nakamoto Consensus on a PoS blockchain? Are there formal barries to this?

There is a paper called Formal Barriers to Longest-Chain Proof-of-Stake Protocols describing limitations to Longest-Chain Fork-choice on Proof-of-Stake blockchains. Technically we are using something we call Average Fastest Chain as a Fork-choice, then is not exactly Nakamoto Consensus's Longest-Chain. We choose the change with the smallest average number of VDF steps per block. In the same line, this fork-choice if more difficult to attack with attacks of common types explore in bibliography (On the Instability of Bitcoin Without the Block Reward).

How can you deal with Winner-Takes-All and discrepancies (variance) in CPUs speeds (and miner implementation speeds)?

There is something called Speed Ratio that is part of the consensus. This ratio allows an exponential penalty on the linear difficulty that the miner face based on the random slot that the miner recieved. The exponential penalty (within certain bounds) avoids faster miners jumping from one slot to the previous one, avoiding faster miners to propose more blocks than their stake allows (in average).