Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerKSI committed Feb 12, 2024
2 parents e7e095a + 69e278e commit e7c5718
Show file tree
Hide file tree
Showing 120 changed files with 1,075 additions and 893 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Tests
on: push
on: pull_request

jobs:
chain-test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49
version: v1.55.2
args: --timeout=5m0s
103 changes: 95 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,103 @@
linters-settings:
run:
timeout: 5m
go: '1.19'
skip-files:
- ".*\\.pb\\.go$"
- ".*\\.pb\\.gw\\.\\.go$"
- ".*\\.pulsar\\.go$"

linters:
disable-all: true
enable:
- bodyclose
- depguard
- gofmt
- goimports
- whitespace
- errcheck
- exportloopref
- gci
- gocritic
- gofumpt
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nolintlint
- revive
- staticcheck
- stylecheck
- unconvert
- typecheck
- whitespace

run:
timeout: 5m
go: '1.19'
issues:
exclude-rules:
- text: 'Use of weak random number generator'
linters:
- gosec
- text: 'ST1003:'
linters:
- stylecheck

linters-settings:
gci:
custom-order: true
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/bandprotocol/chain)
gocritic:
disabled-checks:
- regexpMust
- appendAssign
- ifElseChain
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
revive:
rules:
- name: unused-parameter
disabled: true
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] - means include all rules
includes:
# - G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G107 # Url provided to HTTP request as taint input
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
- G114 # Use of net/http serve function that has no support for setting timeouts
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G204 # Audit use of command execution
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G304 # File path provided as taint input
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G307 # Deferring a method which returns an error
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G402 # Look for bad TLS connection settings
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G501 # Import blocklist: crypto/md5
- G502 # Import blocklist: crypto/des
- G503 # Import blocklist: crypto/rc4
- G504 # Import blocklist: net/http/cgi
- G505 # Import blocklist: crypto/sha1
- G601 # Implicit memory aliasing of items from a range statement

53 changes: 23 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,21 @@ BandChain - Decentralized Data Delivery Network<br/><br/>
<p align="center">
<a href="https://docs.bandchain.org/"><strong>Documentation »</strong></a>
<br />
<br/>
<a href="http://docs.bandchain.org/whitepaper/introduction.html">Whitepaper</a>
·
<a href="http://docs.bandchain.org/technical-specifications/obi.html">Technical Specifications</a>
·
<a href="http://docs.bandchain.org/using-any-datasets/">Developer Documentation</a>
·
<a href="http://docs.bandchain.org/client-library/data.html">Client Library</a>
</p>

<br/>

## What is BandChain?

BandChain is a **cross-chain data oracle platform** that aggregates and connects real-world data and APIs to smart contracts. It is designed to be **compatible with most smart contract and blockchain development frameworks**. It does the heavy lifting jobs of pulling data from external sources, aggregating them, and packaging them into the format that’s easy to use and verified efficiently across multiple blockchains.
BandChain is a **cross-chain data oracle platform** that aggregates and connects real-world data and APIs to smart contracts. It is designed to be **compatible with most smart contract and blockchain development frameworks**. It does the heavy lifting jobs of pulling data from external sources, aggregating them, and packaging them into the format that’s easy to use and verifiable efficiently across multiple blockchains.

Band's flexible oracle design allows developers to **query any data** including real-world events, sports, weather, random numbers and more. Developers can create custom-made oracles using WebAssembly to connect smart contracts with traditional web APIs within minutes.

## Installation

