Git Product home page Git Product logo

sandbox's Introduction

Algorand Sandbox

This is a fast way to create and configure an Algorand development environment with Algod and Indexer.

Docker Compose MUST be installed. Instructions.

On a Windows machine, Docker Desktop comes with the necessary tools. Please see the Windows section in getting started for more details.

Warning: Algorand Sandbox is not meant for production environments and should not be used to store secure Algorand keys. Updates may reset all the data and keys that are stored.

Usage

Use the sandbox command to interact with the Algorand Sandbox.

sandbox commands:
  up    [config]  -> start the sandbox environment.
  down            -> tear down the sandbox environment.
  reset           -> reset the containers to their initial state.
  clean           -> stops and deletes containers and data directory.
  test            -> runs some tests to demonstrate usage.
  enter [algod||conduit||indexer||indexer-db]
                  -> enter the sandbox container.
  dump [algod||conduit||indexer||indexer-db]
                  -> dump log information for a container.
  tail [algod||conduit||indexer||indexer-db]
                  -> tail log information for a container.
  version         -> print binary versions.
  copyTo <file>   -> copy <file> into the algod. Useful for offline transactions, offline LogicSigs & TEAL work.
  copyFrom <file> -> copy <file> from the algod. Useful for offline transactions, offline LogicSigs & TEAL work.

algorand commands:
  logs            -> stream algorand logs with the carpenter utility.
  status          -> get node status.
  goal (args)     -> run goal command like 'goal node status'.
  tealdbg (args)  -> run tealdbg command to debug program execution.

special flags for 'up' command:
  -v|--verbose           -> display verbose output when starting standbox.
  -s|--skip-fast-catchup -> skip catchup when connecting to real network.
  -i|--interactive       -> start docker compose in interactive mode.

Sandbox creates the following API endpoints:

  • algod:
    • address: http://localhost:4001
    • token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  • kmd:
    • address: http://localhost:4002
    • token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  • indexer:
    • address: http://localhost:8980
  • algod (follower):
    • address: http://localhost:3999
    • token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  • conduit:
    • address: http://localhost:3998/metrics

Getting Started

Ubuntu and macOS

Make sure the docker daemon is running and docker-compose is installed.

Open a terminal and run:

git clone https://github.com/algorand/sandbox.git

In whatever local directory the sandbox should reside. Then:

cd sandbox
./sandbox up

This will run the sandbox shell script with the default configuration. See the Basic Configuration for other options.

Note for Ubuntu: You may need to alias docker to sudo docker or follow the steps in https://docs.docker.com/install/linux/linux-postinstall so that a non-root user can use the command docker.

Run the test command for examples of how to interact with the environment:

./sandbox test

Windows

Note: Be sure to use the latest version of Windows 10. Older versions may not work properly.

Note: While installing the following programs, several restarts may be required for windows to recognize the new software correctly.

Option 1: Using WSL 2

The installation instructions for Docker Desktop contain some of this but are repeated here.

  1. In order to work with Docker Desktop on windows, a prerequisite is WSL2 and install instructions are available here.
  2. Install Docker Desktop using the instructions available here.
  3. We recommend using the official Windows Terminal, available in the app store here.
  4. Install whatever distribution of Linux desired.
  5. Open the Windows Terminal with the distribution installed in the previous step and follow the instruction for Ubuntu and macOS above.

Tip: If you are using VSCode, do not forget to use the WSL2 terminal inside VSCode too. You may follow this Microsoft tutorial.

Option 2: Using Git for Windows/ MSYS 2 (not recommended)

This option is not fully tested and may cause issues. It is recommended to use WSL 2.

  1. Install Git for Windows: https://gitforwindows.org/
  2. Install and launch Docker for Windows: https://docs.docker.com/get-docker
  3. Open "Git Bash" and follow the instruction for Ubuntu and macOS above, in the "Git Bash" terminal.
Troubleshooting
  • If you see

    the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'.
    

    check that you are using the latest versions of: Docker, Git for Windows, and Windows 10.

    If this does not solve the issue, open an issue with all the versions with all the software used, as well as all the commands typed.

  • If you see

    Error response from daemon: open \\.\pipe\docker_engine_linux: The system cannot find the file specified.
    

    check that Docker is running.

Basic Configuration

Sandbox supports two primary modes of operation. By default, a private network will be created, which is only available from the local environment. There are also configurations available for the public networks which will attempt to connect to one of the long running Algorand networks and allow interaction with it.

To specify which configuration to run:

./sandbox up $CONFIG

Where $CONFIG is specified as one of the configurations in the sandbox directory.

For example to run a dev mode network, run:

./sandbox up dev

To switch the configuration:

./sandbox down
./sandbox clean
./sandbox up $NEW_CONFIG

Private Network

If no configuration is specified the sandbox will be started with the release configuration which is a private network. The other private network configurations are those not suffixed with net. Namely these are beta, dev and nightly.

The private network environment creates and funds a number of accounts in the algod containers local kmd ready to use for testing transactions. These accounts can be reviewed using ./sandbox goal account list.

Private networks also include an Indexer API service configured to synchronize against the private network. Because it doesn't require catching up to one of the long running networks it also starts very quickly.

The dev configuration starts a private network using the latest release with these algod configuration customizations:

  • "DevMode": true - In dev mode, every transaction being sent to the node automatically generates a new block, rather than wait for a new round in real time. This is extremely useful for fast e2e testing of an application.
  • "RewardsPoolBalance": 0 - Prevents participation rewards by overriding the initial rewards pool balance. In a variety of test scenarios, participation rewards obscure testing Algo balances.

It takes a long time to generate participation keys, so the default configurations use the NETWORK_NUM_ROUNDS parameter to limit how many are created. Unless the default value is changed, the network will stall after 24 hours. Some configurations have been changed so that they can be run for over a week. Review the setting to make sure it is suitable for how you would like to use the sandbox.

Public Network

The mainnet, testnet, betanet, and devnet configurations configure the sandbox to connect to one of those long running networks. Once started it will automatically attempt to catchup to the latest round. Catchup tends to take a while and a progress bar will be displayed to illustrate of the progress.

Due to technical limitations, this configuration does not contain preconfigured accounts that may be immediately transact with, and Indexer is not available. A new wallet and accounts may be created or imported at will using the goal wallet new command to create a wallet and the goal account import or goal account new commands. If a testnet configuration is used, please visit the TestNet Dispenser to fund the newly created account.

Advanced configurations

The sandbox environment is completely configured using the config.* files in the root of this repository. For example, the default configuration for config.nightly is:

export ALGOD_CHANNEL="nightly"
export ALGOD_URL=""
export ALGOD_BRANCH=""
export ALGOD_SHA=""
export NETWORK=""
export NETWORK_TEMPLATE="images/algod/future_template.json"
export NETWORK_NUM_ROUNDS=300000
export NETWORK_BOOTSTRAP_URL=""
export NETWORK_GENESIS_FILE=""
export NODE_ARCHIVAL=""
export INDEXER_URL="https://github.com/algorand/indexer"
export INDEXER_BRANCH="develop"
export INDEXER_SHA=""
export INDEXER_DISABLED=""
export INDEXER_ENABLE_ALL_PARAMETERS="false"
export CONDUIT_URL="https://github.com/algorand/conduit"
export CONDUIT_BRANCH="master"
export CONDUIT_SHA=""
export CONDUIT_DISABLED=""

