Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into another-pass-through-app.go
Browse files Browse the repository at this point in the history
  • Loading branch information
sorawit committed Jul 1, 2020
2 parents acbe2df + 410e0d4 commit c5ff4a1
Show file tree
Hide file tree
Showing 65 changed files with 1,196 additions and 1,128 deletions.
24 changes: 24 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v ✰ Thanks for creating a PR! ✰
v Before smashing the submit button please review the checkboxes.
v If a checkbox is n/a - please still include it but + a little note why
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review.
-->

Fixed: #XXXX

## Implementation details

---

Please ensure the following requirements are met before submitting a pull request:

- [ ] The pull request is targeted against the correct target branch
- [ ] The pull request is linked to an issue with appropriate discussion and an accepted design OR is linked to a spec that describes the work.
- [ ] The pull request includes a description of the implementation/work done in detail.
- [ ] The pull request includes any and all appropriate unit/integration tests
- [ ] You have added a relevant changelog entry to `CHANGELOG_UNRELEASED.md`
- [ ] You have re-reviewed the files affected by the pull request (e.g. using the `Files changed` tab in the Github PR explorer)
11 changes: 11 additions & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
### Chain

- (impv) [\#2093](https://github.com/bandprotocol/bandchain/pull/2093) Add missing pieces on app.go + some refactor and comments.
- (feat) [\#2111](https://github.com/bandprotocol/bandchain/pull/2111) Introduce the notion of active validators who are performing oracle tasks.
- (bug) [\#2110](https://github.com/bandprotocol/bandchain/pull/2074) Set `bandoracled` max capacity of event subscription channel.
- (impv) [\#2106](https://github.com/bandprotocol/bandchain/pull/2106) Implement emitter handle MsgCreateDataSource/OracleScript.
- (impv) [\#2074](https://github.com/bandprotocol/bandchain/pull/2074) Use rolling block hash as seed for validator sampling.
- (impv) [\#2104](https://github.com/bandprotocol/bandchain/pull/2104) Update default gas/size consensus params and clean up cmd code.
- (chore) [\#2084](https://github.com/bandprotocol/bandchain/pull/2084) Rename ValidatorReportInto to ReportInfo.
- (chore) [\#2082](https://github.com/bandprotocol/bandchain/pull/2082) Reorder, reword, and remove unused error codes.
- (impv) [\#2080](https://github.com/bandprotocol/bandchain/pull/2080), [\#2107](https://github.com/bandprotocol/bandchain/pull/2107) Set count state on genesis.go and remove default values from getters.
- (feat) [\#2022](https://github.com/bandprotocol/bandchain/pull/2022) Initial implementation of BandChain emitter/flusher.
- (chore) [\#2060](https://github.com/bandprotocol/bandchain/pull/2060) Remove unused /bandchain/file endpoints and custom swagger from bandcli REST.

Expand All @@ -30,8 +38,11 @@

### Oracle Binary Encoding (OBI)

- (impv) [#1947](https://github.com/bandprotocol/bandchain/pull/2065) Remove obi.js build process

### Helpers

### MISC

- (chore) [\#2105](https://github.com/bandprotocol/bandchain/pull/2105) Add pull request template to describe PR.
- (chore) [\#2068](https://github.com/bandprotocol/bandchain/pull/2068) Remove `band-consumer` from repository.
17 changes: 2 additions & 15 deletions chain/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=bandchain \

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'

all: lint install
all: install

install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/bandd
Expand Down Expand Up @@ -50,20 +50,7 @@ release: go.sum
go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify

update-swagger-docs:
$(BINDIR)/statik -src=client/lcd/swagger-ui -dest=client/lcd -f -m
@if [ -n "$(git status --porcelain)" ]; then \
echo "\033[91mSwagger docs are out of sync!!!\033[0m";\
exit 1;\
else \
echo "\033[92mSwagger docs are in sync\033[0m";\
fi

lint:
golangci-lint run
@find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
go mod verify
touch go.sum

test:
@go test -mod=readonly $(PACKAGES)
Expand Down
6 changes: 3 additions & 3 deletions chain/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func NewBandApp(
app.CrisisKeeper = crisis.NewKeeper(crisisSubspace, invCheckPeriod, app.SupplyKeeper, auth.FeeCollectorName)
app.SlashingKeeper = slashing.NewKeeper(cdc, keys[slashing.StoreKey], &stakingKeeper, slashingSubspace)
app.UpgradeKeeper = upgrade.NewKeeper(skipUpgradeHeights, keys[upgrade.StoreKey], cdc)
app.OracleKeeper = oracle.NewKeeper(cdc, keys[oracle.StoreKey], filepath.Join(viper.GetString(cli.HomeFlag), "files"), oracleSubspace, stakingKeeper)
app.OracleKeeper = oracle.NewKeeper(cdc, keys[oracle.StoreKey], filepath.Join(viper.GetString(cli.HomeFlag), "files"), auth.FeeCollectorName, oracleSubspace, app.SupplyKeeper, &stakingKeeper, app.DistrKeeper)
// Register the proposal types.
govRouter := gov.NewRouter()
govRouter.
Expand Down Expand Up @@ -215,13 +215,13 @@ func NewBandApp(
// 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.
app.mm.SetOrderBeginBlockers(
upgrade.ModuleName, mint.ModuleName, distr.ModuleName, slashing.ModuleName,
upgrade.ModuleName, mint.ModuleName, oracle.ModuleName, distr.ModuleName, slashing.ModuleName,
evidence.ModuleName, staking.ModuleName,
)
// NOTE: The oracle module must occur before staking so that jailed validators due to report
// downtime will not get included in staking module's ValidatorUpdate set.
app.mm.SetOrderEndBlockers(
crisis.ModuleName, gov.ModuleName, oracle.ModuleName, staking.ModuleName,
crisis.ModuleName, gov.ModuleName, staking.ModuleName, oracle.ModuleName,
)
// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
Expand Down
9 changes: 5 additions & 4 deletions chain/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ type GenesisState map[string]json.RawMessage
func NewDefaultGenesisState() GenesisState {
cdc := MakeCodec()
denom := "uband"

// Get default genesis states of the modules we are to override.
authGenesis := auth.DefaultGenesisState()
stakingGenesis := staking.DefaultGenesisState()
mintGenesis := mint.DefaultGenesisState()
govGenesis := gov.DefaultGenesisState()
crisisGenesis := crisis.DefaultGenesisState()
slashingGenesis := slashing.DefaultGenesisState()

// Override the genesis parameters.
authGenesis.Params.TxSizeCostPerByte = 5
stakingGenesis.Params.BondDenom = denom
stakingGenesis.Params.HistoricalEntries = 1000
mintGenesis.Params.BlocksPerYear = 10519200 // target 3-second block time
Expand All @@ -46,10 +48,9 @@ func NewDefaultGenesisState() GenesisState {
slashingGenesis.Params.DowntimeJailDuration = 60 * 10 * time.Second // 10 minutes
slashingGenesis.Params.SlashFractionDoubleSign = sdk.NewDecWithPrec(5, 2) // 5%
slashingGenesis.Params.SlashFractionDowntime = sdk.NewDecWithPrec(1, 4) // 0.01%

return GenesisState{
genutil.ModuleName: genutil.AppModuleBasic{}.DefaultGenesis(),
auth.ModuleName: auth.AppModuleBasic{}.DefaultGenesis(),
auth.ModuleName: cdc.MustMarshalJSON(authGenesis),
bank.ModuleName: bank.AppModuleBasic{}.DefaultGenesis(),
supply.ModuleName: supply.AppModuleBasic{}.DefaultGenesis(),
staking.ModuleName: cdc.MustMarshalJSON(stakingGenesis),
Expand Down
3 changes: 0 additions & 3 deletions chain/cmd/bandcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ func txCmd(cdc *amino.Codec) *cobra.Command {
authcmd.GetEncodeCommand(cdc),
authcmd.GetDecodeCommand(cdc),
flags.LineBreak,
multiDelegateCommand(cdc),
flags.LineBreak,
)

// add modules' tx commands
Expand All @@ -140,7 +138,6 @@ func txCmd(cdc *amino.Codec) *cobra.Command {
// NOTE: details on the routes added for each module are in the module documentation
// NOTE: If making updates here you also need to update the test helper in client/lcd/test_helper.go
func registerRoutes(rs *lcd.RestServer) {
// TODO: Bring back full bandclient from client folder
bandclient.RegisterRoutes(rs.CliCtx, rs.Mux)
client.RegisterRoutes(rs.CliCtx, rs.Mux)
authrest.RegisterTxRoutes(rs.CliCtx, rs.Mux)
Expand Down
79 changes: 0 additions & 79 deletions chain/cmd/bandcli/mutlidelegate.go

This file was deleted.

8 changes: 2 additions & 6 deletions chain/cmd/bandd/gends.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/tendermint/tendermint/libs/cli"

"github.com/bandprotocol/bandchain/chain/x/oracle"
otypes "github.com/bandprotocol/bandchain/chain/x/oracle/types"
"github.com/bandprotocol/bandchain/chain/x/oracle/types"
)

// AddGenesisDataSourceCmd returns add-data-source cobra Command.
Expand All @@ -37,25 +37,21 @@ func AddGenesisDataSourceCmd(ctx *server.Context, cdc *codec.Codec, defaultNodeH
if err != nil {
return err
}

genFile := config.GenesisFile()
appState, genDoc, err := genutil.GenesisStateFromGenFile(cdc, genFile)
if err != nil {
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
}

oracleGenState := oracle.GetGenesisStateFromAppState(cdc, appState)
oracleGenState.DataSources = append(oracleGenState.DataSources, otypes.NewDataSource(
oracleGenState.DataSources = append(oracleGenState.DataSources, types.NewDataSource(
owner, args[0], args[1], filename,
))

appState[oracle.ModuleName] = cdc.MustMarshalJSON(oracleGenState)
appStateJSON := cdc.MustMarshalJSON(appState)
genDoc.AppState = appStateJSON
return genutil.ExportGenesisFile(genDoc, genFile)
},
}

cmd.Flags().String(cli.HomeFlag, defaultNodeHome, "node's home directory")
return cmd
}
10 changes: 3 additions & 7 deletions chain/cmd/bandd/genos.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/bandprotocol/bandchain/chain/pkg/filecache"
"github.com/bandprotocol/bandchain/chain/x/oracle"
otypes "github.com/bandprotocol/bandchain/chain/x/oracle/types"
"github.com/bandprotocol/bandchain/chain/x/oracle/types"
"github.com/bandprotocol/bandchain/go-owasm/api"
)

Expand All @@ -33,7 +33,7 @@ func AddGenesisOracleScriptCmd(ctx *server.Context, cdc *codec.Codec, defaultNod
if err != nil {
return err
}
compiledData, err := api.Compile(data, otypes.MaxCompiledWasmCodeSize)
compiledData, err := api.Compile(data, types.MaxCompiledWasmCodeSize)
if err != nil {
return err
}
Expand All @@ -42,25 +42,21 @@ func AddGenesisOracleScriptCmd(ctx *server.Context, cdc *codec.Codec, defaultNod
if err != nil {
return err
}

genFile := config.GenesisFile()
appState, genDoc, err := genutil.GenesisStateFromGenFile(cdc, genFile)
if err != nil {
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
}

oracleGenState := oracle.GetGenesisStateFromAppState(cdc, appState)
oracleGenState.OracleScripts = append(oracleGenState.OracleScripts, otypes.NewOracleScript(
oracleGenState.OracleScripts = append(oracleGenState.OracleScripts, types.NewOracleScript(
owner, args[0], args[1], filename, args[2], args[3],
))

appState[oracle.ModuleName] = cdc.MustMarshalJSON(oracleGenState)
appStateJSON := cdc.MustMarshalJSON(appState)
genDoc.AppState = appStateJSON
return genutil.ExportGenesisFile(genDoc, genFile)
},
}

cmd.Flags().String(cli.HomeFlag, defaultNodeHome, "node's home directory")
return cmd
}
Loading

0 comments on commit c5ff4a1

Please sign in to comment.