Coder Social home page Coder Social logo

platonnetwork / platon-go Goto Github PK

View Code? Open in Web Editor NEW
448.0 51.0 146.0 228.97 MB

Golang implementation of the PlatON protocol

License: GNU Lesser General Public License v3.0

Dockerfile 0.01% Makefile 0.07% Go 89.60% Shell 0.06% NSIS 0.18% Ruby 0.01% JavaScript 3.47% Assembly 0.73% C 5.15% M4 0.20% Java 0.23% Sage 0.23% Solidity 0.08%
distributed-ledger distributed-computing distributed-systems private-blockchain privacy-preserving bft-protocols wasm

platon-go's Introduction

Go PlatON

Welcome to the PlatON-Go source code repository! This is an Ethereum-based、high-performance and high-security implementation of the PlatON protocol. Most of peculiarities according the PlatON's whitepaper(English|中文) has been developed.

API Reference Go Report Card Build Status codecov version GitHub All Releases

Building the source

The requirements to build PlatON-Go are:

  • OS:Windows10/Ubuntu18.04
  • Golang :version 1.18+
  • cmake :version 3.0+
  • g++&gcc :version 7.4.0+

'cmake' and 'gcc&g++' are usually built-in with Ubuntu

In addition, the following libraries needs to be installed manually

sudo apt install libgmp-dev libssl-dev

Then, clone the repository and download dependency

git clone https://github.com/PlatONnetwork/PlatON-Go.git --recursive

cd PlatON-Go && go mod download

Ubuntu:

make all

Windows:

go run build\ci.go install 

The resulting binary will be placed in '$PlatON-Go/build/bin' .

Getting Started

The project comes with several executables found in the build/bin directory.

Command Description
platon Our main PlatON CLI client. It is the entry point into the PlatON network
platonkey a key related tool.

Generate the keys

Each node requires two pairs of public&private keys, the one is called node's keypair, it's generated based on the secp256k1 curve for marking the node identity and signning the block, and the other is called node's blskeypair, it's based on the BLS_12_381 curve and is used for consensus verifing. These two pairs of public-private key need to be generated by the platonkey tool.

Switch to the directory where contains 'platonkey.exe'(Windows) or 'platonkey'(Ubuntu). Node's keypair(Ubuntu for example):

platonkey genkeypair
PrivateKey:  1abd1200759d4693f4510fbcf7d5caad743b11b5886dc229da6c0747061fca36
PublicKey :  8917c748513c23db46d23f531cc083d2f6001b4cc2396eb8412d73a3e4450ffc5f5235757abf9873de469498d8cf45f5bb42c215da79d59940e17fcb22dfc127

Node's blskeypair::

platonkey genblskeypair
PrivateKey:  7747ec6876bbf8ca0934f05e45917b4213afc5814639355868bbf06d0b3e0f19
PublicKey :  e5eb9915ed2b5fd52cf5ff760873a75a8562956e176968f3cbe5ea2b22e03a7b5efc07fdd5ad66d433b404cb880b560bed6295fa79f8fa649588be02231de2e70a782751dc28dbf516b7bb5d52053b5cdf985d8961a5baafa467e8dda55fe981

Note: The PublicKey generated by the 'genkeypair' command is the NodeID we needed, the PrivateKey is the corresponding node private key, and the PublicKey generated by the 'genblskeypair' command is the node BLS PublicKey, used in the staking and consensus process, PrivateKey is the Node BLS PrivateKey, these two keypairs are common in different operating systems, that is, the public and private keys generated in Windows above, can be used in Ubuntu.

store the two private keys in files:

mkdir -p ./data
touch ./data/nodekey 
echo "{your-nodekey}" > ./data/nodekey
touch ./data/blskey
echo "{your-blskey}" > ./data/blskey

Generate a wallet

platon --datadir ./data account new
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase:
Repeat passphrase:
Address: {lat1anp4tzmdggdrcf39qvshfq3glacjxcd5k60wg9}

