Skip to content

Commit

Permalink
enabled wasm gov proposals (#5)
Browse files Browse the repository at this point in the history
* used sdk's multisig gas consumption function

* enabled wasm proposals
  • Loading branch information
sunnya97 committed Aug 24, 2020
1 parent 615552d commit e49cba4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
16 changes: 1 addition & 15 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,9 @@ func consumeSigGas(
case multisig.PubKeyMultisigThreshold:
var multisignature multisig.Multisignature
codec.Cdc.MustUnmarshalBinaryBare(sig, &multisignature)
ConsumeMultisignatureVerificationGas(meter, multisignature, pubkey, params)
ante.ConsumeMultisignatureVerificationGas(meter, multisignature, pubkey, params)
return nil
default:
return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey)
}
}

// Copied from sdk ante package as it wasn't exposed there
func ConsumeMultisignatureVerificationGas(meter sdk.GasMeter,
sig multisig.Multisignature, pubkey multisig.PubKeyMultisigThreshold,
params types.Params) {
size := sig.BitArray.Size()
sigIndex := 0
for i := 0; i < size; i++ {
if sig.BitArray.GetIndex(i) {
ante.DefaultSigVerificationGasConsumer(meter, sig.Sigs[sigIndex], pubkey.PubKeys[i], params)
sigIndex++
}
}
}
6 changes: 3 additions & 3 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ import (

func TestExport(t *testing.T) {
db := db.NewMemDB()
app := NewStraightedgeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, wasm.DisableAllProposals, nil)
app := NewStraightedgeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, wasm.EnableAllProposals, nil)
setGenesis(app)

// Making a new app object with the db, so that initchain hasn't been called
newApp := NewStraightedgeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, wasm.DisableAllProposals, nil)
newApp := NewStraightedgeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, wasm.EnableAllProposals, nil)
_, _, err := newApp.ExportAppStateAndValidators(false, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
}

// ensure that black listed addresses are properly set in bank keeper
func TestBlackListedAddrs(t *testing.T) {
db := db.NewMemDB()
app := NewStraightedgeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, wasm.DisableAllProposals, nil)
app := NewStraightedgeApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0, wasm.EnableAllProposals, nil)

for acc := range maccPerms {
require.True(t, app.bankKeeper.BlacklistedAddr(app.supplyKeeper.GetModuleAddress(acc)))
Expand Down
6 changes: 3 additions & 3 deletions cmd/strd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer) abci.Application
}

return app.NewStraightedgeApp(logger, db, traceStore, true, invCheckPeriod,
wasm.DisableAllProposals,
wasm.EnableAllProposals,
skipUpgradeHeights,
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(viper.GetString(server.FlagMinGasPrices)),
Expand All @@ -113,13 +113,13 @@ func exportAppStateAndTMValidators(
) (json.RawMessage, []tmtypes.GenesisValidator, error) {

if height != -1 {
tempApp := app.NewStraightedgeApp(logger, db, traceStore, false, uint(1), wasm.DisableAllProposals, nil)
tempApp := app.NewStraightedgeApp(logger, db, traceStore, false, uint(1), wasm.EnableAllProposals, nil)
err := tempApp.LoadHeight(height)
if err != nil {
return nil, nil, err
}
return tempApp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
}
tempApp := app.NewStraightedgeApp(logger, db, traceStore, true, uint(1), wasm.DisableAllProposals, nil)
tempApp := app.NewStraightedgeApp(logger, db, traceStore, true, uint(1), wasm.EnableAllProposals, nil)
return tempApp.ExportAppStateAndValidators(forZeroHeight, jailWhiteList)
}

0 comments on commit e49cba4

Please sign in to comment.