Skip to content

Commit

Permalink
chore: merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-monninger committed Nov 11, 2023
1 parent 0b762e9 commit dca74b9
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 10 deletions.
22 changes: 22 additions & 0 deletions m1/scripts/anr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -e
mkdir -p ./plugins

# We will inherit the avalanchego binary from the environment.
# But, we will set the plugin path to the plugin dir in this directory.
export AVALANCHEGO_EXEC_PATH=$(which avalanchego)
export AVALANCHEGO_PLUGIN_PATH=$(pwd)/plugins

# Build the subnet
cargo build -p subnet

# export SUBNET_ID=$(subnet-cli create VMID ./target/debug/subnet)
export SUBNET_ID=srEXiWaHZNDcVtfHLb38cFiwKVLJ8xnhDF5qpWbYdowxEiyid

echo $SUBNET_ID
# Copy the subnet binary to the plugin dir
# cp ./target/debug/subnet ${AVALANCHEGO_PLUGIN_PATH}/${SUBNET_ID}
# cp ./target/debug/subnet ${AVALANCHEGO_PLUGIN_PATH}/subnet

# Start the avalanche-network-runner
avalanche-network-runner server

25 changes: 25 additions & 0 deletions m1/scripts/avalanche-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -e

# Install subnet-cli
VERSION=0.0.4 # Populate latest here

GOARCH=$(go env GOARCH)
GOOS=$(go env GOOS)
DOWNLOAD_PATH=/tmp/subnet-cli.tar.gz
DOWNLOAD_URL=https://github.com/ava-labs/subnet-cli/releases/download/v${VERSION}/subnet-cli_${VERSION}_linux_${GOARCH}.tar.gz
if [[ ${GOOS} == "darwin" ]]; then
DOWNLOAD_URL=https://github.com/ava-labs/subnet-cli/releases/download/v${VERSION}/subnet-cli_${VERSION}_darwin_${GOARCH}.tar.gz
fi

rm -f ${DOWNLOAD_PATH}
rm -f /tmp/subnet-cli

echo "downloading subnet-cli ${VERSION} at ${DOWNLOAD_URL}"
curl -L ${DOWNLOAD_URL} -o ${DOWNLOAD_PATH}

echo "extracting downloaded subnet-cli"
tar xzvf ${DOWNLOAD_PATH} -C /tmp

/tmp/subnet-cli -h

cp /tmp/subnet-cli $HOME/bin/subnet-cli
17 changes: 17 additions & 0 deletions m1/scripts/start-subnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e
export AVALANCHEGO_EXEC_PATH=$(which avalanchego)
export AVALANCHEGO_PLUGIN_PATH=$(pwd)/plugins

echo hello > /tmp/subnet.genesis.json

avalanche-network-runner control start \
--log-level debug \
--endpoint="0.0.0.0:8080" \
--avalanchego-path="${AVALANCHEGO_EXEC_PATH}"
# --blockchain-specs '[{"vm_name":"subnet","genesis":"/tmp/subnet.genesis.json","blockchain_alias":"movement"}]' \

# avalanche-network-runner control create-blockchains '[{"vm_name":"movement", "subnet_id": "srEXiWaHZNDcVtfHLb38cFiwKVLJ8xnhDF5qpWbYdowxEiyid"}]' \
# --log-level debug \
# --endpoint="0.0.0.0:8080"

curl -X POST -k http://localhost:8081/v1/control/status
1 change: 1 addition & 0 deletions m1/subnet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
plugins
20 changes: 11 additions & 9 deletions m1/subnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
avalanche-types = { version = "0.0.398", features = ["subnet", "codec_base64"] }
avalanche-types = { version = "0.1.3", features = ["subnet", "codec_base64"] }
tokio = { version = "1.25.0", features = ["fs", "rt-multi-thread"] }
tonic = { version = "0.8.3", features = ["gzip"] }
serde = { version = "1.0.152", features = ["derive"] }
Expand All @@ -17,33 +17,35 @@ dirs = "5.0.1"
hex = "0.4.3"
bytes = "1.4.0"
env_logger = "0.10.0"
base64 = { version = "0.21.0" }
# base64 = { version = "0.21.0" }
chrono = "0.4.23"
derivative = "2.2.0"
jsonrpc-core = "18.0.0"
jsonrpc-core-client = { version = "18.0.0" }
jsonrpc-derive = "18.0.0"