Do remember the password

Connect to the PlatON network

Options description
--identity Custom node name
--datadir Data directory for the databases and keystore
--http.addr HTTP-RPC server listening interface (default: "localhost")
--http.port HTTP-RPC server listening port (default: 6789)
--http.api API's offered over the HTTP-RPC interface
--http Enable the HTTP-RPC server
--nodiscover Disables the peer discovery mechanism (manual peer addition)
--nodekey P2P node key file
--cbft.blskey BLS key file

Run the following command to launch a PlatON node connecting to the PlatON's mainnet:

platon --identity "platon" --datadir ./data --port {your-p2p-port} --http.addr 127.0.0.1 --http.port {your-rpc-port} --http.api "platon,net,web3,admin,personal" --http --nodiscover --nodekey ./data/nodekey --cbft.blskey ./data/blskey

OK, it seems that the chain is running correctly, we can check it as follow:

platon attach http://127.0.0.1:6789
Welcome to the PlatON JavaScript console!

instance: PlatONnetwork/platon/v0.7.3-unstable/linux-amd64/go1.18
at block: 26 (Wed, 15 Dec 51802 20:22:44 CST)
 datadir: /home/develop/platon/data
 modules: admin:1.0 debug:1.0 miner:1.0 net:1.0 personal:1.0 platon:1.0 rpc:1.0 txgen:1.0 txpool:1.0 web3:1.0

> platon.blockNumber
29

For more information, please visit our Docs.

Contributing to PlatON-Go

All of codes for PlatON-Go are open source and contributing are very welcome! Before beginning, please take a look at our contributing guidelines. You can also open an issue by clicking here.

Support

If you have any questions or suggestions please contact us at [email protected].

License

The PlatON-Go library (i.e. all code outside of the cmd directory) is licensed under the GNU Lesser General Public License v3.0, also included in our repository in the COPYING.LESSER file.

The PlatON-Go binaries (i.e. all code inside of the cmd directory) is licensed under the GNU General Public License v3.0, also included in our repository in the COPYING file.

platon-go's People

Contributors

awake006 avatar benbaley avatar bglmmz avatar cheng762 avatar chinese-wu avatar cjentzsch avatar davidromy avatar debris avatar fjl avatar gavinxu520 avatar gavofyork avatar holiman avatar hudenian avatar jiangshangqifeng avatar karalabe avatar milan-chen avatar mowind avatar niuxiaojie81 avatar obscuren avatar qcxiao avatar qudonggithub avatar rjl493456442 avatar simonhsj avatar tgerring avatar tracebundy avatar wangzxjiejie avatar weiloy avatar zelig avatar zjsunzone avatar zsfelfoldi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

platon-go's Issues

Run unit test failed

Hello:

I got an error when I ran function ExampleExecute

Path:
~/go/src/github.com/PlatONnetwork/PlatON-Go/life/runtime/runtime_example_test.go

I got following message when I ran the test:

github.com/PlatONnetwork/PlatON-Go/life/resolver
/usr/bin/ld: cannot find -lsoftfloat
/usr/bin/ld: cannot find -lbuiltins
collect2: error: ld returned 1 exit status

Compilation finished with exit code 2

subcommand [platon import] failed

[platon import] subcommand cannot work.

Reason:

// PlatON-Go/cmd/utils/flags.go

func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) {
	....
	....

       // This variable is just a interface, not a implemented object
	var engine consensus.Engine

        ....
	....
}

Double signing report

Double signing report loophole, pledge node forged evidence to report itself, exempt from returning pledge lock period waiting

Add a compile option, choose whether to support MPC or not.

Hi there,

please note that this is an issue tracker reserved for bug reports and feature requests.

For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.

System information

Geth version: geth version
OS & Version: Windows/Linux/OSX
Commit hash : (if develop)

Expected behaviour

Actual behaviour

Steps to reproduce the behaviour

