Skip to content

Commit

Permalink
update test transactions to use spamooor
Browse files Browse the repository at this point in the history
  • Loading branch information
sambukowski committed Aug 20, 2024
1 parent a5897b7 commit 129ce34
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 88 deletions.
1 change: 0 additions & 1 deletion docs/components/_astria-go-cli-install.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

::: code-group

```bash [ARM Mac]
Expand Down
22 changes: 22 additions & 0 deletions docs/components/_git-clone-and-build-spamooor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
::: code-group

```bash [SSH]
git clone [email protected]:astriaorg/spamooor.git
cd spamooor/
go build ./cmd/spamooor
./spamooor -h
```

```bash [HTTPS]
git clone https://github.com/astriaorg/spamooor.git
cd spamooor/
go build ./cmd/spamooor
./spamooor -h
```

:::

<!-- <Tabs>
<TabItem value="SSH" label="SSH" default> </TabItem>
<TabItem value="HTTPS" label="HTTPS> </TabItem>
</Tabs> -->
4 changes: 0 additions & 4 deletions docs/developer/tutorials/run-local-rollup-and-sequencer.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ Open the `geth-genesis-local.json` file in your Geth repo and update the
You will use the private key for your new account, and the `"chainId"` you chose,
with the [test transactions](./test-transactions.md) later on.

<!-- ## Download and Build the Messenger Rollup
tbd -->

## Start Geth

In your Geth terminal window, run the following to initialize and run the Geth rollup:
Expand Down
137 changes: 54 additions & 83 deletions docs/developer/tutorials/test-transactions.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,70 @@
# Test Transactions

## Configure the Testing Script
## Setup `spamooor`

To run the test transactions script you will need `Foundry`:
- Foundry: <https://book.getfoundry.sh/getting-started/installation>
Clone and build the [`spamooor` transaction spamming
tool](https://github.com/astriaorg/spamooor).

In a new terminal window, clone and configure the evm test transactions repo:
Requirements:

- [Go](https://go.dev/doc/install)

<!--@include: ../../components/_git-clone-and-build-spamooor.md-->

## Configure Your Rollup Account

Make sure you have a local Geth rollup configured and running.
- [Set up a Geth
Rollup](run-local-rollup-against-remote-sequencer.md#setup-a-geth-rollup)

Add your private key from your testing account and the rollup rpc to the environment:

```bash
export PRIV_KEY="<your private key>"
export ROLLUP_RPC="http://localhost:8545"
```

## Setup Your Environment for `spamooor`

There are several `spamooor` settings that you can configure:
- `max-wallets`: The number of child wallets that will be created.
- `throughput`: The number of transactions to send per block.
- `count`: The total number of transfer transactions to send.
- `timeout`: The number of seconds to wait before the `spamooor` test times out.
- `gas-units-to-burn`: The approximate amount of gas your transactions will
burn.

Add these settings to your environment:

```bash
git clone --recurse-submodules [email protected]:astriaorg/astria-web3.git
cd astria-web3
git checkout local-evm
cd packages/evm-test-data/
forge install
cp .env.example .env
export SPAMOOOR_MAX_WALLETS="10"
export SPAMOOOR_THROUGHPUT="50"
export SPAMOOOR_COUNT="100"
export SPAMOOOR_TIMEOUT="20"
export SPAMOOOR_GAS_UNITS_TO_BURN="5000000"
```

Open the `.env` file and update the chain id and private key. The chain id
should match the `"chainId"` value in the `geth-genesis-local.json` file in the
`astria-geth` repo. The private key used here should be the private key for the
account you used when [setting up
Geth](./run-local-rollup-and-sequencer.md#setup-a-geth-rollup) previously:
## Generate Transactions

With your sequencer, rollup, and `spamooor` setup, you can now send test
transactions:

Send transfers:
```bash
# this value should be the same as what you used for configuring Geth above
CHAIN_ID=<6 digit number>
PRIVATE_KEY=<your evm account private key>
./spamooor eoatx --privkey $PRIV_KEY --rpchost $ROLLUP_RPC --max-wallets $SPAMOOOR_MAX_WALLETS --throughput $SPAMOOOR_THROUGHPUT --count $SPAMOOOR_COUNT
```

## Run the Testing Script
Send ERC20 transfers:
```bash
./spamooor erctx --privkey $PRIV_KEY --rpchost $ROLLUP_RPC --max-wallets $SPAMOOOR_MAX_WALLETS --throughput $SPAMOOOR_THROUGHPUT --count $SPAMOOOR_COUNT --timeout $SPAMOOOR_TIMEOUT
```

Send gas burner transactions:
```bash
just generate-transactions
./spamooor gasburnertx --privkey $PRIV_KEY --rpchost $ROLLUP_RPC --max-wallets $SPAMOOOR_MAX_WALLETS --throughput $SPAMOOOR_THROUGHPUT --count $SPAMOOOR_COUNT --timeout $SPAMOOOR_TIMEOUT --gas-units-to-burn $SPAMOOOR_GAS_UNITS_TO_BURN
```

You will see the transactions going through in both the `forge` script and the
log windows in the `astria-go` cli.

:::tip
The test script sends transactions directly to the local rollup running on your
machine. Thus, the transactions will work regardless of whether you are running
everything locally with `astria-go dev run --network local` or if you are running
against a remote sequencer with `astria-go dev run --network dusk`.
:::

## Common Issues

### `EvmError: OutOfFunds`

If you see a an `OutOfFunds` error when running the testing script, this means
that your rollup genesis account was not configured correctly. To fix this
issue:
1. Go back to the `astria-geth` repo.
2. Run `cast w new` to create a new rollup account.
3. Add the new address to the `geth-genesis-local.json` under `"alloc"`.
4. Restart your rollup with `just clean-restart`.
5. Update the `PRIVATE_KEY` env var in the test transactions repo with the
private key from the new account.
6. Rerun the testing script.

### Test script hangs

If you are running against a remote sequencer and the transactions test script
hangs, navigate to the cli TUI and look at the logs for the Composer. You will
likely see an error that contains `sequencer rejected the transaction ...
insufficient funds for asset`. This means that the sequencer account that was
created was either improperly configure or not funded correctly. To fix this
issue:
1. Stop the `astria-go` cli.
2. Create a new sequencer account with `astria-go sequencer createaccount` or
use an existing account if you already have one for testing, and fund the
account using the [Sequencer
Faucet](https://faucet.sequencer.dusk-8.devnet.astria.org/).
3. Make sure the `astria_composer_private_key` variable in the
`~/.astria/default/config/base-config.toml` is set to the private key for your funded
sequencer account.
4. Re-launch the cli with `astria-go dev run --network dusk`.
5. Rerun the transactions testing script.

### Chain Data Mismatch

If you start seeing warning in Composer that say `failed getting latest nonce
from sequencer` or errors in Conductor that say `first latest height from
sequencer was bad`, this likely means that block data on your rollup and the
block data coming from whatever sequencer you are using (either local or remote)
are mismatched. To fix this issue:
1. Stop your rollup and the cli.
2. Restart the rollup with `just clean-restart` and restart the cli with the run
conditions you were using.

This will clean the data your rollup and allow it to resync.

If issues still persist, you can clean the data for the rollup and the sequencer
(if you are running a local sequencer):
1. Stop your rollup and the cli.
2. With the cli run `astria-go dev clean` then `astria-go dev init`.
3. Restart the rollup with `just clean-restart`.
4. Restart the cli with `astria-go dev run`.
Send transactions that will revert:
```bash
./spamooor revertingtx --privkey $PRIV_KEY --rpchost $ROLLUP_RPC --max-wallets $SPAMOOOR_MAX_WALLETS --throughput $SPAMOOOR_THROUGHPUT --count $SPAMOOOR_COUNT
```

0 comments on commit 129ce34

Please sign in to comment.