anyhow = { workspace = true }
# anyhow = { workspace = true }
aptos-config = { workspace = true }
aptos-consensus-types = { workspace = true }
# aptos-consensus-types = { workspace = true }
aptos-mempool = { workspace = true }
aptos-runtimes = { workspace = true }
# aptos-runtimes = { workspace = true }
aptos-crypto = { workspace = true }
aptos-db = { workspace = true, features = ["fuzzing"] }
aptos-executor = { workspace = true }
aptos-logger = { workspace = true }
# aptos-logger = { workspace = true }
aptos-api-types = { workspace = true }
aptos-api = { workspace = true }
aptos-executor-types = { workspace = true }
aptos-genesis = { workspace = true }
aptos-sdk = { workspace = true }
aptos-state-view = { workspace = true }
aptos-storage-interface = { workspace = true }
aptos-temppath = { workspace = true }
# aptos-temppath = { workspace = true }
aptos-types = { workspace = true }
aptos-vm = { workspace = true }
futures = { workspace = true }
aptos-vm-genesis = { workspace = true }
rand = { workspace = true }
bcs = { workspace = true }
# rand = { workspace = true }
bcs = { workspace = true }
aptos-node = { workspace = true, features = ["indexer"] }
aptos-indexer-grpc-fullnode = { workspace = true }
24 changes: 23 additions & 1 deletion m1/subnet/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ use aptos_types::transaction::Transaction::UserTransaction;
use aptos_types::validator_signer::ValidatorSigner;
use aptos_vm::AptosVM;
use aptos_vm_genesis::{GENESIS_KEYPAIR, test_genesis_change_set_and_validators};
use aptos_node::indexer::bootstrap_indexer;
use aptos_indexer_grpc_fullnode::runtime::bootstrap as bootstrap_indexer_grpc;

use crate::{block::Block, state};
use crate::api::chain_handlers::{AccountStateArgs, BlockArgs, ChainHandler, ChainService, GetTransactionByVersionArgs, PageArgs, RpcEventHandleReq, RpcEventNumReq, RpcReq, RpcRes, RpcTableReq};
Expand Down Expand Up @@ -1338,7 +1340,7 @@ impl Vm {
// set up the mempool
let (mempool_client_sender,
mut mempool_client_receiver) = futures_mpsc::channel::<MempoolClientRequest>(10);
let sender = MempoolClientSender::from(mempool_client_sender);
let sender = MempoolClientSender::from(mempool_client_sender.clone());
let node_config = NodeConfig::default();
let context = Context::new(ChainId::test(),
db.1.reader.clone(),
Expand Down Expand Up @@ -1368,6 +1370,12 @@ impl Vm {
}
});

// start the indexer service
tokio::task::spawn(async move {
bootstrap_indexer_grpc(&node_config, ChainId::test(), db.1.reader.clone(), mempool_client_sender.clone()).unwrap();
bootstrap_indexer(&node_config, ChainId::test(), db.1.reader.clone(), MempoolClientSender::from(mempool_client_sender.clone())).unwrap();
});


}
}
Expand Down Expand Up @@ -1476,6 +1484,20 @@ impl ChainVm for Vm
async fn last_accepted(&self) -> io::Result<ids::Id> {
self.last_accepted().await
}

async fn verify_height_index(&self) -> io::Result<()> {
Ok(())
}

// Returns an error as a no-op for now.
async fn get_block_id_at_height(&self, _height: u64) -> io::Result<ids::Id> {
Err(Error::new(ErrorKind::NotFound, "block id not found"))
}

async fn state_sync_enabled(&self) -> io::Result<bool> {
Ok(false)
}

}

#[tonic::async_trait]
Expand Down

0 comments on commit dca74b9

Please sign in to comment.