GithubHelp home page GithubHelp logo

bandprotocol / chain Goto Github PK

View Code? Open in Web Editor NEW
117.0 117.0 40.0 10.39 MB

BandChain blockchain reference implementation

License: GNU General Public License v3.0

Dockerfile 0.14% Makefile 0.74% Go 98.56% Shell 0.36% Python 0.20%

chain's Introduction

Band Chain

Blockchain Platform for Decentralize Data Curation

C++17 Tendermint Apache-2.0

Band Chain is a decentralized, permissionless blockchain implementation based on Band Protocol for decentralised data curation. We incentivise trusted, high-quality data sharing in online community via token staking and bonding curve mechanism. See https://bandprotocol.com for more info.

Running with Docker

Getting the containers up and running

The most convenient way to run Band Chain is to use Docker. Under docker directory, you'll find the docker-compose.yaml file which defines the two containers needed to run the blockchain. Make sure you have Docker installed, then run:

$> cd docker
$> docker-compose up -d

The -d tag signals docker-compose to run the containers in detached mode. This allows us to observe the logs from both bandchain and tendermint container individually.

Note that you can change ubuntu's apt-get mirror by changing the country_code in the docker-compose.yaml file

Attaching to the containers

At this point the containers should be up and running. To observe each container, simply attach to it by using the command:

$> docker attach bandchain
   # OR
$> docker attach tendermint

To detach yourself back, use Ctrl+P Ctrl+Q key combination.

Stopping the containers

Under docker directory, run:

$> docker-compose down

Running on Local Machine

Installing Dependencies

To build locally, Band Chain requires the following dependencies. Be sure to have them available in your local system (versions as listed in CMakeLists.txt).

Installing RocksDB

  • OS X:

    • Install via homebrew.
    • run brew install rocksdb
  • Linux - Ubuntu

    • Install Dependencies
      apt-get update
      apt-get -y install build-essential libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
    • Install rocksdb by source code:
      git clone https://github.com/facebook/rocksdb.git
      cd rocksdb & make shared_lib && make install-shared

Building the Source Code

Starting off, you'll have to configure ProtoBuff and cmake by running:

$> protoc --cpp_out=. abci/abci.proto
$> mkdir build
$> cd build
$> cmake ..

Then to compile, under the same build directory, run:

$> make

Running the node

To run the node, make sure you have Tendermint v0.22.3 on your machine, then start it with:

$> tendermint init # First time only
$> tendermint node

Note that you need to keep the Tendermint session running at all time. tmux and similar tools are handy for this purpose.

Then we can run the core Band Chain logic via:

$> cd build
$> ./band -v

Basic Usage

Typically all the commands to Band Chain are sent through Tendermint ABCI, which is exposed on http://localhost:26657.

The transactions need to be generated in a specific way. Please check out the ๐Ÿ› ๏ธ Official Python Client and ๐Ÿ› ๏ธ Official Javascript Client to start interacting with the blockchain.

License

Band Protocol is released under the terms of Apache License 2.0. See LICENSE for more information or see http://www.apache.org/licenses/LICENSE-2.0.

chain's People

Contributors

alessio avatar benzbeeb avatar colmazia avatar dependabot-preview[bot] avatar dependabot[bot] avatar evilpeach avatar faddat avatar kissadada avatar mnguyen-io avatar nghuyenthevinh2000 avatar ntchjb avatar p-rial avatar perimeko avatar prin-r avatar rav-11 avatar rogerksi avatar satawatnack avatar songwongtp avatar sorawit avatar tansawit avatar taobun avatar thebevrishot avatar traviolus 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

chain's Issues

withdrawal-rewards using Ledger fails when using --commission

When running band CLI withdrawal-rewards with --commission and a ledger, the transaction fails.

signatures: [] confirm transaction before signing and broadcasting [y/N]: y code: 4 codespace: sdk data: "" events: [] gas_used: "0" gas_wanted: "0" height: "0" info: "" logs: [] raw_log: 'signature verification failed; please verify account number (12), sequence (103) and chain-id (laozi-mainnet): unauthorized' timestamp: "" tx: null txhash: 22B4443D567CF8BC0513C0A4D8D9C35A91F6DA3221F6A84EA89900E77BF85FF6

This same command works if we remove the --commission flag.

Better gas error management inside `PrepareRequest`

Context

