testnet upgrade
Signed-off-by: Valentyn Faychuk <valy@detee.ltd>
This commit is contained in:
parent
780c1e54a3
commit
5da08f59c3
@ -42,3 +42,6 @@ tonic-build = "0.12"
|
|||||||
[patch.crates-io.curve25519-dalek]
|
[patch.crates-io.curve25519-dalek]
|
||||||
git = "https://github.com/anza-xyz/curve25519-dalek.git"
|
git = "https://github.com/anza-xyz/curve25519-dalek.git"
|
||||||
rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464"
|
rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
test = []
|
@ -34,42 +34,61 @@ function build_mint_sol_tool() {
|
|||||||
source "${script_dir}/build-container.sh"
|
source "${script_dir}/build-container.sh"
|
||||||
build_mint_sol_tool
|
build_mint_sol_tool
|
||||||
|
|
||||||
# Cleanup old containers and run the network root
|
# Cleanup old containers and the network
|
||||||
docker ps -a | grep 'hacker-challenge' | awk '{ print $NF }' | xargs docker rm -f || true
|
echo "Creating the network and the root node"
|
||||||
|
docker ps -a | grep 'dthc' | awk '{ print $NF }' | xargs docker rm -f || true
|
||||||
|
docker network inspect dthc > /dev/null 2>&1 \
|
||||||
|
|| docker network create --subnet=172.18.0.0/16 dthc \
|
||||||
|
|| true
|
||||||
|
|
||||||
echo "Waiting for the network root to start"
|
function run_node() {
|
||||||
docker run --device /dev/sgx/enclave \
|
custom_flags=$1
|
||||||
--device /dev/sgx/provision \
|
docker run --network dthc -d "${custom_flags}" \
|
||||||
--name "hacker-challenge" \
|
--device /dev/sgx/provision \
|
||||||
-d detee/hacker-challenge:latest
|
--device /dev/sgx/enclave \
|
||||||
|
detee/hacker-challenge:latest
|
||||||
|
}
|
||||||
|
|
||||||
|
root_ip="172.18.0.1"
|
||||||
|
|
||||||
|
echo "Waiting for the root node to start"
|
||||||
|
run_node "--name dthc-root --ip ${root_ip}"
|
||||||
while true; do
|
while true; do
|
||||||
echo -n "." && sleep 1
|
echo -n "." && sleep 1
|
||||||
docker logs hacker-challenge | grep -q "SOL" && echo && break
|
docker logs dthc-root | grep -q "SOL" && echo && break
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Sending SOL to the root and waiting for the mint"
|
echo "Sending SOL to the root and waiting for the mint"
|
||||||
address=$(docker logs hacker-challenge | grep 'SOL' | awk '{ print $NF }')
|
address=$(docker logs dthc-root | grep 'SOL' | awk '{ print $NF }')
|
||||||
"${script_dir}"/mint_sol "${address}"
|
"${script_dir}"/mint_sol "${address}"
|
||||||
while true; do
|
while true; do
|
||||||
echo -n "." && sleep 1
|
echo -n "." && sleep 1
|
||||||
docker logs hacker-challenge | grep -q "Mint created" && echo && break
|
docker logs dthc-root | grep -q "Mint created" && echo && break
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Creating the cluster"
|
echo "Creating the cluster"
|
||||||
for p in {31311..31320}; do
|
for n in {2..20}; do
|
||||||
docker run --device /dev/sgx/enclave \
|
#init_nodes=$(docker inspect dthc-root --format '{{ .NetworkSettings.Networks.dthc.IPAddress }}')
|
||||||
--device /dev/sgx/provision \
|
node_ip="172.18.0.${n}"
|
||||||
--env INIT_NODES="172.17.0.2 172.17.0.3 172.17.0.4" \
|
node_port=$((31300 + n))
|
||||||
-v "/tmp/hacker-challenge${p}:/challenge/main" \
|
node_volume="/tmp/dthc${node_port}"
|
||||||
--name "hacker-challenge${p}" -p "${p}:31372" \
|
|
||||||
-d detee/hacker-challenge:latest
|
run_node "--env INIT_NODES='${root_ip}' \
|
||||||
|
--env NODE_IP='${node_ip}' \
|
||||||
|
--name dthc-${n} --ip ${node_ip} \
|
||||||
|
-v ${node_volume}:/challenge/main \
|
||||||
|
-p ${node_port}:31372"
|
||||||
done
|
done
|
||||||
sleep 15 # Wait for the cluster to start
|
sleep 15 # Wait for the cluster to start
|
||||||
|
|
||||||
echo "Running the test mint"
|
echo "Running the test mint"
|
||||||
for p in {31311..31320}; do
|
for n in {2..20}; do
|
||||||
curl -X POST "127.0.0.1:${p}/mint" \
|
node_port=$((31300 + n))
|
||||||
|
curl -X POST "127.0.0.1:${node_port}/mint" \
|
||||||
--json '{"wallet": "EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR"}' \
|
--json '{"wallet": "EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR"}' \
|
||||||
--connect-timeout 5 2> /dev/null
|
--connect-timeout 5 2> /dev/null
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# curl <ip>/metrics
|
||||||
|
# curl -X POST <ip>/mint -d '{"wallet": "EZT16iP1SQVUFf1AJN6oiE5BZPnyBUqaKDkZ4oZRsvhR"}' -H 'Content-Type: application/json'
|
||||||
|
@ -26,7 +26,7 @@ pub struct NodeInfo {
|
|||||||
|
|
||||||
impl NodeInfo {
|
impl NodeInfo {
|
||||||
pub fn is_newer_than(&self, older_self: &Self) -> bool {
|
pub fn is_newer_than(&self, older_self: &Self) -> bool {
|
||||||
self.keepalive >= older_self.keepalive
|
self.keepalive > older_self.keepalive
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_json(&self) -> String {
|
pub fn to_json(&self) -> String {
|
||||||
|
@ -26,6 +26,13 @@ const INIT_NODES_FILE: &str = "/host/detee_challenge_nodes";
|
|||||||
const KEYS_FILE: &str = "/host/main/TRY_TO_HACK_THIS";
|
const KEYS_FILE: &str = "/host/main/TRY_TO_HACK_THIS";
|
||||||
const MAX_CONNECTIONS: usize = 3;
|
const MAX_CONNECTIONS: usize = 3;
|
||||||
|
|
||||||
|
#[cfg(feature = "test")]
|
||||||
|
async fn resolve_my_ip() -> Result<String, Error> {
|
||||||
|
let ip = std::env::var("NODE_IP").unwrap_or_else(|_| "127.0.0.1".to_string());
|
||||||
|
Ok(ip)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "test"))]
|
||||||
async fn resolve_my_ip() -> Result<String, Error> {
|
async fn resolve_my_ip() -> Result<String, Error> {
|
||||||
let err = "Can't resolve my external IP, try again";
|
let err = "Can't resolve my external IP, try again";
|
||||||
let ip = public_ip::addr_v4().await.ok_or(Error::new(ErrorKind::Other, err))?;
|
let ip = public_ip::addr_v4().await.ok_or(Error::new(ErrorKind::Other, err))?;
|
||||||
|
Loading…
Reference in New Issue
Block a user