-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(simapp): move simapp binary into its own go.mod (#6710)
* move simapp to a separate go module * remove unecessary modules from testing/simapp * Fix tests * refactor: trim out unnecessary files/code of new simapp go.mod * refactor: remove unnecessary code in testing simapp package * remove: upgrade logic and crisis module from testing simapp * Update simapp go.mod * Fix compile issue with new simapp * lint * go mod tidy e2e * Fix fail after merge --------- Co-authored-by: Colin Axnér <[email protected]>
- Loading branch information
1 parent
b62e7d4
commit 6bc5e8f
Showing
31 changed files
with
3,085 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# simapp | ||
|
||
simapp is an application built using the Cosmos SDK for testing and educational purposes. | ||
|
||
## Running testnets with `simd` | ||
|
||
If you want to spin up a quick testnet with your friends, you can follow these steps. | ||
Unless otherwise noted, every step must be done by everyone who wants to participate | ||
in this testnet. | ||
|
||
1. `$ make build`. This will build the `simd` binary and install it in your Cosmos SDK repo, | ||
inside a new `build` directory. The following instructions are run from inside | ||
that directory. | ||
2. If you've run `simd` before, you may need to reset your database before starting a new | ||
testnet: `$ ./simd unsafe-reset-all` | ||
3. `$ ./simd init [moniker]`. This will initialize a new working directory, by default at | ||
`~/.simapp`. You need a provide a "moniker," but it doesn't matter what it is. | ||
4. `$ ./simd keys add [key_name]`. This will create a new key, with a name of your choosing. | ||
Save the output of this command somewhere; you'll need the address generated here later. | ||
5. `$ ./simd add-genesis-account $(simd keys show [key_name] -a) [amount]`, where `key_name` | ||
is the same key name as before; and `amount` is something like `10000000000000000000000000stake`. | ||
6. `$ ./simd gentx [key_name] [amount] --chain-id [chain-id]`. This will create the | ||
genesis transaction for your new chain. | ||
7. Now, one person needs to create the genesis file `genesis.json` using the genesis transactions | ||
from every participant, by gathering all the genesis transactions under `config/gentx` and then | ||
calling `./simd collect-gentxs`. This will create a new `genesis.json` file that includes data | ||
from all the validators (we sometimes call it the "super genesis file" to distinguish it from | ||
single-validator genesis files). | ||
8. Once you've received the super genesis file, overwrite your original `genesis.json` file with | ||
the new super `genesis.json`. | ||
9. Modify your `config/config.toml` (in the simapp working directory) to include the other participants as | ||
persistent peers: | ||
|
||
```text | ||
# Comma separated list of nodes to keep persistent connections to | ||
persistent_peers = "[validator address]@[ip address]:[port],[validator address]@[ip address]:[port]" | ||
``` | ||
You can find `validator address` by running `./simd tendermint show-node-id`. (It will be hex-encoded.) | ||
By default, `port` is 26656. | ||
10. Now you can start your nodes: `$ ./simd start`. | ||
Now you have a small testnet that you can use to try out changes to the Cosmos SDK or Tendermint! | ||
NOTE: Sometimes creating the network through the `collect-gentxs` will fail, and validators will start | ||
in a funny state (and then panic). If this happens, you can try to create and start the network first | ||
with a single validator and then add additional validators using a `create-validator` transaction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package simapp | ||
|
||
import ( | ||
"errors" | ||
|
||
circuitante "cosmossdk.io/x/circuit/ante" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
|
||
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante" | ||
"github.com/cosmos/ibc-go/v8/modules/core/keeper" | ||
) | ||
|
||
// HandlerOptions are the options required for constructing a default SDK AnteHandler. | ||
type HandlerOptions struct { | ||
ante.HandlerOptions | ||
CircuitKeeper circuitante.CircuitBreaker | ||
IBCKeeper *keeper.Keeper | ||
} | ||
|
||
// NewAnteHandler returns an AnteHandler that checks and increments sequence | ||
// numbers, checks signatures & account numbers, and deducts fees from the first | ||
// signer. | ||
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { | ||
if options.AccountKeeper == nil { | ||
return nil, errors.New("account keeper is required for ante builder") | ||
} | ||
|
||
if options.BankKeeper == nil { | ||
return nil, errors.New("bank keeper is required for ante builder") | ||
} | ||
|
||
if options.SignModeHandler == nil { | ||
return nil, errors.New("sign mode handler is required for ante builder") | ||
} | ||
|
||
anteDecorators := []sdk.AnteDecorator{ | ||
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first | ||
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper), | ||
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), | ||
ante.NewValidateBasicDecorator(), | ||
ante.NewTxTimeoutHeightDecorator(), | ||
ante.NewValidateMemoDecorator(options.AccountKeeper), | ||
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), | ||
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), | ||
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators | ||
ante.NewValidateSigCountDecorator(options.AccountKeeper), | ||
ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), | ||
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), | ||
ante.NewIncrementSequenceDecorator(options.AccountKeeper), | ||
ibcante.NewRedundantRelayDecorator(options.IBCKeeper), | ||
} | ||
|
||
return sdk.ChainAnteDecorators(anteDecorators...), nil | ||
} |
Oops, something went wrong.