diff --git a/go/consensus/tendermint/apps/staking/genesis.go b/go/consensus/tendermint/apps/staking/genesis.go index e0a67ba89a0..978d1b96f3c 100644 --- a/go/consensus/tendermint/apps/staking/genesis.go +++ b/go/consensus/tendermint/apps/staking/genesis.go @@ -287,21 +287,21 @@ func (sq *stakingQuerier) Genesis(ctx context.Context) (*staking.Genesis, error) return nil, err } - accounts, err := sq.state.Accounts(ctx) + addresses, err := sq.state.Addresses(ctx) if err != nil { return nil, err } ledger := make(map[staking.Address]*staking.Account) - for _, acctID := range accounts { + for _, addr := range addresses { var acct *staking.Account - acct, err = sq.state.Account(ctx, acctID) + acct, err = sq.state.Account(ctx, addr) if err != nil { return nil, fmt.Errorf("tendermint/staking: failed to fetch account: %w", err) } // Make sure that export resets the stake accumulator state as that should be re-initialized // during genesis (a genesis document with non-empty stake accumulator is invalid). acct.Escrow.StakeAccumulator = staking.StakeAccumulator{} - ledger[acctID] = acct + ledger[addr] = acct } delegations, err := sq.state.Delegations(ctx) diff --git a/go/consensus/tendermint/apps/staking/query.go b/go/consensus/tendermint/apps/staking/query.go index c2649764376..ca01ef53c17 100644 --- a/go/consensus/tendermint/apps/staking/query.go +++ b/go/consensus/tendermint/apps/staking/query.go @@ -17,7 +17,7 @@ type Query interface { LastBlockFees(context.Context) (*quantity.Quantity, error) Threshold(context.Context, staking.ThresholdKind) (*quantity.Quantity, error) DebondingInterval(context.Context) (epochtime.EpochTime, error) - Accounts(context.Context) ([]staking.Address, error) + Addresses(context.Context) ([]staking.Address, error) AccountInfo(context.Context, staking.Address) (*staking.Account, error) Delegations(context.Context, staking.Address) (map[staking.Address]*staking.Delegation, error) DebondingDelegations(context.Context, staking.Address) (map[staking.Address][]*staking.DebondingDelegation, error) @@ -72,8 +72,8 @@ func (sq *stakingQuerier) DebondingInterval(ctx context.Context) (epochtime.Epoc return sq.state.DebondingInterval(ctx) } -func (sq *stakingQuerier) Accounts(ctx context.Context) ([]staking.Address, error) { - return sq.state.Accounts(ctx) +func (sq *stakingQuerier) Addresses(ctx context.Context) ([]staking.Address, error) { + return sq.state.Addresses(ctx) } func (sq *stakingQuerier) AccountInfo(ctx context.Context, addr staking.Address) (*staking.Account, error) { diff --git a/go/consensus/tendermint/apps/staking/state/state.go b/go/consensus/tendermint/apps/staking/state/state.go index 9f022cafb90..b9c94651437 100644 --- a/go/consensus/tendermint/apps/staking/state/state.go +++ b/go/consensus/tendermint/apps/staking/state/state.go @@ -165,23 +165,23 @@ func (s *ImmutableState) Thresholds(ctx context.Context) (map[staking.ThresholdK return params.Thresholds, nil } -func (s *ImmutableState) Accounts(ctx context.Context) ([]staking.Address, error) { +func (s *ImmutableState) Addresses(ctx context.Context) ([]staking.Address, error) { it := s.is.NewIterator(ctx) defer it.Close() - var accounts []staking.Address + var addresses []staking.Address for it.Seek(accountKeyFmt.Encode()); it.Valid(); it.Next() { var addr staking.Address if !accountKeyFmt.Decode(it.Key(), &addr) { break } - accounts = append(accounts, addr) + addresses = append(addresses, addr) } if it.Err() != nil { return nil, abciAPI.UnavailableStateError(it.Err()) } - return accounts, nil + return addresses, nil } func (s *ImmutableState) Account(ctx context.Context, id staking.Address) (*staking.Account, error) { diff --git a/go/consensus/tendermint/apps/supplementarysanity/checks.go b/go/consensus/tendermint/apps/supplementarysanity/checks.go index 174aca1da07..262d8cc5ff0 100644 --- a/go/consensus/tendermint/apps/supplementarysanity/checks.go +++ b/go/consensus/tendermint/apps/supplementarysanity/checks.go @@ -122,19 +122,19 @@ func checkStaking(ctx *abciAPI.Context, now epochtime.EpochTime) error { // Check if the total supply adds up (common pool + all balances in the ledger). // Check all commission schedules. var total quantity.Quantity - accounts, err := st.Accounts(ctx) + addresses, err := st.Addresses(ctx) if err != nil { - return fmt.Errorf("Accounts: %w", err) + return fmt.Errorf("Addresses: %w", err) } var acct *staking.Account - for _, id := range accounts { - acct, err = st.Account(ctx, id) + for _, addr := range addresses { + acct, err = st.Account(ctx, addr) if err != nil { return fmt.Errorf("Account: %w", err) } - err = staking.SanityCheckAccount(&total, parameters, now, id, acct) + err = staking.SanityCheckAccount(&total, parameters, now, addr, acct) if err != nil { - return fmt.Errorf("SanityCheckAccount %s: %w", id, err) + return fmt.Errorf("SanityCheckAccount %s: %w", addr, err) } } @@ -183,12 +183,12 @@ func checkStaking(ctx *abciAPI.Context, now epochtime.EpochTime) error { } // Check the above two invariants for each account as well. - for _, id := range accounts { - acct, err = st.Account(ctx, id) + for _, addr := range addresses { + acct, err = st.Account(ctx, addr) if err != nil { return fmt.Errorf("Account: %w", err) } - if err = staking.SanityCheckAccountShares(id, acct, delegationses[id], debondingDelegationses[id]); err != nil { + if err = staking.SanityCheckAccountShares(addr, acct, delegationses[addr], debondingDelegationses[addr]); err != nil { return err } } @@ -266,9 +266,9 @@ func checkStakeClaims(ctx *abciAPI.Context, now epochtime.EpochTime) error { } // Get staking accounts. accounts := make(map[staking.Address]*staking.Account) - addresses, err := stakingSt.Accounts(ctx) + addresses, err := stakingSt.Addresses(ctx) if err != nil { - return fmt.Errorf("failed to get staking accounts: %w", err) + return fmt.Errorf("failed to get staking addresses: %w", err) } for _, addr := range addresses { accounts[addr], err = stakingSt.Account(ctx, addr) diff --git a/go/consensus/tendermint/staking/staking.go b/go/consensus/tendermint/staking/staking.go index 452fd1a5cf3..87cf6b390bc 100644 --- a/go/consensus/tendermint/staking/staking.go +++ b/go/consensus/tendermint/staking/staking.go @@ -82,13 +82,13 @@ func (tb *tendermintBackend) Threshold(ctx context.Context, query *api.Threshold return q.Threshold(ctx, query.Kind) } -func (tb *tendermintBackend) Accounts(ctx context.Context, height int64) ([]api.Address, error) { +func (tb *tendermintBackend) Addresses(ctx context.Context, height int64) ([]api.Address, error) { q, err := tb.querier.QueryAt(ctx, height) if err != nil { return nil, err } - return q.Accounts(ctx) + return q.Addresses(ctx) } func (tb *tendermintBackend) AccountInfo(ctx context.Context, query *api.OwnerQuery) (*api.Account, error) { diff --git a/go/oasis-node/cmd/debug/txsource/workload/queries.go b/go/oasis-node/cmd/debug/txsource/workload/queries.go index ee1eff0b360..888dfc5cc3c 100644 --- a/go/oasis-node/cmd/debug/txsource/workload/queries.go +++ b/go/oasis-node/cmd/debug/txsource/workload/queries.go @@ -284,19 +284,19 @@ func (q *queries) doStakingQueries(ctx context.Context, rng *rand.Rand, height i return fmt.Errorf("Invalid treshold") } - accounts, err := q.staking.Accounts(ctx, height) + addresses, err := q.staking.Addresses(ctx, height) if err != nil { return fmt.Errorf("staking.Accounts: %w", err) } // Make sure total supply matches sum of all balances and fees. var accSum, totalSum quantity.Quantity - for _, sig := range accounts { - acc, err := q.staking.AccountInfo(ctx, &staking.OwnerQuery{Owner: sig, Height: height}) + for _, addr := range addresses { + acc, err := q.staking.AccountInfo(ctx, &staking.OwnerQuery{Owner: addr, Height: height}) if err != nil { q.logger.Error("Error querying AcccountInfo", "height", height, - "owner", sig, + "address", addr, "err", err, ) return fmt.Errorf("staking.AccountInfo: %w", err) @@ -317,7 +317,7 @@ func (q *queries) doStakingQueries(ctx context.Context, rng *rand.Rand, height i "accounts_sum", accSum, "total_sum", totalSum, "total", total, - "accounts", len(accounts), + "n_addresses", len(addresses), ) return fmt.Errorf("staking total supply mismatch") } diff --git a/go/oasis-node/cmd/stake/stake.go b/go/oasis-node/cmd/stake/stake.go index 781e77ad33c..11bb9b49fd0 100644 --- a/go/oasis-node/cmd/stake/stake.go +++ b/go/oasis-node/cmd/stake/stake.go @@ -172,9 +172,9 @@ func doList(cmd *cobra.Command, args []string) { ctx := context.Background() var addrs []api.Address - doWithRetries(cmd, "query accounts", func() error { + doWithRetries(cmd, "query addresses", func() error { var err error - addrs, err = client.Accounts(ctx, consensus.HeightLatest) + addrs, err = client.Addresses(ctx, consensus.HeightLatest) return err }) diff --git a/go/staking/api/api.go b/go/staking/api/api.go index 4bb86ac2185..452d808dada 100644 --- a/go/staking/api/api.go +++ b/go/staking/api/api.go @@ -93,9 +93,9 @@ type Backend interface { // Threshold returns the specific staking threshold by kind. Threshold(ctx context.Context, query *ThresholdQuery) (*quantity.Quantity, error) - // Accounts returns the addresses of all accounts with a non-zero general or - // escrow balance. - Accounts(ctx context.Context, height int64) ([]Address, error) + // Addresses returns the addresses of all accounts with a non-zero general + // or escrow balance. + Addresses(ctx context.Context, height int64) ([]Address, error) // AccountInfo returns the account descriptor for the given account. AccountInfo(ctx context.Context, query *OwnerQuery) (*Account, error) diff --git a/go/staking/api/grpc.go b/go/staking/api/grpc.go index a83129d81e5..3fcefded301 100644 --- a/go/staking/api/grpc.go +++ b/go/staking/api/grpc.go @@ -224,14 +224,14 @@ func handlerAccounts( // nolint: golint return nil, err } if interceptor == nil { - return srv.(Backend).Accounts(ctx, height) + return srv.(Backend).Addresses(ctx, height) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: methodAccounts.FullName(), } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(Backend).Accounts(ctx, req.(int64)) + return srv.(Backend).Addresses(ctx, req.(int64)) } return interceptor(ctx, height, info, handler) } @@ -527,7 +527,7 @@ func (c *stakingClient) Threshold(ctx context.Context, query *ThresholdQuery) (* return &rsp, nil } -func (c *stakingClient) Accounts(ctx context.Context, height int64) ([]Address, error) { +func (c *stakingClient) Addresses(ctx context.Context, height int64) ([]Address, error) { var rsp []Address if err := c.conn.Invoke(ctx, methodAccounts.FullName(), height, &rsp); err != nil { return nil, err