Indexer and Conduit are always built from source since these can be done quickly. For most configurations, algod will be installed using our standard release channels, but building from source is also available by setting the git URL, branch and optionally a specific SHA commit hash.

The up command looks for the config extension based on the argument provided. With a custom configuration pointed to a fork, the sandbox will start using the fork:

export ALGOD_CHANNEL=""
export ALGOD_URL="https://github.com/<user>/go-algorand"
export ALGOD_BRANCH="my-test-branch"
export ALGOD_SHA=""
export ALGOD_BOOTSTRAP_URL=""
export ALGOD_GENESIS_FILE=""
export INDEXER_URL="https://github.com/<user>/indexer"
export INDEXER_BRANCH="develop"
export INDEXER_SHA=""
export INDEXER_DISABLED=""
export INDEXER_ENABLE_ALL_PARAMETERS="false"
export CONDUIT_URL="https://github.com/<user>/conduit"
export CONDUIT_BRANCH="master"
export CONDUIT_SHA=""
export CONDUIT_DISABLED=""

Indexer Query Parameters

By default Indexer disables many query parameters which are known to have performance problems without specially configured databases. You can identify these parameters if your Indexer calls return a response like the following:

{"message":"provided disabled parameter: tx-type"}

To override the disabled parameters and enable everything, add the following to your config.<name> file:

export INDEXER_ENABLE_ALL_PARAMETERS="true"

Working with files

Some Algorand commands require using a file for the input. For example working with TEAL programs. In some other cases like working with Logical signatures or transactions offline the output from a LogicSig or transaction may be needed.

To stage a file use the copyTo command. The file will be placed in the algod data directory, which is where sandbox executes goal. This means the files can be used without specifying their full path.

To copy a file from sandbox (algod instance) use the copyFrom command. The file will be copied to sandbox directory on host filesystem.

copyTo example

these commands will stage two TEAL programs then use them in a goal command:

~$ ./sandbox copyTo approval.teal
~$ ./sandbox copyTo clear.teal
~$ ./sandbox goal app create --approval-prog approval.teal --clear-prog clear.teal --creator YOUR_ACCOUNT  --global-byteslices 1 --global-ints 1 --local-byteslices 1 --local-ints 1

copyFrom example

these commands will create and copy a signed logic transaction file, created by goal, to be sent or communicated off the chain (e.g. by email or as a QR Code) and submitted else where:

~$ ./sandbox goal clerk send -f <source-account> -t <destination-account> --fee 1000 -a 1000000 -o "unsigned.txn"
~$ ./sandbox goal clerk sign --infile unsigned.txn --outfile signed.txn
~$ ./sandbox copyFrom "signed.txn"

Errors

If something goes wrong, check the sandbox.log file and ./sandbox dump [service] for details.

Debugging for teal developers

For detailed information on how to debug smart contracts and use tealdbg CLI,please consult with Algorand Development Portal :: Debugging smart contracts.

Algorand smart contract debugging process uses tealdbg command line of algod instance(algod container in sandbox).

Note: Always use tealdbg with --listen 0.0.0.0 or --listen [IP ADDRESS] flags, if access is needed to tealdbg from outside of algod docker container!

tealdbg examples

Debugging smart contract with Chrome Developer Tools (CDT): ~$ ./sandbox tealdbg debug ${TEAL_PROGRAM} -f cdt -d dryrun.json

Debugging smart contract with Web Interface (primal web UI) ~$ ./sandbox tealdbg debug ${TEAL_PROGRAM} -f web -d dryrun.json

The debugging endpoint port (default 9392) is forwarded directly to the host machine and can be used directly by Chrome Dev Tools for debugging Algorand TEAL smart comtracts (Goto url chrome://inspect/ and configure port 9392 before using please).

Note: If a different port is needed than the default, it may be changed by running tealdbg --port YOUR_PORT then modifying the docker-compose.yml file and change all occurances of mapped 9392 port with the desired one.

ADVANCED: Sandbox Interactive Debugging with VSCode's Remote - Container Extension

For those looking to develop or extend algod or indexer it's highly recommended to test and debug using a realistic environment. Being able to interactively debug code with breakpoints and introspect the stack as the Algorand daemon communicates with a live network is quite useful. Here are steps that you can take if you want to run an interactive debugger with an indexer running on the sandbox. Analogous instructions work for algod as well.

Before starting, make sure you have VS-Code and have installed the Remote - Containers Extension.

  1. Inside docker_compose.yml add the key/val privileged: true under the indexer: service
  2. Start the sandbox with ./sandbox up YOUR_CONFIG and wait for it to be fully up and running
  • you may need to run a ./sandbox clean first
  • you can verify by seeing healthy output from ./sandbox test
  1. In VS Code...
  2. Go to the Command Palette (on a Mac it's SHIFT-COMMAND-P) and enter Remote - Containers: Attach to Running Container
  3. The container of interest, e.g. /algorand-sandbox-indexer, should pop up and you should choose it
  4. The first time you attach to a container, you'll get the option of choosing which top-level directory inside the container to attach the file browser to. The default HOME (/opt/indexer in the case of indexer) is usually your best choice
  5. Next, VS Code should auto-detect that you're running a go based project and suggest various extensions to add into the container enviroment. You should do this
  6. Now navigate to the file you'd like to debug (e.g. api/handlers.go) and add a breakpoint as you usually would
  7. You'll need to identify the PID of the indexer process so you can attach to it. Choose TerminalNew Terminal from the menu and run ps | egrep "daemon|PID". Note the resulting PID
  8. Now start the debugger with F5. It should give you the option to attach to a process and generate a launch.json with processId: 0 for you
  9. Modify the launch.json with the correct processId. Below I provide an example of a launch.json
  10. Now you're ready to rumble! If you hit your sandbox endpoint with a well formatted request, you should end up reaching and pausing at your break point. For indexer, you would request against port 8980. See the curl example below

Example launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to Process",
      "type": "go",
      "request": "attach",
      "mode": "local",
      "processId": YOUR_PID_HERE
    }
  ]
}

Example curl command

~$ curl "localhost:8980/v2/accounts"

Deep technical details

About pseudo-TTY issues or why do we use the -T flag in dc exec -T everywhere?

Windows Msys / Git Bash does not have a pseudo-TTY. Because of that, any time a command requires a pseudo-TTY, it fails with error:

the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'.

Unfortunately prefixing all commands with winpty is not an option because winpty will break when piping or using command substitution (`...` and $()). The adopted solution is to use a pseudo-TTY only when absolutely required, that is when executing an interactive command such as bash inside docker.

See comments around the commands dc and dc_pty in the file sandbox.

sandbox's People

Contributors

