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

DO NOT MERGE: indexer 2.10.0 #923

Merged
merged 31 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c7d39fb
Use fetch/reset instead of pull for go-algorand in nightly test. (#885)
tzaffi Feb 16, 2022
3cafaad
Configurable query parameters runtime data structures. (#873)
AlgoStephenAkiki Feb 16, 2022
860ed09
Default to including Python go-algorand E2E tests in buildtestdata.sh…
michaeldiamant Feb 18, 2022
6b0ebfd
Temporarily revert to inline glob search (#889)
michaeldiamant Feb 18, 2022
e3ebf75
Ensure query is canceled after account rewind. (#893)
winder Feb 24, 2022
0b6d814
Version bump
algojack Feb 24, 2022
ec1ef09
Revert "Version bump"
algojack Feb 24, 2022
a451371
Version bump
algojack Feb 24, 2022
48035a6
Version bump
algojack Feb 24, 2022
a4687cb
reverting version bump
algojack Feb 24, 2022
1216e79
Disable Parameters in REST API (#892)
AlgoStephenAkiki Feb 24, 2022
df2779c
monitoring dashboard (#876)
shiqizng Feb 24, 2022
2aad7db
Fix e2e test to support inner transactions. (#899)
shiqizng Feb 25, 2022
8d85bf4
Include block-generator and validator as algorand-indexer subcommands…
winder Feb 28, 2022
8b58e4b
Allow Viewing of Disabled Params (#902)
AlgoStephenAkiki Mar 1, 2022
1c0885c
Document instructions for updating Indexer E2E test input (#906)
michaeldiamant Mar 2, 2022
86f2871
Merge branch 'release/2.9.0' into develop
algobarb Mar 2, 2022
4cbb5a1
Merge branch 'develop' of github.com:algorand/indexer into develop
algobarb Mar 2, 2022
534f5a4
Update e2e_subs docs to revise artifact upload process (#910)
michaeldiamant Mar 7, 2022
4eaadeb
Revert imported_tx_per_block change and add new imported_txns gauge. …
shiqizng Mar 7, 2022
5b88518
Enable Validation and Acceptance of New Parameter Configuration (#912)
AlgoStephenAkiki Mar 9, 2022
82b9fe3
Return all inner transactions are returned for logs endpoint. (#915)
algochoi Mar 9, 2022
def3543
Feature flag to disable configurable api parameters. (#917)
winder Mar 10, 2022
ef46a1a
Add CLI doc generation command. (#919)
AlgoStephenAkiki Mar 10, 2022
b303af1
Fix dev mode by addressing off by one error. (#920)
winder Mar 10, 2022
31eec10
Add support for unlimited assets. (#900)
cce Mar 10, 2022
d837231
Bump version to 2.10.0-rc1
Algo-devops-service Mar 10, 2022
4966aa3
Fix validator threads variable. (#927)
winder Mar 15, 2022
44a75e8
Update indirect go module. (#932)
AlgoStephenAkiki Mar 16, 2022
21e8a98
Bump version to 2.10.0
Algo-devops-service Mar 17, 2022
46a1099
Set max account API resource limit to 1000. (#933)
winder Mar 18, 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ commands:
name: Install python and other python dependencies
command: |
sudo apt update
sudo apt -y install python3 python3-pip python3-setuptools python3-wheel libboost-all-dev libffi-dev
sudo apt -y install python3 python3-pip python3-setuptools python3-wheel libboost-math-dev libffi-dev
pip3 install -r misc/requirements.txt

- run:
Expand Down
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.9.0
2.10.0
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ GOLDFLAGS += -X github.com/algorand/indexer/version.CompileTime=$(shell date -u
GOLDFLAGS += -X github.com/algorand/indexer/version.GitDecorateBase64=$(shell git log -n 1 --pretty="%D"|base64|tr -d ' \n')
GOLDFLAGS += -X github.com/algorand/indexer/version.ReleaseVersion=$(shell cat .version)

COVERPKG := $(shell go list ./... | grep -v '/cmd/' | egrep -v '(testing|test|mocks)$$' | paste -s -d, - )

# Used for e2e test
export GO_IMAGE = golang:$(shell go version | cut -d ' ' -f 3 | tail -c +3 )

Expand Down Expand Up @@ -45,7 +47,7 @@ fakepackage: go-algorand
misc/release.py --host-only --outdir $(PKG_DIR) --fake-release

test: idb/mocks/IndexerDb.go cmd/algorand-indexer/algorand-indexer
go test ./... -coverprofile=coverage.txt -covermode=atomic
go test -coverpkg=$(COVERPKG) ./... -coverprofile=coverage.txt -covermode=atomic

lint: go-algorand
golint -set_exit_status ./...
Expand Down Expand Up @@ -75,7 +77,7 @@ test-generate:
test/test_generate.py

nightly-setup:
cd third_party/go-algorand && git pull origin master
cd third_party/go-algorand && git fetch && git reset --hard origin/master

nightly-teardown:
git submodule update
Expand Down
85 changes: 71 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,50 @@ When `--token your-token` is provided, an authentication header is required. For
~$ curl localhost:8980/transactions -H "X-Indexer-API-Token: your-token"
```

## Disabling Parameters

The Indexer has the ability to selectively enable or disable parameters for endpoints. Disabling a "required" parameter will result in the entire endpoint being disabled while disabling an "optional" parameter will cause an error to be returned only if the parameter is provided.

### Viewing the Current Configuration

The Indexer has a default set of disabled parameters. To view the disabled parameters issue:
```
~$ algorand-indexer api-config
```

This will output ONLY the disabled parameters in a YAML configuration. To view all parameters (both enabled and disabled) issue:

```
~$ algorand-indexer api-config --all
```

### Interpreting The Configuration

Below is a snippet of the output from `algorand-indexer api-config`:

```
/v2/accounts:
optional:
- currency-greater-than: disabled
- currency-less-than: disabled
/v2/assets/{asset-id}/transactions:
optional:
- note-prefix: disabled
- tx-type: disabled
- sig-type: disabled
- before-time: disabled
- after-time: disabled
- currency-greater-than: disabled
- currency-less-than: disabled
- address-role: disabled
- exclude-close-to: disabled
- rekey-to: disabled
required:
- asset-id: disabled
```

Seeing this we know that the `/v2/accounts` endpoint will return an error if either `currency-greater-than` or `currency-less-than` is provided. Additionally, because a "required" parameter is provided for `/v2/assets/{asset-id}/transactions` then we know this entire endpoint is disabled. The optional parameters are provided so that you can understand what else is disabled if you enable all "required" parameters.

## Metrics

The `/metrics` endpoint is configured with the `--metrics-mode` option and configures if and how [Prometheus](https://prometheus.io/) formatted metrics are generated.
Expand All @@ -134,20 +178,33 @@ If the maximum number of connections/active queries is reached, subsequent conne

Settings can be provided from the command line, a configuration file, or an environment variable

| Command Line Flag (long) | (short) | Config File | Environment Variable |
| ------------------------ | ------- | -------------------------- | ---------------------------------- |
| postgres | P | postgres-connection-string | INDEXER_POSTGRES_CONNECTION_STRING |
| pidfile | | pidfile | INDEXER_PIDFILE |
| algod | d | algod-data-dir | INDEXER_ALGOD_DATA_DIR |
| algod-net | | algod-address | INDEXER_ALGOD_ADDRESS |
| algod-token | | algod-token | INDEXER_ALGOD_TOKEN |
| genesis | g | genesis | INDEXER_GENESIS |
| server | S | server-address | INDEXER_SERVER_ADDRESS |
| no-algod | | no-algod | INDEXER_NO_ALGOD |
| token | t | api-token | INDEXER_API_TOKEN |
| dev-mode | | dev-mode | INDEXER_DEV_MODE |
| metrics-mode | | metrics-mode | INDEXER_METRICS_MODE |
| max-conn | | max-conn | INDEXER_MAX_CONN |
| Command Line Flag (long) | (short) | Config File | Environment Variable |
|-------------------------------|---------|-------------------------------|---------------------------------------|
| postgres | P | postgres-connection-string | INDEXER_POSTGRES_CONNECTION_STRING |
| pidfile | | pidfile | INDEXER_PIDFILE |
| algod | d | algod-data-dir | INDEXER_ALGOD_DATA_DIR |
| algod-net | | algod-address | INDEXER_ALGOD_ADDRESS |
| algod-token | | algod-token | INDEXER_ALGOD_TOKEN |
| genesis | g | genesis | INDEXER_GENESIS |
| server | S | server-address | INDEXER_SERVER_ADDRESS |
| no-algod | | no-algod | INDEXER_NO_ALGOD |
| token | t | api-token | INDEXER_API_TOKEN |
| dev-mode | | dev-mode | INDEXER_DEV_MODE |
| metrics-mode | | metrics-mode | INDEXER_METRICS_MODE |
| max-conn | | max-conn | INDEXER_MAX_CONN |
| write-timeout | | write-timeout | INDEXER_WRITE_TIMEOUT |
| read-timeout | | read-timeout | INDEXER_READ_TIMEOUT |
| max-api-resources-per-account | | max-api-resources-per-account | INDEXER_MAX_API_RESOURCES_PER_ACCOUNT |
| max-transactions-limit | | max-transactions-limit | INDEXER_MAX_TRANSACTIONS_LIMIT |
| default-transactions-limit | | default-transactions-limit | INDEXER_DEFAULT_TRANSACTIONS_LIMIT |
| max-accounts-limit | | max-accounts-limit | INDEXER_MAX_ACCOUNTS_LIMIT |
| default-accounts-limit | | default-accounts-limit | INDEXER_DEFAULT_ACCOUNTS_LIMIT |
| max-assets-limit | | max-assets-limit | INDEXER_MAX_ASSETS_LIMIT |
| default-assets-limit | | default-assets-limit | INDEXER_DEFAULT_ASSETS_LIMIT |
| max-balances-limit | | max-balances-limit | INDEXER_MAX_BALANCES_LIMIT |
| default-balances-limit | | default-balances-limit | INDEXER_DEFAULT_BALANCES_LIMIT |
| max-applications-limit | | max-applications-limit | INDEXER_MAX_APPLICATIONS_LIMIT |
| default-applications-limit | | default-applications-limit | INDEXER_DEFAULT_APPLICATIONS_LIMIT |

## Command line

Expand Down
202 changes: 202 additions & 0 deletions accounting/eval_preload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
package accounting

import (
"github.com/algorand/go-algorand/data/basics"
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/ledger"
"github.com/algorand/go-algorand/protocol"
)

// Add requests for asset and app creators to `assetsReq` and `appsReq` for the given
// transaction.
func addToCreatorsRequest(stxnad *transactions.SignedTxnWithAD, assetsReq map[basics.AssetIndex]struct{}, appsReq map[basics.AppIndex]struct{}) {
txn := &stxnad.Txn

switch txn.Type {
case protocol.AssetConfigTx:
fields := &txn.AssetConfigTxnFields
if fields.ConfigAsset != 0 {
assetsReq[fields.ConfigAsset] = struct{}{}
}
case protocol.AssetTransferTx:
fields := &txn.AssetTransferTxnFields
if fields.XferAsset != 0 {
assetsReq[fields.XferAsset] = struct{}{}
}
case protocol.AssetFreezeTx:
fields := &txn.AssetFreezeTxnFields
if fields.FreezeAsset != 0 {
assetsReq[fields.FreezeAsset] = struct{}{}
}
case protocol.ApplicationCallTx:
fields := &txn.ApplicationCallTxnFields
if fields.ApplicationID != 0 {
appsReq[fields.ApplicationID] = struct{}{}
}
for _, index := range fields.ForeignApps {
appsReq[index] = struct{}{}
}
for _, index := range fields.ForeignAssets {
assetsReq[index] = struct{}{}
}
}

for i := range stxnad.ApplyData.EvalDelta.InnerTxns {
addToCreatorsRequest(&stxnad.ApplyData.EvalDelta.InnerTxns[i], assetsReq, appsReq)
}
}

// MakePreloadCreatorsRequest makes a request for preloading creators in the batch mode.
func MakePreloadCreatorsRequest(payset transactions.Payset) (map[basics.AssetIndex]struct{}, map[basics.AppIndex]struct{}) {
assetsReq := make(map[basics.AssetIndex]struct{}, len(payset))
appsReq := make(map[basics.AppIndex]struct{}, len(payset))

for i := range payset {
addToCreatorsRequest(&payset[i].SignedTxnWithAD, assetsReq, appsReq)
}

return assetsReq, appsReq
}

// Add requests for account data and account resources to `addressesReq` and
// `resourcesReq` respectively for the given transaction.
func addToAccountsResourcesRequest(stxnad *transactions.SignedTxnWithAD, assetCreators map[basics.AssetIndex]ledger.FoundAddress, appCreators map[basics.AppIndex]ledger.FoundAddress, addressesReq map[basics.Address]struct{}, resourcesReq map[basics.Address]map[ledger.Creatable]struct{}) {
setResourcesReq := func(addr basics.Address, creatable ledger.Creatable) {
c, ok := resourcesReq[addr]
if !ok {
c = make(map[ledger.Creatable]struct{})
resourcesReq[addr] = c
}
c[creatable] = struct{}{}
}

txn := &stxnad.Txn

addressesReq[txn.Sender] = struct{}{}

switch txn.Type {
case protocol.PaymentTx:
fields := &txn.PaymentTxnFields
addressesReq[fields.Receiver] = struct{}{}
// Close address is optional.
if !fields.CloseRemainderTo.IsZero() {
addressesReq[fields.CloseRemainderTo] = struct{}{}
}
case protocol.AssetConfigTx:
fields := &txn.AssetConfigTxnFields
if fields.ConfigAsset == 0 {
if stxnad.ApplyData.ConfigAsset != 0 {
creatable := ledger.Creatable{
Index: basics.CreatableIndex(stxnad.ApplyData.ConfigAsset),
Type: basics.AssetCreatable,
}
setResourcesReq(txn.Sender, creatable)
}
} else {
if creator := assetCreators[fields.ConfigAsset]; creator.Exists {
creatable := ledger.Creatable{
Index: basics.CreatableIndex(fields.ConfigAsset),
Type: basics.AssetCreatable,
}
addressesReq[creator.Address] = struct{}{}
setResourcesReq(creator.Address, creatable)
}
}
case protocol.AssetTransferTx:
fields := &txn.AssetTransferTxnFields
creatable := ledger.Creatable{
Index: basics.CreatableIndex(fields.XferAsset),
Type: basics.AssetCreatable,
}
if creator := assetCreators[fields.XferAsset]; creator.Exists {
setResourcesReq(creator.Address, creatable)
}
source := txn.Sender
// If asset sender is non-zero, it is a clawback transaction. Otherwise,
// the transaction sender address is used.
if !fields.AssetSender.IsZero() {
source = fields.AssetSender
}
addressesReq[source] = struct{}{}
setResourcesReq(source, creatable)
addressesReq[fields.AssetReceiver] = struct{}{}
setResourcesReq(fields.AssetReceiver, creatable)
// Asset close address is optional.
if !fields.AssetCloseTo.IsZero() {
addressesReq[fields.AssetCloseTo] = struct{}{}
setResourcesReq(fields.AssetCloseTo, creatable)
}
case protocol.AssetFreezeTx:
fields := &txn.AssetFreezeTxnFields
creatable := ledger.Creatable{
Index: basics.CreatableIndex(fields.FreezeAsset),
Type: basics.AssetCreatable,
}
if creator := assetCreators[fields.FreezeAsset]; creator.Exists {
setResourcesReq(creator.Address, creatable)
}
setResourcesReq(fields.FreezeAccount, creatable)
case protocol.ApplicationCallTx:
fields := &txn.ApplicationCallTxnFields
if fields.ApplicationID == 0 {
if stxnad.ApplyData.ApplicationID != 0 {
creatable := ledger.Creatable{
Index: basics.CreatableIndex(stxnad.ApplyData.ApplicationID),
Type: basics.AppCreatable,
}
setResourcesReq(txn.Sender, creatable)
}
} else {
creatable := ledger.Creatable{
Index: basics.CreatableIndex(fields.ApplicationID),
Type: basics.AppCreatable,
}
if creator := appCreators[fields.ApplicationID]; creator.Exists {
addressesReq[creator.Address] = struct{}{}
setResourcesReq(creator.Address, creatable)
}
setResourcesReq(txn.Sender, creatable)
}
for _, address := range fields.Accounts {
addressesReq[address] = struct{}{}
}
for _, index := range fields.ForeignApps {
if creator := appCreators[index]; creator.Exists {
creatable := ledger.Creatable{
Index: basics.CreatableIndex(index),
Type: basics.AppCreatable,
}
setResourcesReq(creator.Address, creatable)
}
}
for _, index := range fields.ForeignAssets {
if creator := assetCreators[index]; creator.Exists {
creatable := ledger.Creatable{
Index: basics.CreatableIndex(index),
Type: basics.AssetCreatable,
}
setResourcesReq(creator.Address, creatable)
}
}
}

for i := range stxnad.ApplyData.EvalDelta.InnerTxns {
addToAccountsResourcesRequest(
&stxnad.ApplyData.EvalDelta.InnerTxns[i], assetCreators, appCreators,
addressesReq, resourcesReq)
}
}

// MakePreloadAccountsResourcesRequest makes a request for preloading account data and
// account resources in the batch mode.
func MakePreloadAccountsResourcesRequest(payset transactions.Payset, assetCreators map[basics.AssetIndex]ledger.FoundAddress, appCreators map[basics.AppIndex]ledger.FoundAddress) (map[basics.Address]struct{}, map[basics.Address]map[ledger.Creatable]struct{}) {
addressesReq := make(map[basics.Address]struct{}, len(payset))
resourcesReq := make(map[basics.Address]map[ledger.Creatable]struct{}, len(payset))

for i := range payset {
addToAccountsResourcesRequest(
&payset[i].SignedTxnWithAD, assetCreators, appCreators, addressesReq, resourcesReq)
}

return addressesReq, resourcesReq
}
Loading