Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bd40522
Merge branch 'release/2.8.3'
onetechnical Feb 1, 2022
4997285
Merge branch 'release/2.8.4'
bricerisingalgorand Feb 7, 2022
ae96643
Ledger refactoring changes (#870)
tolikzinovyev Feb 22, 2022
76faddd
unlimited assets: backwards-compatible JSON encodings for account dat…
cce Feb 24, 2022
c941e78
REST API changes for unlimited assets (#872)
cce Feb 25, 2022
dadae50
Merge remote-tracking branch 'origin/develop' into feature/unlimited-…
cce Feb 25, 2022
8444586
REST API: count include-all results when checking max resources limit…
cce Feb 25, 2022
20c5ade
add "none" to exclude enum
cce Feb 25, 2022
ebc44d5
rename MaxAccountNestedObjects => MaxAPIResourcesPerAccount
cce Feb 25, 2022
b3ebf76
update docs for MaxAccountNestedObjects => MaxAPIResourcesPerAccount
cce Feb 25, 2022
0a20fa2
remove "creator" from required since it has been removed from response
cce Feb 25, 2022
12aaa71
achieve parity
cce Feb 25, 2022
6bc3394
Merge branch 'release/2.9.0'
algobarb Mar 2, 2022
6fdb088
Merge remote-tracking branch 'origin/master' into feature/unlimited-a…
cce Mar 3, 2022
ff54cba
Merge remote-tracking branch 'origin/develop' into feature/unlimited-…
cce Mar 8, 2022
333fedf
add DisabledMapConfig to handles_e2e_test defaultOpts
cce Mar 8, 2022
6402d35
Merge remote-tracking branch 'origin/develop' into feature/unlimited-…
cce Mar 9, 2022
482097a
REST API: use ErrorResponse instead of AccountsErrorResponse (#916)
cce Mar 10, 2022
2b82173
Merge branch 'develop' into feature/unlimited-assets
winder Mar 10, 2022
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
Prev Previous commit
Next Next commit
rename MaxAccountNestedObjects => MaxAPIResourcesPerAccount
  • Loading branch information
cce committed Feb 25, 2022
commit ebc44d59bb8524a1137ab405b0af9f31fdec620e
4 changes: 2 additions & 2 deletions api/converter_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,9 @@ func (si *ServerImplementation) transactionParamsToTransactionFilter(params gene
return
}

func (si *ServerImplementation) maxAccountsErrorToAccountsErrorResponse(maxErr idb.MaxAccountNestedObjectsError) generated.AccountsErrorResponse {
func (si *ServerImplementation) maxAccountsErrorToAccountsErrorResponse(maxErr idb.MaxAPIResourcesPerAccountError) generated.AccountsErrorResponse {
addr := maxErr.Address.String()
max := uint64(si.opts.MaxAccountNestedObjects)
max := uint64(si.opts.MaxAPIResourcesPerAccount)
return generated.AccountsErrorResponse{
Message: "Result limit exceeded",
MaxResults: &max,
Expand Down
8 changes: 4 additions & 4 deletions api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (si *ServerImplementation) LookupAccountByID(ctx echo.Context, accountID st
IncludeAppParams: true,
Limit: 1,
IncludeDeleted: boolOrDefault(params.IncludeAll),
MaxResources: uint64(si.opts.MaxAccountNestedObjects),
MaxResources: uint64(si.opts.MaxAPIResourcesPerAccount),
}

if params.Exclude != nil {
Expand All @@ -188,7 +188,7 @@ func (si *ServerImplementation) LookupAccountByID(ctx echo.Context, accountID st

accounts, round, err := si.fetchAccounts(ctx.Request().Context(), options, params.Round)
if err != nil {
var maxErr idb.MaxAccountNestedObjectsError
var maxErr idb.MaxAPIResourcesPerAccountError
if errors.As(err, &maxErr) {
return ctx.JSON(http.StatusBadRequest, si.maxAccountsErrorToAccountsErrorResponse(maxErr))
}
Expand Down Expand Up @@ -352,7 +352,7 @@ func (si *ServerImplementation) SearchForAccounts(ctx echo.Context, params gener
HasAppID: uintOrDefault(params.ApplicationId),
EqualToAuthAddr: spendingAddr[:],
IncludeDeleted: boolOrDefault(params.IncludeAll),
MaxResources: uint64(si.opts.MaxAccountNestedObjects),
MaxResources: uint64(si.opts.MaxAPIResourcesPerAccount),
}

if params.Exclude != nil {
Expand Down Expand Up @@ -381,7 +381,7 @@ func (si *ServerImplementation) SearchForAccounts(ctx echo.Context, params gener

accounts, round, err := si.fetchAccounts(ctx.Request().Context(), options, params.Round)
if err != nil {
var maxErr idb.MaxAccountNestedObjectsError
var maxErr idb.MaxAPIResourcesPerAccountError
if errors.As(err, &maxErr) {
return ctx.JSON(http.StatusBadRequest, si.maxAccountsErrorToAccountsErrorResponse(maxErr))
}
Expand Down
2 changes: 1 addition & 1 deletion api/handlers_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func TestAccountMaxResultsLimit(t *testing.T) {
serverCtx, serverCancel := context.WithCancel(context.Background())
defer serverCancel()
opts := defaultOpts
opts.MaxAccountNestedObjects = uint64(maxResults)
opts.MaxAPIResourcesPerAccount = uint64(maxResults)
listenAddr := "localhost:8989"
go Serve(serverCtx, listenAddr, db, nil, logrus.New(), opts)

Expand Down
4 changes: 2 additions & 2 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ type ExtraOptions struct {
// ReadTimeout is the maximum duration for reading the entire request, including the body.
ReadTimeout time.Duration

// MaxAccountNestedObjects is the maximum number of combined AppParams, AppLocalState, AssetParams,
// MaxAPIResourcesPerAccount is the maximum number of combined AppParams, AppLocalState, AssetParams,
// and AssetHolding resources per address that can be returned by the /v2/accounts endpoints.
// If an address exceeds this number, a 400 error is returned. Zero means unlimited.
MaxAccountNestedObjects uint64
MaxAPIResourcesPerAccount uint64

/////////////////////
// Limit Constants //
Expand Down
6 changes: 3 additions & 3 deletions cmd/algorand-indexer/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
writeTimeout time.Duration
readTimeout time.Duration
maxConn uint32
maxAccountNestedObjects uint32
maxAPIResourcesPerAccount uint32
maxTransactionsLimit uint32
defaultTransactionsLimit uint32
maxAccountsLimit uint32
Expand Down Expand Up @@ -159,7 +159,7 @@ func init() {
daemonCmd.Flags().DurationVarP(&readTimeout, "read-timeout", "", 5*time.Second, "set the maximum duration for reading the entire request")
daemonCmd.Flags().Uint32VarP(&maxConn, "max-conn", "", 0, "set the maximum connections allowed in the connection pool, if the maximum is reached subsequent connections will wait until a connection becomes available, or timeout according to the read-timeout setting")

daemonCmd.Flags().Uint32VarP(&maxAccountNestedObjects, "max-account-nested-objects", "", 0, "set the max # of combined apps and assets per account supported by /v2/accounts API calls before a 400 error is returned (default: unlimited)")
daemonCmd.Flags().Uint32VarP(&maxAPIResourcesPerAccount, "max-account-nested-objects", "", 0, "set the max # of combined apps and assets per account supported by /v2/accounts API calls before a 400 error is returned (default: unlimited)")

daemonCmd.Flags().Uint32VarP(&maxTransactionsLimit, "max-transactions-limit", "", 10000, "set the maximum allowed Limit parameter for querying transactions")
daemonCmd.Flags().Uint32VarP(&defaultTransactionsLimit, "default-transactions-limit", "", 1000, "set the default Limit parameter for querying transactions, if none is provided")
Expand Down Expand Up @@ -199,7 +199,7 @@ func makeOptions() (options api.ExtraOptions) {
options.WriteTimeout = writeTimeout
options.ReadTimeout = readTimeout

options.MaxAccountNestedObjects = uint64(maxAccountNestedObjects)
options.MaxAPIResourcesPerAccount = uint64(maxAPIResourcesPerAccount)
options.MaxTransactionsLimit = uint64(maxTransactionsLimit)
options.DefaultTransactionsLimit = uint64(defaultTransactionsLimit)
options.MaxAccountsLimit = uint64(maxAccountsLimit)
Expand Down
8 changes: 4 additions & 4 deletions idb/idb.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,17 @@ type AccountQueryOptions struct {
// AccountRow is metadata relating to one account in a account query.
type AccountRow struct {
Account models.Account
Error error // could be MaxAccountNestedObjectsError
Error error // could be MaxAPIResourcesPerAccountError
}

// MaxAccountNestedObjectsError records the offending address and resource count that exceeded the limit.
type MaxAccountNestedObjectsError struct {
// MaxAPIResourcesPerAccountError records the offending address and resource count that exceeded the limit.
type MaxAPIResourcesPerAccountError struct {
Address basics.Address

TotalAppLocalStates, TotalAppParams, TotalAssets, TotalAssetParams uint64
}

func (e MaxAccountNestedObjectsError) Error() string {
func (e MaxAPIResourcesPerAccountError) Error() string {
return "Max accounts API results limit exceeded"
}

Expand Down
2 changes: 1 addition & 1 deletion idb/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ func (db *IndexerDb) checkAccountResourceLimit(ctx context.Context, tx pgx.Tx, o
if resultCount > opts.MaxResources {
var aaddr basics.Address
copy(aaddr[:], addr)
return idb.MaxAccountNestedObjectsError{
return idb.MaxAPIResourcesPerAccountError{
Address: aaddr,
TotalAppLocalStates: totalAppLocalStates,
TotalAppParams: totalAppParams,
Expand Down