At Desmos we would like to integrate the usage of Band oracles through IBC in order to allow our users to connect their centralized social network accounts (eg. Twitter, Instagram, GitHub, etc) to their decentralized Desmos profile. In order to do this, we have already created the proper data sources as well as the oracle script.

Yesterday we were testing the integration from a local Desmos chain towards the Laozi Band testnet. While performing some test requests we realized that there is a case in which any blockchain that sends a packet towards Band might not receive any response and thus is left hanging.

This happens particularly when we send a OracleRequestPacketData which does not contain a sufficient amount of gas to execute the transaction. Then, the following happens:

  1. The execute gas is subtracted from the overall gas amount.
  2. Since the overall gas amount is not sufficient, the ctx.GasMeter().ConsumeGas method panics with ErrOutOfGas.
  3. The whole transaction is marked as invalid, but no acknowledgment is sent to the source chain (ie Desmos).
  4. The relayer will continuously try to accept the packet inside the Band chain, but the transaction will continue to fail.

This causes an infinite loop inside which the relayer continues to pay the fees to receive the packet, the packet is never executed properly and no acknowledgment is sent back.

You can see a lot of ReceivePacket transactions here.

Proposed solution

While exploring the Band codebase, I found that you often use the following method:

ctx.GasMeter().ConsumeGas

As described above, this will panic if the overall gas is not sufficient to consume the amount given.

What I propose is to create a new method named safeConsumeGas that acts as follows:

// safeConsumeGas consumes the given amount of gas associating it with the provided descriptor.
// If the gas consumption would error, returns such error instead of panicking.
func (k Keeper) safeConsumeGas(ctx sdk.Context, amount sdk.Gas, descriptor string) error {
	a := ctx.GasMeter().GasConsumed()
	b := amount

	// check overflow
	if math.MaxUint64-a < b {
		return sdkerrors.Wrapf(sdkerrors.ErrLogic, "gas overflow in location: %s", descriptor)
	}

	// check if the gas consume will panic
	futureConsumed := a + b
	if futureConsumed > ctx.GasMeter().Limit() {
		return sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %s", descriptor)
	}

	ctx.GasMeter().ConsumeGas(amount, descriptor)
	return nil
}

Then, inside PrepareRequest all the ctx.GasMeter().ConsumeGas usages should be replaced as follows:

// Consume gas for data requests.
err := k.safeConsumeGas(ctx, askCount*k.PerValidatorRequestGas(ctx), "PER_VALIDATOR_REQUEST_FEE")
if err != nil {
	return 0, err
}

This approach would allow the PrepareRequest method to fail gracefully if any problem related to the gas is raised. Also, it would allow the OnRecvPacket method to properly handle the error and return an ErrorAcknowledgement to the source chain.

Unable to build `2.4.1` or `2.4.0`

It looks like there's a dependency conflict from cosmos-sdk v0.45.10 with go-metrics on these two versions.

NOTE: I am able to successfully build 2.3.6 without issue ๐Ÿ‘๐Ÿป

Go version:

go version go1.16.6 linux/amd64

Steps to reproduce:

  1. git clone https://github.com/bandprotocol/chain
  2. cd chain
  3. git checkout 2d59c56296dd2a4c8bd919d0a278315213a50561 * Release hash for 2.4.1
  4. make install

Error log:

#20 0.244 Cloning into 'chain'...
#20 7.565 Note: checking out '2d59c56296dd2a4c8bd919d0a278315213a50561'.
#20 7.565 
#20 7.565 You are in 'detached HEAD' state. You can look around, make experimental
#20 7.565 changes and commit them, and you can discard any commits you make in this
#20 7.565 state without impacting any branches by performing another checkout.
#20 7.565 
#20 7.565 If you want to create a new branch to retain commits you create, you may
#20 7.565 do so (now or later) by using -b with the checkout command again. Example:
#20 7.565 
#20 7.565   git checkout -b <new-branch-name>
#20 7.565 
#20 7.567 HEAD is now at 2d59c562 Merge pull request #264 from bandprotocol/bump-cosmos-sdk
#20 7.757 go install -mod=readonly -tags "ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=bandchain -X github.com/cosmos/cosmos-sdk/version.AppName=bandd -X github.com/cosmos/cosmos-sdk/version.Commit=2d59c56296dd2a4c8bd919d0a278315213a50561 -X github.com/cosmos/cosmos-sdk/version.Version=2.4.1 -X "github.com/cosmos/cosmos-sdk/version.BuildTags=ledger"' ./cmd/bandd
#20 69.06 go: github.com/cosmos/[email protected] requires
#20 69.06       github.com/armon/[email protected]: missing go.sum entry; to add it:
#20 69.06       go mod download github.com/armon/go-metrics
#20 69.09 Makefile:24: recipe for target 'install' failed
#20 69.09 make: *** [install] Error 1

