diff --git a/app/test/query_account_test.go b/app/test/query_account_test.go new file mode 100644 index 0000000000..3a9394d114 --- /dev/null +++ b/app/test/query_account_test.go @@ -0,0 +1,59 @@ +package app + +import ( + "context" + "fmt" + + "github.com/celestiaorg/celestia-app/app" + "github.com/celestiaorg/celestia-app/app/encoding" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +func QueryAccount(addr string) error { + ecfg := encoding.MakeConfig(app.ModuleEncodingRegisters...) + + conn, err := grpc.Dial("consensus.lunaroasis.net:9090", grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + return err + } + + authQC := authtypes.NewQueryClient(conn) + + authresp, err := authQC.Account(context.Background(), &authtypes.QueryAccountRequest{ + Address: addr, + }) + if err != nil { + return err + } + + var acc authtypes.AccountI + err = ecfg.InterfaceRegistry.UnpackAny(authresp.Account, &acc) + if err != nil { + return err + } + + switch acc := acc.(type) { + case *vestingtypes.PeriodicVestingAccount: + fmt.Println("periodic", acc) + case *vestingtypes.ContinuousVestingAccount: + fmt.Println("continuous", acc) + case *authtypes.BaseAccount: + fmt.Println("base account", acc) + default: + fmt.Println("unknown account type", acc) + } + + bankQC := banktypes.NewQueryClient(conn) + spendableResp, err := bankQC.SpendableBalances(context.Background(), &banktypes.QuerySpendableBalancesRequest{ + Address: addr, + }) + if err != nil { + return err + } + fmt.Println(spendableResp.Balances) + return nil +} diff --git a/test/testground/README.md b/test/testground/README.md index 9691d710fd..c4d65ef7b9 100644 --- a/test/testground/README.md +++ b/test/testground/README.md @@ -45,9 +45,9 @@ sequenceDiagram Note over L, Fn: EntryPoint(runenv *runtime.RunEnv, initCtx *run.InitContext) Note over L, Fn: Plan(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitContext) - F1->>L: Send GenTx - F2->>L: Send GenTx - Fn->>L: Send GenTx + F1->>L: Send PeerPacket + F2->>L: Send PeerPacket + Fn->>L: Send PeerPacket Note over L: Genesis Creation L->>L: Collect GenTx @@ -80,7 +80,26 @@ sequenceDiagram Note over L: Process log local data ``` -## Configuring an experiment +## Configuring an Experiment + +### Defining Topologies and Configs + +Per the diagram above, the leader node initializes and modifies the configs used +by each node. This allows for arbitrary network topologies to be created. + +### Defining the Experiemnt + +To run an specific type of experiment, specify the experiemnt in the `plan.toml`. + +```toml +experiment = "unbounded_block_size" +``` + +To create a new experiment. + +## Running the Experiment + +## Collecting Data ### Tracing diff --git a/test/testground/network/consensus_node.go b/test/testground/network/consensus_node.go index 248d742546..7129397286 100644 --- a/test/testground/network/consensus_node.go +++ b/test/testground/network/consensus_node.go @@ -14,12 +14,8 @@ import ( "github.com/celestiaorg/celestia-app/app" "github.com/celestiaorg/celestia-app/app/encoding" "github.com/celestiaorg/celestia-app/cmd/celestia-appd/cmd" - appns "github.com/celestiaorg/celestia-app/pkg/namespace" - "github.com/celestiaorg/celestia-app/pkg/user" - "github.com/celestiaorg/celestia-app/test/util/blobfactory" "github.com/celestiaorg/celestia-app/test/util/genesis" "github.com/celestiaorg/celestia-app/test/util/testnode" - blobtypes "github.com/celestiaorg/celestia-app/x/blob/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" srvconfig "github.com/cosmos/cosmos-sdk/server/config" srvtypes "github.com/cosmos/cosmos-sdk/server/types" @@ -28,7 +24,6 @@ import ( "github.com/tendermint/tendermint/crypto/ed25519" cmtos "github.com/tendermint/tendermint/libs/os" tmos "github.com/tendermint/tendermint/libs/os" - tmrand "github.com/tendermint/tendermint/libs/rand" "github.com/tendermint/tendermint/node" "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/p2p/pex" @@ -243,45 +238,6 @@ func (cn *ConsensusNode) UniversalTestingConfig() testnode.UniversalTestingConfi } } -// SubmitRandomPFB will submit a single PFB using the consensus node's tx -// signing account. One blob will be included for each size provided in a single PFB. -func (c *ConsensusNode) SubmitRandomPFB(ctx context.Context, runenv *runtime.RunEnv, blobSizes ...int) (*sdk.TxResponse, error) { - runenv.RecordMessage("attempting to get the key") - if c.kr == nil { - return nil, errors.New("nil keyring") - } - rec, err := c.kr.Key(c.Name) - if err != nil { - return nil, err - } - runenv.RecordMessage("got key") - addr, err := rec.GetAddress() - if err != nil { - return nil, err - } - runenv.RecordMessage("got addr") - signer, err := user.SetupSigner(ctx, c.kr, c.cctx.GRPCClient, addr, c.ecfg) - if err != nil { - return nil, err - } - runenv.RecordMessage("created signer") - - r := tmrand.NewRand() - - blobs := blobfactory.RandBlobsWithNamespace(appns.RandomBlobNamespaces(r, len(blobSizes)), blobSizes) - runenv.RecordMessage("made blobs") - blobSizesU := make([]uint32, 0, len(blobSizes)) - for _, size := range blobSizes { - blobSizesU = append(blobSizesU, uint32(size)) - } - - limit := blobtypes.DefaultEstimateGas(blobSizesU) - - runenv.RecordMessage("finished prep for pfb") - - return signer.SubmitPayForBlob(ctx, blobs, user.SetGasLimitAndFee(limit, 0.1)) -} - func addrsToStrings(addrs ...sdk.AccAddress) []string { strs := make([]string, len(addrs)) for i, addr := range addrs { @@ -352,7 +308,7 @@ func parsePeerID(input string) (string, net.IP, int, error) { match := re.FindStringSubmatch(input) if len(match) != 4 { - return "", nil, 0, fmt.Errorf("Invalid input format") + return "", nil, 0, fmt.Errorf("invalid input format") } // Extract the components from the regex match. diff --git a/test/testground/network/follower.go b/test/testground/network/follower.go index 0e587b48b9..0709937aa9 100644 --- a/test/testground/network/follower.go +++ b/test/testground/network/follower.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "errors" - "fmt" "time" "github.com/celestiaorg/celestia-app/test/txsim" @@ -22,8 +21,10 @@ type Follower struct { // NewFollower creates a new follower role. func NewFollower() *Follower { - op := NewOperator() f := &Follower{&ConsensusNode{}, nil} + // all of the commands that the follower can receive have to be registered + // at some point. This is currently done here. + op := NewOperator() op.RegisterCommand( RunTxSimCommandID, func(ctx context.Context, runenv *runtime.RunEnv, _ *run.InitContext, args json.RawMessage) error { @@ -37,7 +38,6 @@ func NewFollower() *Follower { }, ) - op.RegisterCommand(RunSubmitRandomPFBs, f.SubmitRandomPFBsHandler) f.op = op return f } @@ -181,35 +181,3 @@ func NewSubmitRandomPFBsCommand(id string, timeout time.Duration, sizes ...int) TargetGroup: "all", } } - -func (c *ConsensusNode) SubmitRandomPFBsHandler( - ctx context.Context, - runenv *runtime.RunEnv, - initCtx *run.InitContext, - args json.RawMessage, -) error { - var sizes []int - err := json.Unmarshal(args, &sizes) - if err != nil { - return err - } - runenv.RecordMessage("called handler") - for { - select { - case <-ctx.Done(): - runenv.RecordMessage("done with handler") - return nil - default: - runenv.RecordMessage("calling suvbmit") - resp, err := c.SubmitRandomPFB(ctx, runenv, sizes...) - if err != nil { - return err - } - runenv.RecordMessage("received a response") - if resp == nil { - return errors.New("nil response and nil error submitting PFB") - } - runenv.RecordMessage(fmt.Sprintf("follower submitted PFB code: %d %s", resp.Code, resp.Codespace)) - } - } -}