Skip to content

Commit

Permalink
Merge branch 'main' into roman/improved-pow6
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Dec 14, 2022
2 parents 3a7a39c + 5df8cd0 commit 79beaae
Show file tree
Hide file tree
Showing 44 changed files with 1,506 additions and 1,300 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#3611](https://github.com/osmosis-labs/osmosis/pull/3611),[#3647](https://github.com/osmosis-labs/osmosis/pull/3647) Introduce osmocli, to automate thousands of lines of CLI boilerplate
* [#3634](https://github.com/osmosis-labs/osmosis/pull/3634) (Makefile) Ensure correct golang version in make build and make install. (Thank you @jhernandezb )
* [#3712](https://github.com/osmosis-labs/osmosis/pull/3712) replace `osmomath.BigDec` `Power` with `PowerInteger`
* [#3711](https://github.com/osmosis-labs/osmosis/pull/3711) Use Dec instead of Int for additive `ErrTolerace` in `osmoutils`.

## v13.0.0

Expand Down
2 changes: 1 addition & 1 deletion app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (s *KeeperTestHelper) BuildTx(
// StateNotAltered validates that app state is not altered. Fails if it is.
func (s *KeeperTestHelper) StateNotAltered() {
oldState := s.App.ExportState(s.Ctx)
s.Commit()
s.App.Commit()
newState := s.App.ExportState(s.Ctx)
s.Require().Equal(oldState, newState)
}
Expand Down
8 changes: 8 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

downtimedetector "github.com/osmosis-labs/osmosis/v13/x/downtime-detector"
downtimetypes "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/types"
ibchooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks"
ibcratelimit "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit"
ibcratelimittypes "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types"
Expand Down Expand Up @@ -104,6 +106,7 @@ type AppKeepers struct {
AuthzKeeper *authzkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
DistrKeeper *distrkeeper.Keeper
DowntimeKeeper *downtimedetector.Keeper
SlashingKeeper *slashingkeeper.Keeper
IBCKeeper *ibckeeper.Keeper
ICAHostKeeper *icahostkeeper.Keeper
Expand Down Expand Up @@ -197,6 +200,10 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
)
appKeepers.DistrKeeper = &distrKeeper

appKeepers.DowntimeKeeper = downtimedetector.NewKeeper(
appKeepers.keys[downtimetypes.StoreKey],
)

slashingKeeper := slashingkeeper.NewKeeper(
appCodec,
appKeepers.keys[slashingtypes.StoreKey],
Expand Down Expand Up @@ -595,6 +602,7 @@ func KVStoreKeys() []string {
stakingtypes.StoreKey,
minttypes.StoreKey,
distrtypes.StoreKey,
downtimetypes.StoreKey,
slashingtypes.StoreKey,
govtypes.StoreKey,
paramstypes.StoreKey,
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"

_ "github.com/osmosis-labs/osmosis/v13/client/docs/statik"
downtimemodule "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/module"
"github.com/osmosis-labs/osmosis/v13/x/epochs"
"github.com/osmosis-labs/osmosis/v13/x/gamm"
ibc_hooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks"
Expand All @@ -54,6 +55,7 @@ var AppModuleBasics = []module.AppModuleBasic{
capability.AppModuleBasic{},
staking.AppModuleBasic{},
mint.AppModuleBasic{},
downtimemodule.AppModuleBasic{},
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
append(
Expand Down
6 changes: 6 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"

downtimemodule "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/module"
downtimetypes "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/types"

ibc_hooks "github.com/osmosis-labs/osmosis/v13/x/ibc-hooks"

"github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -125,6 +128,7 @@ func appModules(
mint.NewAppModule(appCodec, *app.MintKeeper, app.AccountKeeper, app.BankKeeper),
slashing.NewAppModule(appCodec, *app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, *app.StakingKeeper),
distr.NewAppModule(appCodec, *app.DistrKeeper, app.AccountKeeper, app.BankKeeper, *app.StakingKeeper),
downtimemodule.NewAppModule(*app.DowntimeKeeper),
staking.NewAppModule(appCodec, *app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
upgrade.NewAppModule(*app.UpgradeKeeper),
wasm.NewAppModule(appCodec, app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
Expand Down Expand Up @@ -175,6 +179,7 @@ func orderBeginBlockers(allModuleNames []string) []string {
// IBChost came after staking, before superfluid.
// TODO: Come back and delete this line after testing the base change.
ord.Sequence(stakingtypes.ModuleName, ibchost.ModuleName, superfluidtypes.ModuleName)
// We leave downtime-detector un-constrained.
// every remaining module's begin block is a no-op.
return ord.TotalOrdering()
}
Expand Down Expand Up @@ -204,6 +209,7 @@ func OrderInitGenesis(allModuleNames []string) []string {
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
downtimetypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
Expand Down
3 changes: 2 additions & 1 deletion app/upgrades/v14/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
store "github.com/cosmos/cosmos-sdk/store/types"

"github.com/osmosis-labs/osmosis/v13/app/upgrades"
downtimetypes "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/types"
protorevtypes "github.com/osmosis-labs/osmosis/v13/x/protorev/types"
valsetpreftypes "github.com/osmosis-labs/osmosis/v13/x/valset-pref/types"
)
Expand All @@ -15,7 +16,7 @@ var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{valsetpreftypes.StoreKey, protorevtypes.StoreKey},
Added: []string{valsetpreftypes.StoreKey, protorevtypes.StoreKey, downtimetypes.StoreKey},
Deleted: []string{},
},
}
1 change: 0 additions & 1 deletion cmd/osmosisd/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
config.P2P.Seeds = strings.Join(seeds, ",")
config.P2P.MaxNumInboundPeers = 320
config.P2P.MaxNumOutboundPeers = 40
config.Consensus.TimeoutCommit = 2 * time.Second
config.Mempool.Size = 10000
config.StateSync.TrustPeriod = 112 * time.Hour
config.FastSync.Version = "v0"
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/CosmWasm/wasmd v0.29.2-osmo-v13
github.com/cosmos/cosmos-proto v1.0.0-alpha8
github.com/cosmos/cosmos-sdk v0.45.11
github.com/cosmos/cosmos-sdk v0.46.6
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/iavl v0.19.4
github.com/cosmos/ibc-go/v3 v3.4.0
Expand All @@ -27,6 +27,7 @@ require (
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.24
github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b
github.com/tidwall/btree v1.6.0
go.uber.org/multierr v1.8.0
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e
Expand Down Expand Up @@ -94,7 +95,7 @@ require (
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/cosmos/btcutil v1.0.4
github.com/cosmos/btcutil v1.0.5
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
github.com/cosmos/ledger-go v0.9.3 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44=
github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU=
github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
github.com/cosmos/cosmos-proto v1.0.0-alpha8 h1:d3pCRuMYYvGA5bM0ZbbjKn+AoQD4A7dyNG2wzwWalUw=
github.com/cosmos/cosmos-proto v1.0.0-alpha8/go.mod h1:6/p+Bc4O8JKeZqe0VqUGTX31eoYqemTT4C1hLCWsO7I=
github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k=
Expand Down Expand Up @@ -1091,6 +1091,8 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR
github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY=
github.com/tetafro/godot v1.4.11 h1:BVoBIqAf/2QdbFmSwAWnaIqDivZdOV0ZRwEm6jivLKw=
github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8=
github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg=
github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI=
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down
24 changes: 2 additions & 22 deletions osmomath/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
tickLogOf2 = MustNewDecFromStr("0.000144262291094554178391070900057480")
// initialized in init() since requires
// precision to be defined.
twoBigDec BigDec
twoBigDec BigDec = MustNewDecFromStr("2")
)

// Decimal errors
Expand All @@ -68,8 +68,6 @@ func init() {
for i := 0; i <= Precision; i++ {
precisionMultipliers[i] = calcPrecisionMultiplier(int64(i))
}

twoBigDec = NewBigDec(2)
}

func precisionInt() *big.Int {
Expand Down Expand Up @@ -423,7 +421,7 @@ func (d BigDec) ApproxRoot(root uint64) (guess BigDec, err error) {
guess, delta := OneDec(), OneDec()

for iter := 0; delta.Abs().GT(SmallestDec()) && iter < maxApproxRootIterations; iter++ {
prev := guess.Power(root - 1)
prev := guess.PowerInteger(root - 1)
if prev.IsZero() {
prev = SmallestDec()
}
Expand All @@ -437,24 +435,6 @@ func (d BigDec) ApproxRoot(root uint64) (guess BigDec, err error) {
return guess, nil
}

// Power returns a the result of raising to a positive integer power
func (d BigDec) Power(power uint64) BigDec {
if power == 0 {
return OneDec()
}
tmp := OneDec()

for i := power; i > 1; {
if i%2 != 0 {
tmp = tmp.Mul(d)
}
i /= 2
d = d.Mul(d)
}

return d.Mul(tmp)
}

// ApproxSqrt is a wrapper around ApproxRoot for the common special case
// of finding the square root of a number. It returns -(sqrt(abs(d)) if input is negative.
func (d BigDec) ApproxSqrt() (BigDec, error) {
Expand Down
Loading

0 comments on commit 79beaae

Please sign in to comment.