When ibc/v2 is upgraded?

Hello,
I am building a cosmwasm contract that will interact with band through ibc.
However, current ibc version of band is somewhat lacking.
When will band protocol is updated to ibc/v2? and testnet as well?

Ability to delegate oracle re-activation to another account

Given the propensity for the band oracle to deactivate if the wind blows in the wrong direction, we end up running bandcli tx oracle activate on a semi regularly basis (once or twice a month).

Given proper key handling, our platforms team do not have the ability to reactivate the oracle - as this requires possesion of the key that controls the entire validator (including the ability to withdraw / send funds, etc.)

It would be hugely beneficial, if in the next iteration, if the validator account could sign a tx to (optionally) authorise a separate sub account (with no other permissions), that could re-enable the oracle in the event of a failure (much like Terra delegates permission to their oracle feeder account).

txj

ใ‚‚ใ†ใญใ“ ใฎใ‚ฎใƒƒใƒˆ ใƒใƒ–ใ‹ใชใ‚“ใ‹ txt ใพใจใ‚ใ‚Šใคใ„ใฆใใ‚‹ ไฝ•ใ‹ใ‚ใ‚‹ใ‚“ใงใ—ใ‚‡ใ† ่ณ‡็”ฃใŒใ‚ใ‚‹ใ‚“ใงใ—ใ‚‡ใ†่ฟ”ใ›ใ‚ˆ
ใƒˆใƒฉใ‚นใƒˆ ใƒ€ใ‚คใ‚นใ‚ซใ‚ธใƒŽใงใ‚ธใƒฃใƒƒใ‚ฏใƒใƒƒใƒˆใ‚’ๅ‡บใ—ใŸ ใฉใ“่กŒใฃใŸใฎ LINE ใ‚‚ LINE ๅ‰ใฎใ‚ขใƒ‰ใƒฌใ‚น0x4ใ‹ใ‚‰ๅง‹ใพใฃใฆๆœ€ๅพŒใฏeใ‹cใ ใฃใŸใ‚ˆใ†ใชๆฐ—ใŒใ™ใ‚‹ ใ™ใ”ใ„ ๅ‰ใฎใ‚ขใƒ‰ใƒฌใ‚น ใ‚คใƒผใ‚ตใƒชใ‚ขใƒ ใฎใ‚ขใƒ‰ใƒฌใ‚น ใญ

Can not use txs/encode api for encodeTx

Hi, is there a big upgrade for band?

I used to encode tx using this api txs/encode and sent it successfully in testnet2 and guanyu-mainnet
But it got error when in laozi mainnet and I did not change anything
The api returned this error:

  "code": 12,
  "message": "Not Implemented",
  "details": [
  ]
}

How can I use the txs/encode now? I need to build tx body offline and use rest api to send, looking forward to your reply

Issues installing bandd

Hello,
i have some issues installing bandd.
I cloned the chain repository and executed cd which worked fine.
Then i executed "make install" which downloaded many things but where i also got these issues and results.
How do i solve this ?
Feedback and solutions would be really nice.
Thanks

go install -mod=readonly -tags "ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=bandchain -X github.com/cosmos/cosmos-sdk/version.AppName=bandd -X github.com/cosmos/cosmos-sdk/version.Commit=4fe19638b33043eed4dec9861cda40962fb5b2a7 -X github.com/cosmos/cosmos-sdk/version.Version=2.3.0 -X "github.com/cosmos/cosmos-sdk/version.BuildTags=ledger"' ./cmd/bandd
..\go\pkg\mod\github.com\rcrowley\[email protected]\runtime.go:5:2: found packages pprof (elf.go) and proto (proto.go) in C:\Users\anton\go\GO Language\src\runtime\pprof
make: *** [Makefile:24: install] Error 1

Withdraw reward emit wrong address to reset reward

We emiited withdraw address to update reward that makes reward counter update on withdraw address, not a delegator address that makes we show the wrong amount of reward on withdraw address, and didn't reset reward of delegator address.

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.