Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
fix: bumpup lfb-sdk; integrate ostracon (#26)
Browse files Browse the repository at this point in the history
* fix: bumpup lfb-sdk; integrate ostracon

* fix: changelog

* fix: integration test failure

* fix: integration test failure

* fix: integration test failure
  • Loading branch information
Woosang Son authored Sep 10, 2021
1 parent f289ed2 commit f6c9deb
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 312 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Breaking Changes
* (sdk) (auth) [\#16](https://github.com/line/lfb/pull/16) Introduce sig block height for the new replay protection
* (ostracon/sdk) [\#26](https://github.com/line/lfb/pull/26) Use vrf-based consensus, address string treatment

## [gaia v4.0.4] - 2021-03-15
Initial lfb is based on the tendermint v0.34.9+, cosmos-sdk v0.42.0+, gaia v4.0.4
Expand Down
15 changes: 9 additions & 6 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (app *LinkApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
allowedAddrsMap := make(map[string]bool)

for _, addr := range jailAllowedAddrs {
_, err := sdk.ValAddressFromBech32(addr)
err := sdk.ValidateValAddress(addr)
if err != nil {
log.Fatal(err)
}
Expand All @@ -79,15 +79,16 @@ func (app *LinkApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
// withdraw all delegator rewards
dels := app.StakingKeeper.GetAllDelegations(ctx)
for _, delegation := range dels {
valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress)
err := sdk.ValidateValAddress(delegation.ValidatorAddress)
if err != nil {
panic(err)
}

delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress)
valAddr := sdk.ValAddress(delegation.ValidatorAddress)
err = sdk.ValidateAccAddress(delegation.DelegatorAddress)
if err != nil {
panic(err)
}
delAddr := sdk.AccAddress(delegation.DelegatorAddress)
_, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) // nolint: errcheck
}

Expand Down Expand Up @@ -115,14 +116,16 @@ func (app *LinkApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [

// reinitialize all delegations
for _, del := range dels {
valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress)
err := sdk.ValidateValAddress(del.ValidatorAddress)
if err != nil {
panic(err)
}
delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress)
valAddr := sdk.ValAddress(del.ValidatorAddress)
err = sdk.ValidateAccAddress(del.DelegatorAddress)
if err != nil {
panic(err)
}
delAddr := sdk.AccAddress(del.DelegatorAddress)
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
}
Expand Down
2 changes: 1 addition & 1 deletion cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func TestLFBCreateValidator(t *testing.T) {
defer n.Cleanup()

barAddr := f.KeyAddress(keyBar)
barVal := sdk.ValAddress(barAddr)
barVal := barAddr.ToValAddress()

consPubKey := sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, ed25519.GenPrivKey().PubKey())

Expand Down
4 changes: 2 additions & 2 deletions cli_test/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestMultiValidatorAddNodeAndPromoteValidator(t *testing.T) {
}

barAddr := f2.KeyAddress(keyBar)
barVal := sdk.ValAddress(barAddr)
barVal := barAddr.ToValAddress()

sendTokens := sdk.TokensFromConsensusPower(10)
{
Expand All @@ -129,7 +129,7 @@ func TestMultiValidatorAddNodeAndPromoteValidator(t *testing.T) {
pubkey, err := privVal.GetPubKey()
require.NoError(t, err)

tmValPubKey, err := cryptocodec.FromTmPubKeyInterface(pubkey)
tmValPubKey, err := cryptocodec.FromOcPubKeyInterface(pubkey)
require.NoError(t, err)
consPubKey := sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, tmValPubKey)

Expand Down
6 changes: 3 additions & 3 deletions cli_test/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,9 @@ func (f *Fixtures) KeysShow(name string, flags ...string) keyring.KeyOutput {
// KeyAddress returns the SDK account address from the key
func (f *Fixtures) KeyAddress(name string) sdk.AccAddress {
ko := f.KeysShow(name)
accAddr, err := sdk.AccAddressFromBech32(ko.Address)
err := sdk.ValidateAccAddress(ko.Address)
require.NoError(f.T, err)
return accAddr
return sdk.AccAddress(ko.Address)
}

// ___________________________________________________________________________________
Expand Down Expand Up @@ -1374,7 +1374,7 @@ func newValidator(f *Fixtures, cfg testnet.Config, appCfg *srvconfig.Config, ctx
logger := log.NewNopLogger()
var err error
if cfg.EnableLogging {
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
logger = log.NewOCLogger(log.NewSyncWriter(os.Stdout))
logger, err = ostflags.ParseLogLevel("info", logger, ostcfg.DefaultLogLevel)
require.NoError(f.T, err)
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/lfb/cmd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa

config.SetRoot(clientCtx.HomeDir)

addr, err := sdk.AccAddressFromBech32(args[0])
var addr sdk.AccAddress
err := sdk.ValidateAccAddress(args[0])
if err != nil {
inBuf := bufio.NewReader(cmd.InOrStdin())
keyringBackend, err := cmd.Flags().GetString(flags.FlagKeyringBackend)
Expand All @@ -68,6 +69,8 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
}

addr = info.GetAddress()
} else {
addr = sdk.AccAddress(args[0])
}

coins, err := sdk.ParseCoinsNormalized(args[1])
Expand Down
2 changes: 1 addition & 1 deletion cmd/lfb/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func InitTestnet(

valTokens := sdk.TokensFromConsensusPower(100)
createValMsg, err := stakingtypes.NewMsgCreateValidator(
sdk.ValAddress(addr),
addr.ToValAddress(),
valPubKeys[i],
sdk.NewCoin(sdk.DefaultBondDenom, valTokens),
stakingtypes.NewDescription(nodeDirName, "", "", "", ""),
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.15

require (
github.com/gorilla/mux v1.8.0
github.com/line/lfb-sdk v1.0.0-init.1.0.20210720072128-577c2c01cf60
github.com/line/ostracon v0.34.9-0.20210610071151-a52812ac9add
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210413083915-5bb60e117524
github.com/line/lfb-sdk v1.0.0-init.1.0.20210910004202-84db942b6643
github.com/line/ostracon v0.34.9-0.20210906083237-658e85d9b160
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210824011847-fcfa67dd3c70
github.com/prometheus/client_golang v1.11.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.3.1
Expand Down
Loading

0 comments on commit f6c9deb

Please sign in to comment.