aldur avatar algobarb avatar algochoi avatar algojack avatar barnjamin avatar bbroder-algo avatar btoll avatar d13co avatar emg110 avatar eric-warehime avatar eztierney avatar fabrice102 avatar figurestudios avatar gmalouf avatar jannotti avatar joe-p avatar jzjones avatar kael-shipman avatar kevguy avatar kondurarjun-personal avatar mworzala avatar onetechnical avatar ori-shem-tov avatar overhead525 avatar ryanrfox avatar shiqizng avatar tzaffi avatar vuvoth avatar whyash5114 avatar winder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sandbox's Issues

Allow sandbox commands to be executed from Node

Problem

When a sandbox command is executed from Node (and maybe other platforms) it raises the following error:

Command failed: ... the input device is not a TTY

Solution

An easy fix for this problem is to change the goal_helper function to add the -T parameter as follows:

goal_helper () {
  dc exec -T algod goal "$@"
}

Dependencies

No dependencies

Urgency

Normal

algorand-sandbox-indexer Error: unknown flag: --logfile

hello,
i've found an error building the image of the indexer that restart the container in loop:
Follow the error:


algorand-sandbox-indexer | Connecting to algod:4001 (172.23.0.3:4001)
algorand-sandbox-indexer | saving to 'genesis.json'
algorand-sandbox-indexer | genesis.json         100% |********************************|  1697  0:00:00 ETA
algorand-sandbox-indexer | 'genesis.json' saved
algorand-sandbox-indexer | Error: unknown flag: --logfile

Provide easy way of adding/modifying configs

When you use sandbox today it's hard to change the default values, like if you want to change the algod node to be an archival node, you'd have to change images/algod/setup.py and rebuild everything from scratch. It would be nice if sandbox up could support adding extra configs that would overload the existing default ones, or something similar.

Unable to copy from subdirectories

sandbox copy myfile.teal works well within the sandbox parent directory /path/to/sandbox.

However, running sandbox copy subdir/myfile.teal fails with error:
Error: No such container:path: 434a0b7a05e145b02113d86738b7577bf8a33b8225f8ee2f52666aeebe51cffc:/opt/data/home/user/path/to/sandbox/subdir

I have no problem working with all my files on the parent directory but would be nicer to have a clean and ordered environment.

'docker-compose' replaced by 'docker compose'

Subject of the issue

'docker-compose' command has been replaced by 'docker compose' in Docker Compose v2 causing sandbox bug

Your environment

  • Software version: sandbox commit 5064377
  • Operating System: Ubuntu 20.04

Steps to reproduce

  1. Install docker as specified at https://docs.docker.com/engine/install/ubuntu/
  2. git clone https://github.com/algorand/sandbox.git
  3. cd sandbox
  4. ./sandbox up

Expected behaviour

Sandbox run with the default configuration

Actual behaviour

An error is thrown: Error: docker-compose is not installed.

Sending a payment stops the indexer

Subject of the issue

The indexer becomes unreachable (crashes?) after sending a payment:

$ curl http://127.0.0.1:8980/v2/
{"message":"Not Found"} 

$ sandbox goal clerk send -a 10000000000 -f F3RJ3NHYV55SSHMSF35RKMHFXRD43LJ3SKZV4N2NVUHVUU3DHCMY5DCTW4 -t DNQPINWK4K5QZYLCK7DVJFEWRUXPXGW36TEUIHNSNOFYI2RMPG2BZPQ7DE
Sent 10000000000 MicroAlgos from account F3RJ3NHYV55SSHMSF35RKMHFXRD43LJ3SKZV4N2NVUHVUU3DHCMY5DCTW4 to address DNQPINWK4K5QZYLCK7DVJFEWRUXPXGW36TEUIHNSNOFYI2RMPG2BZPQ7DE, transaction ID: YKML3QPAQEAKEBDYLMJKPBCISCRBWKUHRT45N2HSD443446PB4AQ. Fee set to 1000
Transaction YKML3QPAQEAKEBDYLMJKPBCISCRBWKUHRT45N2HSD443446PB4AQ committed in round 1

$ curl http://127.0.0.1:8980/v2/
curl: (7) Failed to connect to 127.0.0.1 port 8980: Connection refused

