Solana devnet fixtures and lockup generator

This commit is contained in:
Leo 2020-08-21 20:48:58 +02:00
parent a04fe2b447
commit 86ccc1c617
5 changed files with 60 additions and 18 deletions

View File

@ -39,6 +39,10 @@ Generate test ETH lockups once the cluster is up:
kubectl exec -it -c tests eth-devnet-0 -- npx truffle exec src/send-lockups.js
Initialize contract on devnet and generate test SOL lockups:
kubectl exec -it guardian-0 -c agent ./devnet_setup.sh
Adjust number of nodes in running cluster:
tilt args -- --num=2

View File

@ -45,6 +45,11 @@ docker_build(
# Ignore target folders from local (non-container) development.
ignore = ["./solana/target", "./solana/agent/target", "./solana/cli/target"],
# See below for --sync-mode caveats.
live_update = [
sync("./solana/devnet_setup.sh", "/usr/src/solana/devnet_setup.sh"),
],
)
# solana smart contract

View File

@ -37,8 +37,6 @@ spec:
volumes:
- name: key-volume
configMap:
# Provide the name of the ConfigMap containing the files you want
# to add to the container
name: bridge-keypair
containers:
- name: guardiand
@ -68,7 +66,7 @@ spec:
image: solana-agent
command:
- /usr/local/bin/agent
- 'Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o' # TODO: program address
- 'Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o'
- 'solana-devnet' # host
- '8899' # rpc port
- '8900' # pubsub/ws port
@ -77,11 +75,6 @@ spec:
- containerPort: 9000
name: grpc
protocol: TCP
volumeMounts:
- name: key-volume
mountPath: /usr/src/solana
- name: key-volume
mountPath: /root/.config/solana
# volumeClaimTemplates:
# - metadata:
# name: guardian-data
@ -90,13 +83,4 @@ spec:
# resources:
# requests:
# storage: 1Gi
---
apiVersion: v1
kind: ConfigMap
metadata:
name: bridge-keypair
namespace: default
data:
# Key with pubkey 6sbzC1eH4FTujJXWj51eQe25cYvr4xfXbJ1vAj7j2k5J
id.json: |
[14,173,153,4,176,224,201,111,32,237,183,185,159,247,22,161,89,84,215,209,212,137,10,92,157,49,29,192,101,164,152,70,87,65,8,174,214,157,175,126,98,90,54,24,100,177,247,77,19,112,47,44,165,109,233,102,14,86,109,29,134,145,132,141]

48
solana/devnet_setup.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/bash
# This script configures the devnet for test transfers with hardcoded addresses.
set -x
# Configure CLI (works the same as upstream Solana CLI)
mkdir -p ~/.config/solana/cli
cat <<EOF > ~/.config/solana/cli/config.yml
json_rpc_url: "http://solana-devnet:8899"
websocket_url: ""
keypair_path: /usr/src/solana/id.json
EOF
# Constants
cli_address=6sbzC1eH4FTujJXWj51eQe25cYvr4xfXbJ1vAj7j2k5J
bridge_address=Bridge1p5gheXUvJ6jGWGeCsgPKgnE3YgdGKRVCMY9o
initial_guardian=5b1869D9A4C187F2EAa108f3062412ecf0526b24
chain_id_ethereum=2
# TODO: use proper confirmation level to avoid retries (except for faucet, which waits for devnet to come up)
retry () {
while ! $@; do
sleep 1
done
}
# Fund our account (as seen in id.json).
retry cli airdrop solana-devnet:9900
# Create the bridge contract at a known address
# OK to fail on subsequent attempts (already created).
cli create-bridge "$bridge_address" "$initial_guardian"
# Create a new SPL token (at a random address)
token=$(cli create-token | grep 'Creating token' | awk '{ print $3 }')
echo "Created token $token"
# Create token account
account=$(cli create-account "$token" | grep 'Creating account' | awk '{ print $3 }')
echo "Created token account $account"
# Mint new tokens owned by our CLI account
retry cli mint "$token" 10000000000 "$account"
# Do lock transactions <3
while : ; do
cli lock "$bridge_address" "$account" "$token" 10 "$chain_id_ethereum" "$((RANDOM % 254))"
sleep 5
done

1
solana/id.json Normal file
View File

@ -0,0 +1 @@
[14,173,153,4,176,224,201,111,32,237,183,185,159,247,22,161,89,84,215,209,212,137,10,92,157,49,29,192,101,164,152,70,87,65,8,174,214,157,175,126,98,90,54,24,100,177,247,77,19,112,47,44,165,109,233,102,14,86,109,29,134,145,132,141]