Giter Site home page Giter Site logo

bosnet / sebak Goto Github PK

View Code? Open in Web Editor NEW
44.0 18.0 15.0 2.5 MB

SEBAK, the next BOScoin Blockchain

Home Page: https://devteam.blockchainos.org

License: GNU General Public License v3.0

Go 95.98% Shell 3.82% Dockerfile 0.19%
blockchain isaac boscoin blockchainos cryptocurrency consensus-protocol

sebak's Introduction

SEBAK

GoDoc CircleCI CLA assistant codecov FOSSA Status

SEBAK is the core node for BOScoin Tokennet.

Getting Started

Please read our Getting Started page on how to build, setup and run SEBAK.

Contribution

We welcome contributions by the community. Please open issues for any bug you find, or for enhancement requests. Pull requests are also very welcome. Before submitting, please read the contribution guidelines.

License

FOSSA Status

sebak's People

Contributors

anarcher avatar charleslee522 avatar geod24 avatar kfangw avatar leejames00 avatar outsideris avatar spikeekips avatar zzim2x 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

Watchers

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

sebak's Issues

API: Account changes to event stream

This api will produce the latest balance of account. If 'text/event-stream' header is set in request header, the node will continuously send the balance of data as response without disconnecting connection.

Basically the 'content-type' of response will be 'application/json' and the data of BlockAccount must be included.

API: Metrics to event stream

(almost same with #3 )

The metric data will have,

  • number of current ongoing ballots in each boxes
  • validators
  • connected validators
  • etc.

Change '--validator' value to be URL

Requirement is so simple,

--validator GBWCMWDUZK67YNUZ44UPNVFYZRSCCS4OLE6ORWD4ZLI2MVGY4KJDPHMO,https://localhost:12346

to

--validator https://localhost:12346?address=GBWCMWDUZK67YNUZ44UPNVFYZRSCCS4OLE6ORWD4ZLI2MVGY4KJDPHMO

It will be more meaningful and intuitive like --endpoint.

CLI: Node info command interface

Add node info command interface for #9

e.g. sebak node info --endpoint=localhost:12345 (default: localhost) ?

ps) IMHO, The cli can be useful for monitoring and diagnostics. If this issue is not necessity or duplicated, remove or close it freely :-)

Versioning 'Transaction', 'Ballot', etc.

The incoming messages like Transaction, Ballot, etc already have Version field, at this time in development we just leave it blank. We need the version management and versioning itself.

  • How to manage version of messages
  • How to make version(string)

sebak crash when no data is passed as body

curl -k -X POST -H "Content-Type: application/json" https://localhost:2822/message

Node "response"

127.0.0.1 - - [07/Jun/2018:09:01:40 +0000] "POST /message HTTP/2.0" 200 0 "" "curl/7.58.0"
panic: runtime error: slice bounds out of range

goroutine 25 [running]:
github.com/owlchain/sebak/lib.(*NodeRunner).handleMessage(0xc420098750)
	/go/src/github.com/owlchain/sebak/lib/node_runner.go:206 +0xe3c
created by github.com/owlchain/sebak/lib.(*NodeRunner).Start
	/go/src/github.com/owlchain/sebak/lib/node_runner.go:74 +0x51

API: Node info

The basic node information will be produced,

  • node alias
  • node status #10 #11
  • public address
  • endpoint
  • validators
  • connected validators(?)
  • etc.

Machine readable generating keypair's output

In stellar, generating keypair is anoying to launch multiple nodes especially in containers.

Currently generating keypair's output is:

$ sebak key generate
       Secret Seed: SCN4NSV5SVHIZWUDJFT4Z5FFVHO3TFRTOIBQLHMNPAZJ37K5A2YFSCBM
    Public Address: GALQG5SCKCPXUG4ODPMFZJGZ6XBVJTLAJFR7OJKJOJVARA7M4H5SGSOG

It is hard to parse in a command line.

If it prints a format which is machine readable like:

$ sebak key generate --json
{ 
    "secret-seed": "SCN4NSV5SVHIZWUDJFT4Z5FFVHO3TFRTOIBQLHMNPAZJ37K5A2YFSCBM",
    "public-address": "GALQG5SCKCPXUG4ODPMFZJGZ6XBVJTLAJFR7OJKJOJVARA7M4H5SGSOG"
}

It's much better to launch nodes in Docker, Docker compose or Kubernetes.

Use `Amount` consistently for internal representation (& define it)

We currently store monetary amount in a string representation. In addition of being inefficient space wise, it forces conversion to/from string pretty frequently. To add insult to injury, we have an Amount type supposed to represent a monetary amount, which is converted to/from uint64 (and Amount is defined as uint64).

