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

txsource/queries: workload doing various queries #2769

Merged
merged 3 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .changelog/2769.feature.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
txsource/queries: workload doing historical queries

Queries workload continuously performs various historic queries using the
exposed APIs and makes sure the responses make sense.
3 changes: 3 additions & 0 deletions .changelog/2769.feature.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go/staking: add LastBlockFees query method

LastBlockFees returns the collected fees for previous block.
Copy link
Member

Choose a reason for hiding this comment

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

Slightly unrelated, but this is also something that should be part of the genesis state dump as otherwise it could cause the total token amount to become inconsistent on dump/restore.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh we don't do that at the moment :o will do a PR that adds that tomorrow 😁

5 changes: 5 additions & 0 deletions go/consensus/tendermint/apps/staking/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type Query interface {
TotalSupply(context.Context) (*quantity.Quantity, error)
CommonPool(context.Context) (*quantity.Quantity, error)
LastBlockFees(context.Context) (*quantity.Quantity, error)
Threshold(context.Context, staking.ThresholdKind) (*quantity.Quantity, error)
DebondingInterval(context.Context) (epochtime.EpochTime, error)
Accounts(context.Context) ([]signature.PublicKey, error)
Expand Down Expand Up @@ -67,6 +68,10 @@ func (sq *stakingQuerier) CommonPool(ctx context.Context) (*quantity.Quantity, e
return sq.state.CommonPool()
}

func (sq *stakingQuerier) LastBlockFees(ctx context.Context) (*quantity.Quantity, error) {
return sq.state.LastBlockFees()
}

func (sq *stakingQuerier) Threshold(ctx context.Context, kind staking.ThresholdKind) (*quantity.Quantity, error) {
thresholds, err := sq.state.Thresholds()
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions go/consensus/tendermint/staking/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ func (tb *tendermintBackend) CommonPool(ctx context.Context, height int64) (*qua
return q.CommonPool(ctx)
}

func (tb *tendermintBackend) LastBlockFees(ctx context.Context, height int64) (*quantity.Quantity, error) {
q, err := tb.querier.QueryAt(ctx, height)
if err != nil {
return nil, err
}

return q.LastBlockFees(ctx)
}

func (tb *tendermintBackend) Threshold(ctx context.Context, query *api.ThresholdQuery) (*quantity.Quantity, error) {
q, err := tb.querier.QueryAt(ctx, query.Height)
if err != nil {
Expand Down
6 changes: 1 addition & 5 deletions go/oasis-node/cmd/debug/txsource/txsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
cmdFlags "github.com/oasislabs/oasis-core/go/oasis-node/cmd/common/flags"
cmdGrpc "github.com/oasislabs/oasis-core/go/oasis-node/cmd/common/grpc"
"github.com/oasislabs/oasis-core/go/oasis-node/cmd/debug/txsource/workload"
runtimeClient "github.com/oasislabs/oasis-core/go/runtime/client/api"
)

const (
Expand Down Expand Up @@ -95,9 +94,6 @@ func doRun(cmd *cobra.Command, args []string) error {
// Set up the consensus client.
cnsc := consensus.NewConsensusClient(conn)

// Set up the runtime client.
rtc := runtimeClient.NewRuntimeClient(conn)

// Wait for sync before transferring control to the workload.
ncc := api.NewNodeControllerClient(conn)
logger.Debug("waiting for node sync")
Expand All @@ -120,7 +116,7 @@ func doRun(cmd *cobra.Command, args []string) error {
}

logger.Debug("entering workload", "name", name)
if err = w.Run(ctx, rng, conn, cnsc, rtc, fundingAccount); err != nil {
if err = w.Run(ctx, rng, conn, cnsc, fundingAccount); err != nil {
pro-wh marked this conversation as resolved.
Show resolved Hide resolved
logger.Error("workload error", "err", err)
return fmt.Errorf("workload %s: %w", name, err)
}
Expand Down
2 changes: 0 additions & 2 deletions go/oasis-node/cmd/debug/txsource/workload/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/oasislabs/oasis-core/go/common/logging"
consensus "github.com/oasislabs/oasis-core/go/consensus/api"
"github.com/oasislabs/oasis-core/go/consensus/api/transaction"
runtimeClient "github.com/oasislabs/oasis-core/go/runtime/client/api"
staking "github.com/oasislabs/oasis-core/go/staking/api"
)

Expand Down Expand Up @@ -178,7 +177,6 @@ func (d *delegation) Run(
rng *rand.Rand,
conn *grpc.ClientConn,
cnsc consensus.ClientBackend,
rtc runtimeClient.RuntimeClient,
fundingAccount signature.Signer,
) error {
var err error
Expand Down
2 changes: 0 additions & 2 deletions go/oasis-node/cmd/debug/txsource/workload/oversized.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/oasislabs/oasis-core/go/common/logging"
consensus "github.com/oasislabs/oasis-core/go/consensus/api"
"github.com/oasislabs/oasis-core/go/consensus/api/transaction"
runtimeClient "github.com/oasislabs/oasis-core/go/runtime/client/api"
staking "github.com/oasislabs/oasis-core/go/staking/api"
)

Expand All @@ -33,7 +32,6 @@ func (oversized) Run(
rng *rand.Rand,
conn *grpc.ClientConn,
cnsc consensus.ClientBackend,
rtc runtimeClient.RuntimeClient,
fundingAccount signature.Signer,
) error {
txSignerFactory := memorySigner.NewFactory()
Expand Down
2 changes: 0 additions & 2 deletions go/oasis-node/cmd/debug/txsource/workload/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/oasislabs/oasis-core/go/common/logging"
consensus "github.com/oasislabs/oasis-core/go/consensus/api"
"github.com/oasislabs/oasis-core/go/consensus/api/transaction"
runtimeClient "github.com/oasislabs/oasis-core/go/runtime/client/api"
staking "github.com/oasislabs/oasis-core/go/staking/api"
)

Expand All @@ -39,7 +38,6 @@ func (parallel) Run(
rng *rand.Rand,
conn *grpc.ClientConn,
cnsc consensus.ClientBackend,
rtc runtimeClient.RuntimeClient,
fundingAccount signature.Signer,
) error {
ctx := context.Background()
Expand Down
Loading