Skip to content

Commit

Permalink
chore!: remove redundant mechanisms to submit pfbs
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-forbes committed Nov 14, 2023
1 parent e608781 commit 6305141
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 84 deletions.
59 changes: 59 additions & 0 deletions app/test/query_account_test.go
Original file line number Diff line number Diff line change
@@ -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
}
27 changes: 23 additions & 4 deletions test/testground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
46 changes: 1 addition & 45 deletions test/testground/network/consensus_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
38 changes: 3 additions & 35 deletions test/testground/network/follower.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"time"

"github.com/celestiaorg/celestia-app/test/txsim"
Expand All @@ -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 {
Expand All @@ -37,7 +38,6 @@ func NewFollower() *Follower {
},
)

op.RegisterCommand(RunSubmitRandomPFBs, f.SubmitRandomPFBsHandler)
f.op = op
return f
}
Expand Down Expand Up @@ -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))
}
}
}

0 comments on commit 6305141

Please sign in to comment.