Your environment

  • Software version: algod -v
    3.5.1.stable [rel/stable] (commit #aa2fb0ee)
  • Node status if applicable: sandbox goal node status
Last committed block: 1
Time since last block: 84.3s
Sync Time: 0.0s
Last consensus protocol: future
Next consensus protocol: future
Round for next consensus protocol: 2
Next consensus protocol supported: true
Last Catchpoint: 
Genesis ID: sandnet-v1
Genesis hash: U93Rh5bObyZj2D8fbmWldO0UgMZs8988FFoGuBjOUBI=
  • sandbox git
$ git log -1
commit 306e1f5dbef23f28e77ebc4f4889ff6e7f2a0166 (HEAD -> master, origin/master, origin/HEAD)
Author: Will Winder <[email protected]>
Date:   Tue May 17 17:17:27 2022 -0400
  • Operating System details.
    MacOS 12.1 (21C52)
    Apple M1

Steps to reproduce

  1. sandbox reset dev -v
  2. curl http://127.0.0.1:8980/v2/ (to confirm that it's reachable).
  3. sandbox goal clerk send -a 10000000000 -f F3RJ3NHYV55SSHMSF35RKMHFXRD43LJ3SKZV4N2NVUHVUU3DHCMY5DCTW4 -t DNQPINWK4K5QZYLCK7DVJFEWRUXPXGW36TEUIHNSNOFYI2RMPG2BZPQ7DE, wait for it to be finished.
  4. curl http://127.0.0.1:8980/v2/

curl: (7) Failed to connect to 127.0.0.1 port 8980: Connection refused

Expected behaviour

The indexer continues working

Actual behaviour

The indexer becomes unreachable after sending a payment (possibly other) transactions.

More data

sandbox logs:

Watching file: /opt/data/node.log...
could not decode line from JSON: ++++++++++++++++++++++++++++++++++++++++
could not decode line from JSON: Logging Starting
could not decode line from JSON: Telemetry Disabled
could not decode line from JSON: ++++++++++++++++++++++++++++++++++++++++
15:28:45.414        :                RoundConcluded      -       |
15:28:46.151        :                RoundConcluded      -       |
15:29:23.565   1.0.0:              RoundInterrupted      -       |

Indexer logs in docker:

Starting indexer against algod.
Algod not responding... waiting.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Starting indexer against algod.
Connecting to algod:4001 (172.18.0.3:4001)
wget: can't connect to remote host (172.18.0.3): Connection refused
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved
Connecting to algod:4001 (172.18.0.3:4001)
saving to 'genesis.json'
genesis.json         100% |********************************|  2060  0:00:00 ETA
'genesis.json' saved

Reducing default number of participation keys in `dev` mode

Problem

Since the introduction of Falcon keys it takes a lot to bootstrap the sandbox with a private net. It is reasonable to consider dev mode as a “disposable” private net that doesn’t need to stay up for millions of rounds.

Solution

At least in dev mode we should reduce the default number of participation keys generated when we build it.

Dependencies

None

Urgency

Low

Indexer doesn't update transactions

I've been experimenting this tool but I can't seem to figure out why my indexer doesn't get updated.

In the below screenshot, I've queried the indexer before and after doing a transaction but the round doesn't seem to update nor do any of my transactions show up:
image

Am I missing something? I've tried removing the containers, removing the docker images and readding them but the issue seems to persist. Can't see anything obvious in the sandbox.log file either.

Use Indexer release for all but dev configuration

Problem

Currently, sandbox recompiles the indexer from the master branch even for the default release configuration.
This makes sandbox slower to start (compared to downloading an executable) and running a potentially non-fully stable software.

Solution

Use the latest stable release from indexer.
This change may be simpler if the indexer is published as a Debian package.

Urgency

Nice to have.

Docker setup on Windows 10

Subject of the issue

I experienced an issue while using the docker sandbox with Windows10, together with Git bash.

Issue error on the git bash console:
"the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'."

Your environment

OS:
Edition Windows 10 Pro
Version 21H2
Installed on ‎12/‎25/‎2020
OS build 19044.1645
Experience Windows Feature Experience Pack 120.2212.4170.0

Git:
Git for Windows 2.36.0.windows.1 (64-bit)

Docker:
Docker Desktop 4.7.1 (77678)

Steps to reproduce

Following the guide in the git

  1. In the sandbox folder
  2. ./sandbox up -v

Expected behaviour

Not showing the error message

Actual behaviour

Showing the error message:
"the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'."

Remove layers of abstraction on-top of docker-compose

Problem

Right now the sandbox script is a layer of abstraction that exists on-top of docker-compose. If you look at the sandbox channel in discord, most of the issues people have are specific to the sandbox script and issues with docker itself is hard to debug due to it being all embedded within the sandbox script. Having this script offers an attractive ease-of-use, but when it doesn't work it can make things more complicated. Debugging a sandbox problem not only requires docker knowledge, but also sandbox-specific knowledge. In the end, the sandbox script is just another thing that requires maintenance and I'm not sure if it really adds much value.

Solution

I think it will be beneficial if we remove the abstraction layer that sandbox provides and instead rely on docker-compose for the management and configuration of sandbox services. At a high level, this means there is no more sandbox script that needs to be maintained and problems will be easier to debug. It also makes the experience a little easier to configure for those that are already familiar with docker.

For reference, I've created a fork of sandbox that does exactly this. I've also added some functionality in this repo that I think could be beneficial

  • Two files for configuration. .env and docker-compose.yml, both of which are native to the docker environment
  • Easier file management with bind mounts (copyFrom and copyTo can be confusing)
  • Runs with specific UID:GID, making sharing files inside and outside of the container even easier
  • Seemless VSCode devcontainer compatibility (simply clone directly as .devcontainer)
  • Shell with more functionality (add git-prompt.sh and mount ~/.gitconfig) for in container development
  • Option to install PyTeal

Most of this accomplished with docker-compose.yml and Dockerfile changes and is configurable with the docker-compose.yml and .env

Dependencies

Any work on this would require someone familiar with docker, docker-compose, and sandbox. Ideally I think some of the sandbox functionality could be implemented as in-container helper scripts.

Urgency

Low. Sandbox is still usable and support is easy enough to get on the discord, but making the sandbox simpler will be beneficial in the long run.

Update algod / indexer during "up"

There are some cases where it might be useful to update an existing sandbox deployment to generally speed it up (and make it easier to update).

  1. If a set of accounts have been created, on the latest "nightly" release, it might be nice to update to the next nightly version each day.
  2. If a branch is being used it would be very convenient to allow an incremental build as new sources are pushed instead of requiring a full rebuild.
  3. If a mainnet sandbox is all caught up, it would be nice to swap in the new "stable" binaries instead of running catchup again.

This would require changing the Indexer + Algod scripts / Dockerfile's:

Algod

  • if a release channel was used, run update.sh
  • if a branch was used, run git pull && make install

Indexer

  • Run git pull && make install

Urgency

Not a high priority, but would definitely be a time saver and would allow you to be more flexible with updating on the fly (without wasting a ton of time re deploying)

ledger does not have entry

Problem

When I start sandbox by './sandbox up', I get this info:

algod version
12885229569
3.5.1.stable [rel/stable] (commit #aa2fb0ee)
go-algorand is licensed with AGPLv3.0
source code available at https://github.com/algorand/go-algorand

Postgres version
postgres (PostgreSQL) 13.6

algod - goal node status
Last committed block: 12040
Time since last block: 3.2s
Sync Time: 0.0s
Last consensus protocol: https://github.com/algorandfoundation/specs/tree/d5ac876d7ede07367dbaa26e149aa42589aac1f7
Next consensus protocol: https://github.com/algorandfoundation/specs/tree/d5ac876d7ede07367dbaa26e149aa42589aac1f7
Round for next consensus protocol: 12041
Next consensus protocol supported: true
Last Catchpoint:
Genesis ID: sandnet-v1
Genesis hash: ia8oR31STNLo8HHh3Ks95WIo4K8jr+E9DjS+ZkCd9o4=

indexer - health
{
"data": {
"migration-required": false,
"migration-status": "Migrations Complete"
},
"db-available": true,
"errors": [
"fetcher error: HTTP 500: {"message":"ledger does not have entry 12041 (latest 12040, committed 12040)"}\n"
],
"is-migrating": false,
"message": "12040",
"round": 12040,
"version": "(unknown version)"
}

Environment

Docker: 20.10.14
Ubuntu 20.04.4 LTS

Installation crashes

Subject of the issue

Trying to install sandbox on Ubuntu 20.04 but it crashes upon startup.

Your environment

Steps to reproduce

1.uname -a
Linux MBP 5.11.0-40-generic #44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
2. mkdir algorand
3. cd algorand
4. git clone https://github.com/algorand/sandbox.git
5. ./sandbox up dev -v
libtool is required, but wasn't found on this system
make: *** [Makefile:133: crypto/libs/linux/amd64/lib/libsodium.a] Error 1
ERROR: Service 'algod' failed to build: The command '/bin/sh -c /tmp/images/algod/install.sh -d "${BIN_DIR}" -c "${CHANNEL}" -u "${URL}" -b "${BRANCH}" -s "${SHA}"' returned a non-zero code: 2

But libtool is is installed!

Expected behaviour

it should run without crashing:
./sandbox up dev -v

Actual behaviour

See 5. above - it crashes

Support custom `consensus.json` files

Problem

Algod allows for custom consensus.json files as long as they are located in the data directory, but getting a consensus.json file to the data directory requires the copyTo command and several docker up/downs. It would be nice if there was a CLI argument that allowed you to pass your own consensus.json file on ./sandbox up.

Related to #36.

Solution

Add a CLI argument to sandbox for copying a consensus.json file into sandbox.

Stretch goal: read the consensus file and only overwrite/insert consensus config that was changed; don't replace the entire file. This way users could specify "consensus overrides" instead of replacements, and would make the customization more future-proof.

Dependencies

None

Urgency

Not urgent. Would be a nice improvement.

Fix error message when starting with an invalid configuration

Looks like we made a mistake somewhere

./sandbox up asdf
Starting sandbox for: asdf
Could not find config file for 'asdf'.
Valid options: /config, /config, /config, /config, /config, /config, /config, /config, /config, /config, /config, /config

Postgresql 13-alpine issue on Raspberry Pi

Hi,
When I was setting up the sandbox on Raspberry Pi, I realized that the postgresql docker container did not start. There was no error message during the execution of the ./sandbox up -v and the container seemed to be up, but exited after few seconds. It caught my attention during a run of ./sandbox test -v, where curl "localhost:8980/health?pretty" resulted in curl: (56) Recv failure: Connection reset by peer

Docker version:
docker --version Docker version 20.10.5, build 55c4c88
docker-compose -v docker-compose version 1.29.0, build unknown
uname -r 5.10.17-v7+

The logs of the exited postgresql container:

2021-04-06 23:56:38.290 GMT [1] LOG: starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on arm-unknown-linux-gnueabihf, compiled by gcc (Debian 8.3.0-6) 8.3.0, 32-bit 2021-04-06 23:56:38.292 GMT [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2021-04-06 23:56:38.293 GMT [1] LOG: listening on IPv6 address "::", port 5432 2021-04-06 23:56:38.314 GMT [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2021-04-06 23:56:49.042 GMT [1] LOG: **startup process (PID 27) was terminated by signal 11: Segmentation fault** 2021-04-06 23:56:49.088 GMT [1] LOG: aborting startup due to startup process failure 2021-04-06 23:56:50.083 GMT [1] LOG: database system is shut down

So far, what worked for me as fix is a modification of the docker-compose.yml to change it from postgresql:13-alpine to postgres:13.

Findings:
The issue is related to the alpine image itself.
docker-library/postgres#812 (comment)
You need to update Docker to 19.03.9 or newer and libseccomp (on your host) to 2.4.2 or newer.
Fix:

wget http://ftp.debian.org/debian/pool/main/libs/libseccomp/libseccomp-dev_2.5.1-1_armhf.deb 
wget http://ftp.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb
sudo dpkg -i libseccomp-dev_2.5.1-1_armhf.deb
sudo dpkg -i libseccomp_2.5.1-1_armhf.deb

However, It might be worth adding the health check option to ensure the postgresql not only started, but keep running (e.g. in this case it exited after 10-50s): https://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y/41854997#41854997

Feel free to close the issue, just wanted to post it in case someone else comes across the same problem, so they have a solution to it.

Accounts for private network

Hi,

"By default you will be given access to a private network. This environment is preloaded with a number of accounts ready to use for testing transactions, and includes an Indexer service configured to synchronize against the private network. Because it doesn't require catching up to one of the long running networks it also starts very quickly."

Can you please explain how to get the information for these accounts to use in test transactions?

Thank you,
Chris

Stuck on go-jmespath

It's trying to download go-jmespath v.0.0.3 and it gets stuck there when it's trying to docker compose in gitbash.

Then the whole process fails.

Can you see if there's meant to be that version?

It's attempting to visit the following repository and it gets stuck there --> going to it, that site fails.
https://github.com/jmespath/go-jmespath%20v0.3.0


github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=

Dev mode for indexer as well

Problem

The dev mode for the sandbox is a nice feature that allows for rapid transactions to be made during development and testing. However, the indexer does not keep up with algod in this mode. In fact, it takes longer for the indexer to recognize new transactions and add them to the index, than it does in "normal" mode for the transaction to confirm and then be added to the index. Because of this we cannot use the dev mode because we need to get data from the indexer as part of our process.

Steps to reproduce:

const indexerPort = 8980;
const baseServer = "http://localhost";
const token = { 'X-Algo-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' };
const port = 4001;
const algosdk = require('algosdk');
const indexer = new algosdk.Indexer(token, baseServer, indexerPort);
const algod = new algosdk.Algodv2(token, baseServer, port); kmdToken = { 'X-KMD-API-Token': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' };
const account = algosdk.mnemonicToSecretKey('knock olive prevent shield poem ranch card movie sudden jeans wrist december stock manual lucky umbrella twist wet output surround venture limit jar abstract jelly');
// fill up RDCLUJUWYJP77SQAG5HSTTW3X7WWMKMG6VLGE3S7IZR6LKMYDJR3YZ5BPY with ALGOs

function sleep(seconds) {
  const ms = seconds * 1000;
  return new Promise((resolve) => setTimeout(resolve, ms));
}

async function waitForTx(txId) {
  while (true) {
  try {
    await indexer.lookupTransactionByID(txId).do()
    break;
  } catch (e) {
    await sleep(0.5)
  }
}
}

async function timeIndexer() {
  const params = await algod.getTransactionParams().do();

  const txn = {
    ...params,
    to: account.addr,
    from: account.addr,
    amount: 0
  }

  const signed = algosdk.signTransaction(txn, account.sk);

  // Start timer
  console.time("indexer confirmed in")

  const sent = await algod.sendRawTransaction(signed.blob).do();
  const txId = sent.txId;
  await waitForTx(txId);

  console.timeEnd("indexer confirmed in")
}

with dev mode:

> await timeIndexer(); await timeIndexer(); await timeIndexer(); await timeIndexer(); await timeIndexer();
indexer confirmed in: 24.345s
indexer confirmed in: 1:00.348 (m:ss.mmm)
indexer confirmed in: 59.795s
indexer confirmed in: 1:00.264 (m:ss.mmm)
indexer confirmed in: 59.758s

consecutive calls of await timeIndexer() show that the indexer only checks for new transactions every minute, and therefore cause delays in tests by up to one minute, making dev mode unusable with indexer based things

with standard sandbox:

> await timeIndexer(); await timeIndexer(); await timeIndexer(); await timeIndexer(); await timeIndexer();
indexer confirmed in: 11.207s
indexer confirmed in: 12.182s
indexer confirmed in: 12.145s
indexer confirmed in: 12.178s
indexer confirmed in: 11.637s

Solution

Have dev mode algod ping the indexer somehow to try to get new transactions whenever a block is created.
Or at minimum reduce the dev mode indexer to check for transactions more often (every few seconds or so)

Dependencies

Urgency

The dev mode is unusable for us (and I'm sure many other groups as well) without rapid indexing.

Handle 'cannot connect to Docker daemon' correctly

Minor issue when running './sandbox up' on OS X when the Docker daemon has been turned off. Sandbox util incorrectly reports progress, while also showing errors from Docker.

`Building a new Docker Image...
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERRO[0000] failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: connection refused

Starting a new Docker Container...
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

Sandbox started! Printing status...
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?`

Fix: Correct flow to exit out if daemon is not running or update bolded status messages to indicate issue.

Use a single docker image for all sandbox components as an alternative to the current docker-compose structure

Problem

The problem with the current Docker Compose structure of the Sandbox occurs when there is necessity to execute the sandbox inside a Docker environment if DinD (Docker-in-Docker) is not available.

For example, Gitlab.com CI/CD allows executions of pipeline code inside a given Docker image, and doesn't allow Docker-in-Docker images. Using a single image that exposes all the components and can be uploaded to a repository, it would be possible to extend it (i.e. using apk if based on Alpine Linux) and prepare it for Test execution.

Solution

Prepare a single Dockerfile that merges all the components (postgres DB, indexer and algod) in one single image.
This image would be usable with standard docker build and docker run <image_name> command.

The solution could be implemented without impacts on the current structure, just as a separate component and not as a substitution of the current one. Current working software that uses the current Sandbox structure would not be affected.

Dependencies

None

Urgency

Not urgent, but useful in an ongoing project.

Improve output in case of error

Problem

Sometimes the sandbox fails but does not clearly indicates it so.
If the user is unfamiliar with sandbox, they may not realize that it did not start properly.

See for example:

Solution

Have something that catches errors systematically and display a clear error message at the end:

ERROR: Something went wrong. Please look at sandbox.log and read https://github.com/algorand/sandbox#errors

(in case -v is not provided)

ERROR: Something went wrong. Please look at the error above and read https://github.com/algorand/sandbox#errors

(in case -v is provided)

where https://github.com/algorand/sandbox#errors is extended to give usual ways of fixing errors, including:

  • check you are on the latest version (git ...)
  • check that nothing is listening on ...
  • reset the sandbox (warning clear up everything)
  • reset Docker

See https://medium.com/@dirk.avery/the-bash-trap-trap-ce6083f36700 on how to trap errors.

Dependencies

Urgency

Algod doesn't start on hotspot wifi

Subject of the issue

If I run ./sandbox up while using a hotspot for WIFI, I get the following error service "algod" is not running container #1, and I am unable to use sandbox.

Your environment

Processor/kernel info:
Darwin Tallys-MacBook-Air.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101 arm64
MacOS info:
System Version: macOS 12.0.1 (21A559)

Steps to reproduce

  1. use personal hotspot for wifi
  2. git clone https://github.com/algorand/sandbox.git
  3. cd sandbox
  4. ./sandbox up

Expected behaviour

behavior as described by the readme

Actual behaviour

algod" is not running container #1

sandbox running in Github Actions fails with `the input device is not a TTY`

Subject of the issue

I've tried setting it up sandbox as a service for my test workflow:
https://github.com/CareBoo/unity-algorand-sdk/blob/66efbd3c969242610fdb994095dd7eae0ecae9ff/.github/workflows/test.yaml

but I'm running into the input device is not a TTY

Your environment

Github Action runner:
https://github.com/CareBoo/unity-algorand-sdk/blob/66efbd3c969242610fdb994095dd7eae0ecae9ff/.github/workflows/test.yaml

Steps to reproduce

  1. Create a ubuntu github workflow with the following steps:
steps:
  - uses: actions/checkout@v2
    with:
      repository: algorand/sandbox
      path: sandbox
  - run: |
    cd sandbox
    ./sandbox up -v
  1. Run the workflow

Expected behaviour

the services should run successfully with an exit code of 0

Actual behaviour

the services fail with the input device is not a TTY and exits 1

unable to connect to indexer REST endpoint on local sandbox

./sandbox test output:

...

Test Indexer REST API...
~$ curl "localhost:8980/health?pretty"
curl: (56) Recv failure: Connection reset by peer

./sandbox version

algod version
8590262278
2.5.6.stable [rel/stable] (commit #219b78d9)
go-algorand is licensed with AGPLv3.0
source code available at https://github.com/algorand/go-algorand

Indexer version
2.3.4 compiled at 2021-05-18T10:21:23+0000 from git hash 1cfd8bb4c9abbb02d7830bddaf47686742eb4693 (modified)

Postgres version
postgres (PostgreSQL) 13.3
  • I am running on pop-os 20.10 (ubuntu debian)

The indexer write only the first 513 rounds in dev mode.

The indexer write only the first 513 rounds in dev mode.

When launched in dev mode, the indexer stops the synchronization with algod after 513 rounds.

Environment

  • Software version: 3.3.137611.dev
  • Node status:
    • Last committed block: 742
    • Time since last block: 53.1s
    • Sync Time: 0.0s
    • Last consensus protocol: future
    • Next consensus protocol: future
    • Round for next consensus protocol: 743
    • Next consensus protocol supported: true
    • Last Catchpoint:
    • Genesis ID: sandnet-v1
    • Genesis hash: yvolBA1KcmMsdHI1DZDwzfe1fH9AXW9xoxBOWbuSU20=
  • Operating System: macOS Monterey 12.2.1

Steps to reproduce

  1. Install a new sandbox in dev mode:
./sandbox clean
./sandbox up dev -v
  1. Run a large number of transactions

Expected behavior

The indexer_db is updated as transactions are committed.

Actual behavior

The indexer_db is no longer updated after round 513 (see blocks_header table)

use-snapshot flag does not use a snapshot

--use-snapshot actually skips downloading the snapshot.

The introduction says to start a testnet node with ./sandbox up testnet --use-snapshot but then it takes forever to sync.

Lock version of stable/nightly to git commits

From Discord:

image

It seems that sandbox currently downloads the latest version available for stable/nightly rather than manually upgraded via SCM so each algod/indexer version is guaranteed a separate git commit.

This makes the stability of the sandbox worse than it has to be, as new versions of the algod/indexer can be pushed and break the sandbox unless you upgrade the sandbox at the same time.

Instead I propose we hardcode the current version to be downloaded of algod/indexer so developers using the sandbox can always be sure that the sandbox works for day-to-day work without interruptions. Then when developers using the sandbox is ready to upgrade, they can pull down the latest git commits and therefore get the latest stable/nightly versions instead.

Unexpected behaviour with Docker 4.4.2 on macOS 12.1

Subject of the issue

When updating docker to version 4.4.2 the sandbox script will error when performing ./sandbox up -v However it still successfully launches the containers.
After successfully launching the containers, the following error is given before fully completing the output:

 ./sandbox up -v

Bringing up existing sandbox: 'c2c'
.clean file NOT FOUND. Sandbox images will NOT be rebuilt.
* docker-compose up -d
[+] Running 3/3
 ⠿ Container algorand-sandbox-algod     Started                                                                                 0.3s
 ⠿ Container algorand-sandbox-postgres  Started                                                                                 0.2s
 ⠿ Container algorand-sandbox-indexer   Started                                                                                 1.0s

#
#... Cut out some prints.
#

Available accounts
~$ ./sandbox goal account list


Example command to send between two accounts:
./sandbox: line 460: ACCOUNTS[1]: unbound variable

I also came across this issue when trying to pipe the output of ./sandbox goal account list | awk '{print $3}' and it will completely ignore the pipe and just output the full account details.

It feels as though the latest Docker version has changed how the output is presented from the container. Piping the data is completely ignored, but if I enter the algod container and run the same command (goal account list | awk '{print $3}') it works fine. So it's the output from docker.

I updated a couple of the docker-compose exec calls in the script to use the -T flag and things somewhat started working again, but it wasn't a comprehensive solution so I went back to docker version 4.3.1 for the time being.

Your environment

algod version
12885100837
3.3.133413.dev [feature/contract-to-contract] (commit #83bccc5c)
go-algorand is licensed with AGPLv3.0
source code available at https://github.com/algorand/go-algorand

MacBook Pro M1 running macOS Monterey version 12.1

Steps to reproduce

  1. Use Docker version 4.4.2
  2. Launch sandbox with ./sandbox up -v

Quicknet

Problem

Developers might want to test transactions faster, or test a full deployment, or run unit tests without having to wait for minutes for multiple transactions to finish.

Solution

A network that processes transactions almost immediately.

Dependencies

?

Urgency

Low urgency.

Change config.release indexer branch back to master

Sandbox depends on some features that are not yet in indexer's master branch. To workaround this the release configuration builds with indexer's develop branch. On the next indexer release we should change the release config to use master.

Indexer `v2.10.0` disables query parameters that were previously enabled and results in different behaviour

Subject of the issue

I had a few reports that unit tests for SCs relying on the sandbox and the indexer are failing since indexer release 2.10.0, because of the latest changes to query parameters.

Specifically, they would need tx-type to be enabled for /v2/transactions, but the default config has it disabled.

/v2/transactions:
    optional:
        - limit: enabled
        - next: enabled
        - note-prefix: disabled
        - tx-type: disabled

Has anyone thought about how to address this in the sandbox? I can provide a PR that either enables all parameters for the indexer or reads from a custom configuration file.

Steps to reproduce

  1. Compile dev sandbox (with indexer)
  2. Run unit tests relying on /v2/transactions?tx-type=X

Expected behaviour

Successful tests.

Actual behaviour

{
    "message": "provided disabled parameter: tx-type"
}

Private Network Mode

Summary:

There should be a way to start a private network inside the sandbox. For a lot of development work there is no need to be connected to a real network, or a real network would even make things less convenient since there will naturally be activity outside of your control.

Running from a private network also would allow us to do other cool things, like add an indexer node.

An environment like that should give immediate access to all the genesis funds and let you do things like create assets then query their metadata with indexer to see how the different services work together.

Requirements/Solution design

Likely forking the sandbox and pulling in features from the sdk test env (making it nice to use)

Urgency

@winder gets asked about this frequently by devrel, it's hard to configure and spin up sandbox. It would also be a way of cleaning up the test env by splitting out that code. @ejbaran is also thinking about building a coding playground which this could help.

Notes:

This is functionality used by a lot of people, we need to discuss how this could be turned into a supported feature.

Window 11 the input device is not a TTY .

I'm using window 11, docker version 4.2.0 I'm facing this errror: "the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'.
Any solution for this? I'm trying to learn pyteal but facing this issue.

Weird behavior after dockerd restart

Behavior

When you restart the docker daemon only the indexer container restarts with it.

Expected behavior

The indexer container should not start itself automatically.

Notes

This is almost certainly related to the hack used to keep restarting indexer until the postgres container finishes being initialized. In the docker-compose.yml file there are lines like this:

    restart: unless-stopped

These lines should be removed and images/indexer/start.sh should be modified with a retry mechanism. If we had a retry function it could go here:

 if [ ! -z "$DISABLED" ]; then
   disabled
 elif [ -z "${SNAPSHOT}" ]; then
-  start_with_algod
+  retry_for_60_seconds start_with_algod
 else    
-  import_and_start_readonly
+  retry_for_60_seconds import_and_start_readonly
 fi

Improve Docker Error Handling

As a sandbox user, having concise, meaningful error handling for the required Docker environment is helpful.

Sandbox 1.0 had helpful output:

# sandbox commit 2a34519
./sandbox up

Building a new Docker Image...
 [|]  Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
    
Initializing data directory for testnet...
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

Sandbox 2.0 could be improved:

# commit 0c15c8f
./sandbox up       

Starting default sandbox: nightly
see sandbox.log for detailed progress, or use -v.
* started!

algod version
Traceback (most recent call last):
  File "site-packages/urllib3/connectionpool.py", line 677, in urlopen
  File "site-packages/urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "site-packages/docker/transport/unixconn.py", line 43, in connect
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/requests/adapters.py", line 449, in send
  File "site-packages/urllib3/connectionpool.py", line 727, in urlopen
  File "site-packages/urllib3/util/retry.py", line 403, in increment
  File "site-packages/urllib3/packages/six.py", line 734, in reraise
  File "site-packages/urllib3/connectionpool.py", line 677, in urlopen
  File "site-packages/urllib3/connectionpool.py", line 392, in _make_request
  File "http/client.py", line 1252, in request
  File "http/client.py", line 1298, in _send_request
  File "http/client.py", line 1247, in endheaders
  File "http/client.py", line 1026, in _send_output
  File "http/client.py", line 966, in send
  File "site-packages/docker/transport/unixconn.py", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionRefusedError(61, 'Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/docker/api/client.py", line 205, in _retrieve_server_version
  File "site-packages/docker/api/daemon.py", line 181, in version
  File "site-packages/docker/utils/decorators.py", line 46, in inner
  File "site-packages/docker/api/client.py", line 228, in _get
  File "site-packages/requests/sessions.py", line 543, in get
  File "site-packages/requests/sessions.py", line 530, in request
  File "site-packages/requests/sessions.py", line 643, in send
  File "site-packages/requests/adapters.py", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(61, 'Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 67, in main
  File "compose/cli/main.py", line 123, in perform_command
  File "compose/cli/command.py", line 69, in project_from_options
  File "compose/cli/command.py", line 132, in get_project
  File "compose/cli/docker_client.py", line 43, in get_client
  File "compose/cli/docker_client.py", line 170, in docker_client
  File "site-packages/docker/api/client.py", line 188, in __init__
  File "site-packages/docker/api/client.py", line 213, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', ConnectionRefusedError(61, 'Connection refused'))
[78933] Failed to execute script docker-compose

'sandbox enter algod' not working on Windows

atref@DESKTOP-R0MTNJK MINGW64 ~/Documents/sandbox (master)
$ ./sandbox enter algod

Entering /bin/bash session in the algod container...
OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "C:/Program Files/Git/usr/bin/bash.exe": stat C:/Program Files/Git/usr/bin/bash.ex
e: no such file or directory: unknown

I think the reason is that git-bash was installed on my computer to: C:\Program Files\Git\git-bash.exe

Support devmode networks

Problem

While it is possible to start a devmode local network by copying a network_template.json into the images/algod directory, it would be nice if there was a config.devmode file available so starting a local devmode network would be as simple as ./sandbox up devmode.

Solution

Include a devmode_template.json network template in the images/algod directory and add a config.devmode file similar to config.release but with a different NETWORK_TEMPLATE.

Dependencies

None.

Urgency

Not urgent. Would be a nice improvement.

Issues setting up sandbox on Windows 10 - and discovered a fix

Hello, so I had some issues setting up sandbox on Windows 10 with docker and git bash. Went through the steps exactly. There is a strange error about “the input device is not a TTY” which is related to git bash. The symptoms are that you can’t see much of the output text from sandbox. However, I solved the issue with a one line change in the sandbox code. See these screenshots

It's basically this problem - seems git bash and docker can cause issues without adding 'winpty' in front of commands https://stackoverflow.com/questions/48623005/docker-error-the-input-device-is-not-a-tty-if-you-are-using-mintty-try-prefi/49965690

image
image

ConnectionRefusedError

Subject of the issue

I am trying test a connection and I got this ConnectionRefusedError.

I am using Sandbox.

would appreciate any help.

attached is the screen shot.

Thanks!
Uploading image.jpg…

Your environment

Steps to reproduce

Expected behaviour

Actual behaviour

Compile node from source

It would be nice to have a feature to compile the node from source (given a git repository perhaps) instead of using the latest release.

I implemented this for personal use which I can submit as a PR, but I am not super excited about how I did it.

unbale to start the sandbox in windows

Subject of the issue

unable to run the sandbox

ZEUS@DESKTOP-NDIDRTG MINGW64 ~/Desktop/Algorand/sandbox (master)
$ ./sandbox up -v

Starting default sandbox: release

  • docker-compose up -d
    Building indexer
    [+] Building 25.3s (12/12) FINISHED
    => [internal] load build definition from Dockerfile 1.7s
    => => transferring dockerfile: 611B 0.1s
    => [internal] load .dockerignore 1.1s
    => => transferring context: 67B 0.0s
    => [internal] load metadata for docker.io/library/golang:1.17.5-alpine 15.5s
    => [auth] library/golang:pull token for registry-1.docker.io 0.0s
    => [1/7] FROM docker.io/library/golang:1.17.5-alpine@sha256:4918412049183afe42f1ecaf8f5c2a88917c2eab153ce5ecf4bf2d55c1507b74 0.0s
    => [internal] load build context 0.5s
    => => transferring context: 3.55kB 0.0s
    => CACHED [2/7] WORKDIR /opt/indexer 0.0s
    => CACHED [3/7] RUN apk add --no-cache git bzip2 make bash libtool boost-dev autoconf automake g++ 0.0s
    => CACHED [4/7] COPY images/indexer/disabled.go /tmp/disabled.go 0.0s
    => CACHED [5/7] COPY images/indexer/start.sh /tmp/start.sh 0.0s
    => CACHED [6/7] COPY images/indexer/install.sh /tmp/install.sh 0.0s
    => ERROR [7/7] RUN /tmp/install.sh 7.3s

[7/7] RUN /tmp/install.sh:
#12 1.587 Cloning into '/opt/indexer'...
#12 6.608 fatal: unable to access 'https://github.com/algorand/indexer/': Could not resolve host: github.com


executor failed running [/bin/sh -c /tmp/install.sh]: exit code: 128
ERROR: Service 'indexer' failed to build : Build failed

executor failed running [/bin/sh -c /tmp/install.sh]: exit code: 128
ERROR: Service 'indexer' failed to build : Build failed

Your environment

Steps to reproduce

Expected behaviour

Actual behaviour

docker compose setup /node/algod error

Subject of the issue

I'm following https://developer.algorand.org/docs/sdks/go/
with sudo docker-compose up, and I get an error no such file /node/algod

Your environment

Ubuntu 20.04

Steps to reproduce

  1. Follow the tutorial

Expected behaviour

  • algorand dev testnet installs

Actual behaviour

BINDIR=/usr/bin/algod sudo docker-compose up
WARNING: The ALGOD_CHANNEL variable is not set. Defaulting to a blank string.
WARNING: The ALGOD_URL variable is not set. Defaulting to a blank string.
WARNING: The ALGOD_BRANCH variable is not set. Defaulting to a blank string.
WARNING: The ALGOD_SHA variable is not set. Defaulting to a blank string.
WARNING: The NETWORK_BOOTSTRAP_URL variable is not set. Defaulting to a blank string.
WARNING: The NETWORK_GENESIS_FILE variable is not set. Defaulting to a blank string.
WARNING: The INDEXER_URL variable is not set. Defaulting to a blank string.
WARNING: The INDEXER_BRANCH variable is not set. Defaulting to a blank string.
WARNING: The INDEXER_SHA variable is not set. Defaulting to a blank string.
WARNING: The INDEXER_DISABLED variable is not set. Defaulting to a blank string.
Building algod
Step 1/24 : ARG GO_VERSION=1.17.5
Step 2/24 : FROM golang:$GO_VERSION
 ---> 276895edf967
Step 3/24 : ARG CHANNEL=nightly
 ---> Using cache
 ---> 3adefabf56da
Step 4/24 : ARG URL=
 ---> Using cache
 ---> 0a5c2b16cdc0
Step 5/24 : ARG BRANCH=
 ---> Using cache
 ---> 27a9a183f9c0
Step 6/24 : ARG SHA=
 ---> Using cache
 ---> 3ac173148fb8
Step 7/24 : ARG GENESIS_FILE=""
 ---> Using cache
 ---> d6d5d7d41284
Step 8/24 : ARG BOOTSTRAP_URL=""
 ---> Using cache
 ---> 5e027cbef45c
Step 9/24 : ARG ALGOD_PORT=""
 ---> Using cache
 ---> d266c2a0480d
Step 10/24 : ARG KMD_PORT=""
 ---> Using cache
 ---> 4700f8133eeb
Step 11/24 : ARG TOKEN=""
 ---> Using cache
 ---> eadc6a1ccb3c
Step 12/24 : ARG TEMPLATE=""
 ---> Using cache
 ---> 1e58a4c38bb7
Step 13/24 : RUN echo "Installing from source. {URL} --URL−−{BRANCH}"
 ---> Using cache
 ---> 3a668828181a
Step 14/24 : ENV BIN_DIR="$HOME/node"
 ---> Using cache
 ---> 0847a59cbc2b
Step 15/24 : ENV ALGORAND_DATA="/opt/data"
 ---> Using cache
 ---> 2276de1ccac5
Step 16/24 : ENV HOME /opt
 ---> Using cache
 ---> 1b1d27ac10db
Step 17/24 : ENV DEBIAN_FRONTEND noninteractive
 ---> Using cache
 ---> 381f0a92b49b
Step 18/24 : RUN apt-get update && apt-get install -y apt-utils curl git git-core bsdmainutils python3
 ---> Using cache
 ---> 882797db409f
Step 19/24 : COPY . /tmp
 ---> Using cache
 ---> da596d3cb53c
Step 20/24 : RUN /tmp/images/algod/install.sh     -d "{BIN_DIR}"     -c "BIN 
D
​
 IR"−c"{CHANNEL}"     -u "{URL}"     -b "URL"−b"{BRANCH}"     -s "${SHA}"
 ---> Running in a1c679e22621
/tmp/images/algod /go
Installing algod with options:
  BINDIR = /node
  CHANNEL = 
  URL = 
  BRANCH = 
  SHA = 
/tmp/images/algod/install.sh: line 75: /node/algod: No such file or directory
ERROR: Service 'algod' failed to build: The command '/bin/sh -c /tmp/images/algod/install.sh     -d "{BIN_DIR}"     -c "BIN 
D
​
 IR"−c"{CHANNEL}"     -u "{URL}"     -b "URL"−b"{BRANCH}"     -s "${SHA}"' returned a non-zero code: 127
export BINDIR=/usr/bin/algod sudo docker-compose up
-bash: export: `docker-compose': not a valid identifier
^Cport BINDIR=/usr/bin/algod sudo docker-compose up
^C
^C
algod -v
12885032963
3.2.3.stable [rel/stable] (commit #d2289a52)
go-algorand is licensed with AGPLv3.0
source code available at https://github.com/algorand/go-algorand

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.