Skip to content

Commit

Permalink
apply ethermint reduction
Browse files Browse the repository at this point in the history
for this, applied custom ibc-go and cosmos-sdk to updated initialStake as sdk.Int
  • Loading branch information
zsystm committed Aug 10, 2023
1 parent e47ac8d commit bed5d90
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
8 changes: 0 additions & 8 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import (
// Get flags every time the simulator is run
func init() {
simapp.GetSimulatorFlags()
sdk.DefaultPowerReduction = sdk.NewIntFromUint64(1_000_000)
liquidstakingtypes.ChunkSize = sdk.TokensFromConsensusPower(250_000, sdk.DefaultPowerReduction)
}

type StoreKeysPrefixes struct {
Expand Down Expand Up @@ -113,8 +111,6 @@ func TestAppImportExport(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()

sdk.DefaultPowerReduction = sdk.NewIntFromUint64(1000000)

app := NewCanto(
logger,
db,
Expand Down Expand Up @@ -253,8 +249,6 @@ func TestAppStateDeterminism(t *testing.T) {
numTimesToRunPerSeed := 5
appHashList := make([]json.RawMessage, numTimesToRunPerSeed)

sdk.DefaultPowerReduction = sdk.NewIntFromUint64(1000000)

for i := 0; i < numSeeds; i++ {
config.Seed = rand.Int63()
for j := 0; j < numTimesToRunPerSeed; j++ {
Expand Down Expand Up @@ -324,8 +318,6 @@ func TestAppSimulationAfterImport(t *testing.T) {
require.NoError(t, os.RemoveAll(dir))
}()

sdk.DefaultPowerReduction = sdk.NewIntFromUint64(1000000)

app := NewCanto(
logger,
db,
Expand Down
18 changes: 10 additions & 8 deletions app/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ func AppStateRandomizedFn(
numAccs := int64(len(accs))
genesisState := NewDefaultGenesisState()

var initalStake, numInitiallyBonded int64
var initialStake sdk.Int
var numInitiallyBonded int64
appParams.GetOrGenerate(
cdc,
simappparams.StakePerAccount,
&initalStake,
r,
func(r *rand.Rand) { initalStake = r.Int63n(1e12) },
cdc, simappparams.StakePerAccount, &initialStake, r,
func(r *rand.Rand) {
sdkReductionInt := sdk.NewInt(r.Int63n(1e12))
// ethermint reduction is 1e18 and cosmos is 1e6, so we need to multiply by 1e12(=1e18 - 1e6)
initialStake = sdkReductionInt.Mul(sdk.NewInt(1e12))
},
)
appParams.GetOrGenerate(
cdc,
Expand All @@ -169,15 +171,15 @@ func AppStateRandomizedFn(
StakePerAccount: %d,
InitiallyBondedValidators: %d,
}
`, initalStake, numInitiallyBonded)
`, initialStake, numInitiallyBonded)

simState := &module.SimulationState{
AppParams: appParams,
Cdc: cdc,
Rand: r,
GenState: genesisState,
Accounts: accs,
InitialStake: initalStake,
InitialStake: initialStake,
NumBonded: numInitiallyBonded,
GenTimestamp: genesisTimestamp,
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/evmos/ethermint v0.19.3
)

require github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6 // indirect
require github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6

require (
cosmossdk.io/errors v1.0.0-beta.7
Expand Down Expand Up @@ -169,7 +169,8 @@ require (

replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
github.com/cosmos/cosmos-sdk => github.com/b-harvest/cosmos-sdk v0.45.9-canto-lsm-sim
github.com/cosmos/cosmos-sdk => github.com/b-harvest/cosmos-sdk v0.45.9-2-canto-lsm-sim
github.com/cosmos/ibc-go/v3 v3.2.0 => github.com/b-harvest/ibc-go/v3 v3.2.0-1-canto-lsm-sim
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.25
google.golang.org/grpc => google.golang.org/grpc v1.33.2
Expand Down
11 changes: 4 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQ
github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/b-harvest/cosmos-sdk v0.45.9-canto-lsm-sim h1:4Y7JBv1ODfCTzWMBZcZxx+Vj3XKEMUmzDvainLIMoMI=
github.com/b-harvest/cosmos-sdk v0.45.9-canto-lsm-sim/go.mod h1:Z5M4TX7PsHNHlF/1XanI2DIpORQ+Q/st7oaeufEjnvU=
github.com/b-harvest/cosmos-sdk v0.45.9-2-canto-lsm-sim h1:dPbp2D/U5uNX3+VSs06zGMYVjqgVLoFC6BxQ1AgCRsM=
github.com/b-harvest/cosmos-sdk v0.45.9-2-canto-lsm-sim/go.mod h1:Z5M4TX7PsHNHlF/1XanI2DIpORQ+Q/st7oaeufEjnvU=
github.com/b-harvest/ibc-go/v3 v3.2.0-1-canto-lsm-sim h1:ODXVMtFDD5GX39xMSZEZEFxJYsgkxmv1pDEp/6EVi9M=
github.com/b-harvest/ibc-go/v3 v3.2.0-1-canto-lsm-sim/go.mod h1:ZTUeC/y/r1WW7KXE2AUpax/ieECnDX+6hQ3Qwdd65sM=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down Expand Up @@ -185,8 +187,6 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.3 h1:cESO0OwTTxQm5rmyESKW+zESheDUYI7CcZDWWDwnuxg=
github.com/cosmos/iavl v0.19.3/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-go/v3 v3.2.0 h1:Mh+RWo5FHPMM1Xsrar3uwKufdEGdIp5LDkVk9cYKYYA=
github.com/cosmos/ibc-go/v3 v3.2.0/go.mod h1:DrDYXJjWNwgv72cK1Il+BegtyGIDXcx+cnJwWGzve6o=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
Expand Down Expand Up @@ -315,7 +315,6 @@ github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5Nq
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
Expand Down Expand Up @@ -402,7 +401,6 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down Expand Up @@ -825,7 +823,6 @@ github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNG
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s=
github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U=
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI=
Expand Down
3 changes: 2 additions & 1 deletion x/inflation/types/inflation_calculation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
ethermint "github.com/evmos/ethermint/types"
)

// CalculateEpochProvisions returns mint provision per epoch
Expand Down Expand Up @@ -40,6 +41,6 @@ func CalculateEpochMintProvision(
// Multiply epochMintProvision with power reduction (10^18 for evmos) as the
// calculation is based on `evmos` and the issued tokens need to be given in
// `aevmos`
epochProvision = epochProvision.Mul(sdk.DefaultPowerReduction.ToDec())
epochProvision = epochProvision.Mul(ethermint.PowerReduction.ToDec())
return epochProvision
}

0 comments on commit bed5d90

Please sign in to comment.