Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regeneration of app #127

Merged
merged 18 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- name: Display go version
run: go version
- run: make build
Expand All @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- name: Display go version
run: go version
- name: Install runsim
Expand All @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v5
Expand All @@ -77,7 +77,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v5
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v5
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- name: Unshallow
run: git fetch --prune --unshallow
- name: Create release
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- name: Display go version
run: go version
- name: install tparse
Expand All @@ -38,7 +38,7 @@ jobs:
# - uses: actions/checkout@v2
# - uses: actions/[email protected]
# with:
# go-version: 1.15
# go-version: 1.17
# - name: Display go version
# run: go version
# - uses: technote-space/get-diff-action@v5
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- uses: technote-space/get-diff-action@v5
with:
PATTERNS: |
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: 1.15
go-version: 1.17
- uses: technote-space/get-diff-action@v5
with:
PATTERNS: |
Expand Down Expand Up @@ -235,7 +235,7 @@ jobs:
# - uses: actions/checkout@v2
# - uses: actions/[email protected]
# with:
# go-version: 1.15
# go-version: 1.17
# - uses: technote-space/get-diff-action@v5
# id: git_diff
# with:
Expand Down
27 changes: 23 additions & 4 deletions app/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"sort"

"github.com/celestiaorg/celestia-app/x/payment/types"
abci "github.com/celestiaorg/celestia-core/abci/types"
core "github.com/celestiaorg/celestia-core/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/pkg/consts"
core "github.com/tendermint/tendermint/proto/tendermint/types"
)

// This file should contain all of the altered ABCI methods
Expand Down Expand Up @@ -65,7 +66,7 @@ func (app *App) PreprocessTxs(txs abci.RequestPreprocessTxs) abci.ResponsePrepro
}

// encode the processed tx
rawProcessedTx, err := app.appCodec.MarshalBinaryBare(signedTx)
rawProcessedTx, err := app.appCodec.Marshal(signedTx)
if err != nil {
continue
}
Expand All @@ -86,11 +87,23 @@ func (app *App) PreprocessTxs(txs abci.RequestPreprocessTxs) abci.ResponsePrepro
}
}

// pfmURL is the URL expected for pfm. NOTE: this will be deleted when we upgrade from
// sdk v0.44.0
var pfmURL = sdk.MsgTypeURL(&types.MsgWirePayForMessage{})

func hasWirePayForMessage(tx sdk.Tx) bool {
for _, msg := range tx.GetMsgs() {
if msg.Type() == types.TypeMsgPayforMessage {
msgName := sdk.MsgTypeURL(msg)
if msgName == pfmURL {
return true
}
// note: this is what we will use in the future as proto.MessageName is
// deprecated
// svcMsg, ok := msg.(sdk.ServiceMsg) if !ok {
// continue
// } if svcMsg.SerivceMethod == types.TypeMsgPayforMessage {
// return true
// }
Comment on lines +90 to +106
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will have to be replaced as soon as we use a newer version of the sdk (see comment).

}
return false
}
Expand Down Expand Up @@ -142,3 +155,9 @@ func (app *App) processMsg(msg sdk.Msg) (core.Message, *types.TxSignedTransactio

return coreMsg, signedData, nil
}

// SquareSize returns the current square size. Currently, the square size is
// hardcoded. todo(evan): don't hardcode the square size
func (app *App) SquareSize() uint64 {
return consts.MaxSquareSize
}
28 changes: 13 additions & 15 deletions app/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"testing"

"github.com/celestiaorg/celestia-app/x/payment/types"
abci "github.com/celestiaorg/celestia-core/abci/types"
"github.com/celestiaorg/celestia-core/libs/log"
core "github.com/celestiaorg/celestia-core/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
Expand All @@ -28,6 +25,10 @@ import (
"github.com/spf13/cast"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/spm/cosmoscmd"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
core "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
)

Expand All @@ -40,7 +41,7 @@ func init() {

func TestProcessMsg(t *testing.T) {
kb := keyring.NewInMemory()
info, _, err := kb.NewMnemonic(testingKeyAcc, keyring.English, "", hd.Secp256k1)
info, _, err := kb.NewMnemonic(testingKeyAcc, keyring.English, "", "", hd.Secp256k1)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -74,7 +75,7 @@ func TestProcessMsg(t *testing.T) {

func TestPreprocessTxs(t *testing.T) {
kb := keyring.NewInMemory()
info, _, err := kb.NewMnemonic(testingKeyAcc, keyring.English, "", hd.Secp256k1)
info, _, err := kb.NewMnemonic(testingKeyAcc, keyring.English, "", "", hd.Secp256k1)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -139,23 +140,20 @@ func setupApp(t *testing.T, pub cryptotypes.PubKey) *App {

skipUpgradeHeights := make(map[int64]bool)

encCfg := cosmoscmd.MakeEncodingConfig(ModuleBasics)

testApp := New(
"test-app", logger, db, nil, true, skipUpgradeHeights,
logger, db, nil, true, skipUpgradeHeights,
cast.ToString(emptyOpts.Get(flags.FlagHome)),
cast.ToUint(emptyOpts.Get(server.FlagInvCheckPeriod)),
MakeEncodingConfig(),
encCfg,
emptyOpts,
anteOpt,
)

for acc := range maccPerms {
require.Equal(t, !allowedReceivingModAcc[acc], testApp.BankKeeper.BlockedAddr(testApp.AccountKeeper.GetModuleAddress(acc)),
"ensure that blocked addresses are properly set in bank keeper")
}

genesisState := NewDefaultGenesisState()
genesisState := NewDefaultGenesisState(encCfg.Marshaler)

genesisState, err := addGenesisAccount(sdk.AccAddress(pub.Address().Bytes()), genesisState, testApp.appCodec)
genesisState, err := addGenesisAccount(sdk.AccAddress(pub.Address().Bytes()), genesisState, encCfg.Marshaler)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -184,7 +182,7 @@ func (ao emptyAppOptions) Get(o string) interface{} {
// addGenesisAccount mimics the cli addGenesisAccount command, providing an
// account with an allocation of to "token" and "stake" tokens in the genesis
// state
func addGenesisAccount(addr sdk.AccAddress, appState map[string]json.RawMessage, cdc codec.Marshaler) (map[string]json.RawMessage, error) {
func addGenesisAccount(addr sdk.AccAddress, appState map[string]json.RawMessage, cdc codec.Codec) (map[string]json.RawMessage, error) {
// create concrete account type based on input parameters
var genAccount authtypes.GenesisAccount

Expand Down
Loading