Backtrace

[backtrace]

How wavm worked in PlatON?

Platon used both evm and wavm, I was wondering how wavm worked, especially how to load and store data from the state MPT storage.

  • What are the functions of $_Znwm, $_Znam, $_ZdlPv in wasm file?
  • How to load contract data from MPT tree, which code do this?
  • When and where store back contract data?

Thanks!

Build failed

Hi there,
Build failed with error:
ls: cannot access '/home/hyperchain/PlatON-Go/life/resolver/softfloat': No such file or directory /usr/lib/git-core/git-submodule: 83: /usr/lib/git-core/git-sh-setup: Cannot fork build/build_deps.sh: line 43: cd: /home/hyperchain/PlatON-Go/life/resolver/softfloat/build/Linux-x86_64-GCC: No such file or directory make[6130]: Entering directory '/home/hyperchain/PlatON-Go' build/build_deps.sh ls: cannot access '/home/hyperchain/PlatON-Go/life/resolver/softfloat': No such file or directory /usr/lib/git-core/git-submodule: 7: /usr/lib/git-core/git-submodule: Cannot fork /usr/lib/git-core/git-submodule: 83: /usr/lib/git-core/git-sh-setup: Cannot fork build/build_deps.sh: line 43: cd: /home/hyperchain/PlatON-Go/life/resolver/softfloat/build/Linux-x86_64-GCC: No such file or directory make[6131]: Entering directory '/home/hyperchain/PlatON-Go' build/build_deps.sh make[6131]: fork: Resource temporarily unavailable make[6131]: Leaving directory '/home/hyperchain/PlatON-Go' cp: cannot stat './softfloat.a': No such file or directory

System information

PlatON version: current master branch
OS & Version: Ubuntu 16.04.4


if lock!=nil Constant is true

func (b *BlockTree) commitBlock(ext *blockExt) (*types.Block, *types.Block) {
lock := ext.Parent
if lock == nil {
panic(fmt.Sprintf("%s,%d", ext.Block.Hash().String(), ext.Block.NumberU64()))
}
if lock.Block.Hash() == b.root.Block.Hash() {
return b.root.Block, b.root.Block
}
var commit *blockExt
if lock != nil {
commit = lock.Parent
}
return lock.Block, commit.Block
}

Solving the problem that the WASM virtual machine does not perform 32-byte alignment when processing signed data types causes the SDK (JAVA/JS/Python) to not parse the return value properly.

Hi there,

please note that this is an issue tracker reserved for bug reports and feature requests.

For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.

System information

Geth version: geth version
OS & Version: Windows/Linux/OSX
Commit hash : (if develop)

Expected behaviour

Actual behaviour

Steps to reproduce the behaviour

Backtrace

[backtrace]

Double sign report

After reporting the built-in verification node successfully, the chain does not appear to be out of the block.

Contract's balance is not enough

Hi,

An error occurred when I called CandidateWithdraw:
--Failed to CandidateWithdraw to RefundBalance RefundBalance return err: ="Contract's balance is not enough"

System information
PlatON version: platon 0.6.0
OS & Version: Ubuntu 5.3.1

Adjust the time window period of the CBFT consensus generation block to reduce the fork probability.

Hi there,

please note that this is an issue tracker reserved for bug reports and feature requests.

For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.

System information

Geth version: geth version
OS & Version: Windows/Linux/OSX
Commit hash : (if develop)

Expected behaviour

Actual behaviour

Steps to reproduce the behaviour

Backtrace

[backtrace]

Samurai钱包客户端区块未同步完成时,发起交易失败

Hi there,

please note that this is an issue tracker reserved for bug reports and feature requests.

System information

PlatON version: platon version 0.5.0
OS & Version: Windows/Linux/OSX Windows
Commit hash : (if develop)

Expected behaviour

success

Actual behaviour

fail

Steps to reproduce the behaviour

Backtrace

[backtrace]