Since Amount is unsigned, it leads to quite some surprising code when doing substractions

Last but not least, I didn't see any place where the relation between 1 Amount and 1 BOSCoin was defined. Most (all?) cryptocurrencies represent monetary amount using integers (e.g. Bitcoin's Satoshi, ETH's Wei...) because dealing with floating point is just too error prone.

So I propose the following:

  • We define Amount as being 1/10^6 BOSCoin (1 million Amount == 1 BOSCoin). This can be changed later, but will allow us to get all the fractional calculations right.
  • We use Amount consistently within the code base. No string, no uint64
  • We cap the maximum balance to 2^64-1 / 10^8 (notice the 10^2 of "margin" for safety). This should leave us plenty of space. I would even say we could cap it to something closer to what the whitepaper V1 defined.
  • We make sure never to represent negative numbers in Amount. Functions should always be passed a positive amount, even if they are going to substract that amount from the account.

Would that make sense to everyone ?

To improve performance, keeping sources in VotingBox

SourceManager manages a source list which has unique sources in the boxes.
The type of source list should be map[/* Source */ string]bool for checking uniqueness.
When a new ballot came, the source from the ballot is inserted to the list. Then, the ballot process finished, it deleted from the list.
While the ballot is in the list, new ballots from the same source are not processed.

It is related with #13(https://github.com/bosnet/sebak/pull/49/files#diff-18683a7542195386fa853b4683d31b7bR38)

Catchup process

When new validator join a network, it will have no blocks, so the newbie should catch up all the blocks from other validators.

Web wallet

  • Basically support main feature of current web wallet
  • and password based 'secret seed' protection

API: Transaction history -to event stream-

(almost same with #3)

This api can be used to check how the transmitted transaction(from client) is finished,

  • tx gets consensus successfully?
  • or tx is failed because of some reason

  • If tx gets consensus successfully, the response will have BlockTransaction data.
  • If failed, the response will have BlockTransactionHistory data.

Redesign 'Checker'

Instead of using 'context', how about making Checker to be struct and value can be stored in properties.

Unreasonable 'Checkpoint` Validation

When transaction stores, it updates the Checkpoint of target account. This causes problem that target account can not know his/her latest checkpoint when he/her tries to make new tranaction.

For example, there are 3 account, a0, a1 and a2, each account has 1 BOS, and send payment transactions between each others.

souce description target a2 balance a2 checkpoint
a0 tx0 sends 1 BOS a2 1 BOS -> 2 BOS chk0
....
a2 tx2 sends 1 BOS a0
....
a1 tx1 sends 1 BOS a2 2 BOS -> 3 BOS chk1

If a2 sends tx2 before tx1 is stored, but tx1 is stoed during tx2 under consensus. Of course, the Checkpoint of tx2 is chk0. What happened?

Current implementation will think, tx2 is invalid, that is, tx2 does not have latest checkpoint, so tx2 will be failed to get consensus.

This problem is caused because the validation just checks whether Checkpoint of transaction is the latest checkpoint of account, or not.

If the validation checks that the Checkpoint exists in transactions of the account and at that Checkpoint the balance is sufficient or not, the problem will be solved.

This is new strategy.

How Checkpoint can be made

checkpoint is: <subtracted>-<added>

  • <subtracted>: hash of last paid transaction, it means balance is subtracted
  • <added>: hash of last added transaction, it means balance is added

Validating Checkpoint

  • if checkpoint is final checkpoint of source, check balance
  • if not, try to find existing checkpoint of source
    • if not, say no
    • if found,
      • check, <subtracted> is same with <added> of final check
        • if not, say no
        • if same, check the balance of that time.

Checkpoint Changes Example

account initial checkpoint
a0 tx0-tx0
a1 tx1-tx1
a2 tx2-tx2
source target transaction checkpoint of transaction checkpoint of source checkpoint of target
a0 a1 tx3 tx0-tx0 a0: tx3-tx3 a1: tx1-tx3
a0 a2 tx4 tx3-tx3 a0: tx4-tx4 a2: tx2-tx4
a1 a0 tx5 tx1-tx3 a1: tx5-tx5 a0: tx4-tx5

Transaction Fee should be collected to 'Common Budget Account'

In SEBAK, there are 2 special accounts,

  • genesis account(most of blockchains does)
  • common budget account

'Common budget account' of our BOScoin is unique feature, it's balance can be used for entire BOScoin network and our community, it's like common goods.

When transaction is finished, it's fee will be collected to 'Common budget' account.

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.