### Building from source
Please refer to [this documentation](https://docs.bandchain.org/node-validators/run-node/joining-mainnet/installation) for the most up-to-date installation guide.

## Building from source

We recommend the following for running a BandChain Validator:

Expand All @@ -61,7 +55,7 @@ Use `git` to retrieve BandChain from the [official repo](https://github.com/band

```bash
git clone https://github.com/bandprotocol/chain
cd chain && git checkout v2.3.0
cd chain && git checkout v2.5.4
make install
```

Expand All @@ -70,28 +64,27 @@ make install
Using `bandd version` command to verify that your `bandd` has been build successfully.

```
bandd version --long
name: bandchain
server_name: bandd
version: 2.3.0
commit: 4fe19638b33043eed4dec9861cda40962fb5b2a7
build_tags: ledger
go: go version go1.18.3 darwin/amd64
version: 2.5.4
commit: e6548bbf4793829bb8e711e5ed89ba4afc710ded
build_tags: netgo,ledger
go: go version go1.19.1 darwin/amd64
build_deps:
...
```

### Setting Up Yoda — The Oracle Daemon

BandChain validators are also responsible for responding to oracle data requests. Whenever someone submits a request message to BandChain, the chain will autonomously choose a subset of active oracle validators to perform the data query.

The validators are chosen submit a report message to BandChain within a given timeframe as specified by a chain parameter (100 blocks in mainnet). We provide a program called yoda to do this task for you. For more information on the data request process, please see [here](https://docs.bandchain.org/whitepaper/system-overview.html#oracle-data-request).

Yoda uses an external executor to resolve requests to data sources. Currently, it supports [AWS Lambda](https://aws.amazon.com/lambda/) and [Google Cloud Function](https://cloud.google.com/functions) (through the REST interface). In future releases, `yoda` will support more executors and allow you to specify multiple executors to add redundancy.
If you are using Mac ARM architecture (M1, M2) and face the issue of GMP library, you can run this.
```
brew update && brew install gmp
sudo ln -s /opt/homebrew/lib/libgmp.10.dylib /usr/local/lib/
```

You also need to set up `yoda` and activate oracle status. Here’s the [documentation](https://github.com/bandprotocol/bandchain/wiki/Instruction-for-apply-to-be-an-oracle-validator-on-Guanyu-mainnet) to get started.
## Useful scripts for development

That’s it! You can verify that your validator is now an oracle provider via cli by using ` bandd query oracle validator <your validator address>`. Your yoda process must be responding to oracle requests assigned to your node. If the process misses a request, your oracle provider status will automatically get deactivated and you must send MsgActivate to activate again after a 10-minute waiting period and make sure that yoda is up.
- `scripts/generate_genesis.sh` to create/reset the default genesis file
- `scripts/start_bandd.sh` to start the bandd binary
- `scripts/start_yoda.sh` to start yoda with reporter(s)

## Resources

Expand All @@ -105,19 +98,19 @@ That’s it! You can verify that your validator is now an oracle provider via cl
- [Cosmoscan Mainnet](https://cosmoscan.io)
- [Big Dipper](https://band.bigdipper.live/)
- Testnet:
- [CosmoScan Testnet](https://laozi-testnet2.cosmoscan.io)
- [CosmoScan Testnet](https://laozi-testnet6.cosmoscan.io)

## Community

- [Official Website](https://bandprotocol.com)
- [Telegram](https://100.band/tg)
- [Telegram](https://t.me/bandprotocol)
- [Twitter](https://twitter.com/bandprotocol)
- [Developer Discord](https://100x.band/discord)
- [Developer Discord](https://discord.com/invite/3t4bsY7)

## License & Contributing

BandChain is licensed under the terms of the GPL 3.0 License unless otherwise specified in the LICENSE file at module's root.

We highly encourage participation from the community to help with D3N development. If you are interested in developing with D3N or have suggestion for protocol improvements, please open an issue, submit a pull request, or [drop as a line].
We highly encourage participation from the community to help with D3N development. If you are interested in developing with D3N or have suggestions for protocol improvements, please open an issue, submit a pull request, or [drop as a line].

[drop as a line]: mailto:[email protected]
[drop us a line]: mailto:[email protected]
14 changes: 7 additions & 7 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ type HandlerOptions struct {

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
return nil, sdkerrors.ErrLogic.Wrap("account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
return nil, sdkerrors.ErrLogic.Wrap("bank keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, sdkerrors.ErrLogic.Wrap("sign mode handler is required for ante builder")
}
if options.OracleKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "oracle keeper is required for AnteHandler")
return nil, sdkerrors.ErrLogic.Wrap("oracle keeper is required for AnteHandler")
}
if options.IBCKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "IBC keeper is required for AnteHandler")
return nil, sdkerrors.ErrLogic.Wrap("IBC keeper is required for AnteHandler")
}
if options.StakingKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "Staking keeper is required for AnteHandler")
return nil, sdkerrors.ErrLogic.Wrap("Staking keeper is required for AnteHandler")
}
if options.GlobalfeeKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "Globalfee keeper is required for AnteHandler")
return nil, sdkerrors.ErrLogic.Wrap("Globalfee keeper is required for AnteHandler")
}

sigGasConsumer := options.SigGasConsumer
Expand Down
22 changes: 15 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ func NewBandApp(
if err != nil {
panic(err)
}

// Initialize params keeper and module subspaces.
app.ParamsKeeper = initParamsKeeper(
appCodec,
Expand Down Expand Up @@ -340,6 +341,7 @@ func NewBandApp(
Bech32MainPrefix,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// wrappedBankerKeeper overrides burn token behavior to instead transfer to community pool.
app.BankKeeper = bandbankkeeper.NewWrappedBankKeeperBurnToCommunityPool(
bankkeeper.NewBaseKeeper(
Expand All @@ -351,13 +353,15 @@ func NewBandApp(
),
app.AccountKeeper,
)

app.StakingKeeper = stakingkeeper.NewKeeper(
appCodec,
keys[stakingtypes.StoreKey],
app.AccountKeeper,
app.BankKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.MintKeeper = mintkeeper.NewKeeper(
appCodec,
keys[minttypes.StoreKey],
Expand All @@ -367,6 +371,7 @@ func NewBandApp(
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.DistrKeeper = distrkeeper.NewKeeper(
appCodec,
keys[distrtypes.StoreKey],
Expand All @@ -378,6 +383,7 @@ func NewBandApp(
)
// DistrKeeper must be set afterward due to the circular reference between banker-staking-distr.
app.BankKeeper.SetDistrKeeper(&app.DistrKeeper)

app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec,
legacyAmino,
Expand Down Expand Up @@ -488,7 +494,6 @@ func NewBandApp(
scopedICAHostKeeper,
app.MsgServiceRouter(),
)

icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)

Expand Down Expand Up @@ -543,7 +548,7 @@ func NewBandApp(
/**** Module Options ****/
// NOTE: we may consider parsing `appOpts` inside module constructors. For the moment
// we prefer to be more strict in what arguments the modules expect.
var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))
skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants))

// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
Expand Down Expand Up @@ -609,11 +614,11 @@ func NewBandApp(
oracleModule,
globalfee.NewAppModule(app.GlobalfeeKeeper),
)

// NOTE: Oracle module must occur before distr as it takes some fee to distribute to active oracle validators.
// NOTE: During begin block slashing happens after distr.BeginBlocker so that there is nothing left
// over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant.

// TODO: Recheck all Begin/End block logic order
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
Expand All @@ -639,6 +644,7 @@ func NewBandApp(
consensusparamtypes.ModuleName,
globalfeetypes.ModuleName,
)

app.mm.SetOrderEndBlockers(
crisistypes.ModuleName,
govtypes.ModuleName,
Expand All @@ -664,6 +670,7 @@ func NewBandApp(
consensusparamtypes.ModuleName,
globalfeetypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
// NOTE: The genutils module must also occur after auth so that it can access the params from auth.
Expand Down Expand Up @@ -771,6 +778,7 @@ func NewBandApp(
app.ScopedIBCKeeper = scopedIBCKeeper
app.ScopedTransferKeeper = scopedTransferKeeper
app.ScopedOracleKeeper = scopedOracleKeeper
app.ScopedICAHostKeeper = scopedICAHostKeeper

return app
}
Expand Down Expand Up @@ -967,7 +975,7 @@ func initParamsKeeper(
paramsKeeper.Subspace(minttypes.ModuleName)
paramsKeeper.Subspace(distrtypes.ModuleName)
paramsKeeper.Subspace(slashingtypes.ModuleName)
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable())
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck
paramsKeeper.Subspace(crisistypes.ModuleName)
paramsKeeper.Subspace(ibcexported.ModuleName)
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
Expand Down Expand Up @@ -1002,9 +1010,9 @@ func (app *BandApp) setupUpgradeStoreLoaders() {
return
}

for _, upgrade := range Upgrades {
for idx, upgrade := range Upgrades {
if upgradeInfo.Name == upgrade.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades))
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &Upgrades[idx].StoreUpgrades))
}
}
}
Loading

0 comments on commit e7c5718

Please sign in to comment.