blockchain node crash for run personal.newAccount() command

Hi there,

please note that this is an issue tracker reserved for bug reports and feature requests.

System information

PlatON version: platon version
OS & Version: ubuntu16.04
Commit hash : 7deff2d
Branch: master

Expected behaviour

Actual behaviour

platon node crash

Steps to reproduce the behaviour

./platon --identity "platon" --datadir ./data --nodekey ./data/nodekey --rpcaddr 0.0.0.0 --rpcport 6789 --rpcapi "db,eth,net,web3,admin,personal" --rpc --nodiscover console

another terminal console:
./platon attach ipc:./data/platon.ipc
personal.newAccount()

Backtrace

20190531160400

The number of signature nodes can be less than 2f+1

func (cbft *Cbft) verifyPrepareQC(qc *ctypes.QuorumCert) error {
var cb []byte
var err error
if cb, err = qc.CannibalizeBytes(); err != nil {
return err
}
if err = cbft.validatorPool.VerifyAggSigByBA(qc.BlockNumber, qc.ValidatorSet, cb, qc.Signature.Bytes()); err != nil {
return fmt.Errorf("verify prepare qc failed: %v", err)
}
return err
}

func (vp *ValidatorPool) VerifyAggSigByBA(blockNumber uint64, vSet *utils.BitArray, msg, signature []byte) error {
vp.lock.RLock()
validators := vp.currentValidators
if blockNumber <= vp.switchPoint {
validators = vp.prevValidators
}

nodeList, err := validators.NodeListByBitArray(vSet)
if err != nil || len(nodeList) == 0 {
	return fmt.Errorf("not found validators: %v", err)
}
vp.lock.RUnlock()

var pub bls.PublicKey
pub.Deserialize(nodeList[0].BlsPubKey.Serialize())
for i := 1; i < len(nodeList); i++ {
	pub.Add(nodeList[i].BlsPubKey)
}

var sig bls.Sign
err = sig.Deserialize(signature)
if err != nil {
	return err
}
if !sig.Verify(&pub, string(msg)) {
	return errors.New("bls verifies signature fail")
}
return nil

}

error while loading shared libraries: libcurl.so.4

Hi,
Appears when I use platon initialization,
error:
error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory

System information

PlatON version: 0.4
OS & Version: ubuntu16.04
Commit hash : (if develop)

The node connection

Non-consensus nodes cannot connect to consensus nodes via static-nodes.json

Annual issuance

The amount of the tenth annual issuance foundation is incorrect.

There is a null pointer problem with qc parameter

func (cbft *Cbft) verifyPrepareQC(qc *ctypes.QuorumCert) error {
var cb []byte
var err error
if cb, err = qc.CannibalizeBytes(); err != nil {
return err
}
if err = cbft.validatorPool.VerifyAggSigByBA(qc.BlockNumber, qc.ValidatorSet, cb, qc.Signature.Bytes()); err != nil {
return fmt.Errorf("verify prepare qc failed: %v", err)
}
return err
}

Why PlatON wasm vm supports memory malloc functions

Hi, guys

I was wondering why PlotON VM supply functions of "malloc" and "free" memory.

"malloc":  &exec.FunctionImport{Execute: envMalloc, GasCost: envMallocGasCost},
"free":    &exec.FunctionImport{Execute: envFree, GasCost: envFreeGasCost},
"calloc":  &exec.FunctionImport{Execute: envCalloc, GasCost: envCallocGasCost},
"realloc": &exec.FunctionImport{Execute: envRealloc, GasCost: envReallocGasCost},

This struct seems like defined by PlatON. As I have known, memory in WAVM is a byte array, used by program to store string and other values. The memory can be managed by WAVM. So, why PlatON would like to define this Memory structure and supply "malloc" function for smart contracts?

type Memory struct {
	Memory []byte
	Start  int //start position for malloc
	Size   int //memory size for malloc
	tree   []int
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.