Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ services:
volumes:
- credentials:/credentials
- genesis:/genesis
healthcheck:
# waits until accounts are starting to be provisioned
test: celestia-appd query block --type height 3
interval: 1s
timeout: 60s
retries: 60

grpcwebproxy:
image: grpcwebproxy
Expand Down Expand Up @@ -93,6 +99,34 @@ services:
# - credentials:/credentials
# - genesis:/genesis

# This validator is started as a separate network, only to be able to test
# transactions eviction cases. Thus it has low TTL and block size.
validator-eviction-testing:
image: validator
platform: "linux/amd64"
# we want the first validator to create keys for the main devnet accounts
# before this one is even started. That way we don't race over keys creation,
# and all keys are still funded on this network
depends_on:
validator:
condition: service_healthy
build:
context: .
dockerfile: Dockerfile.validator
environment:
- P2P_NETWORK=private-eviction-testing
# amount of DA nodes to provision (default: 3)
- NODE_COUNT=3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean that both validators will send the funds?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because the networks are separated, accounts need funding on both

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! shared secret keys and separate networks threw me off initially. Would you mind adding small comment like

This creates a separate private network, with the same accounts provisioned
or something to that effect

# values from the eviction testing in celestia-app
# https://github.com/celestiaorg/celestia-app/blob/v6.1.0-rc0/pkg/user/tx_client_test.go#L338
- BLOCK_SIZE=1048576
- MEMPOOL_TX_TTL=1
ports:
- 29090:9090
volumes:
- credentials:/credentials
- genesis:/genesis

volumes:
# local volume where node's credentials can persist
credentials:
Expand Down
4 changes: 2 additions & 2 deletions ci/run-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ NODE_TYPE="${NODE_TYPE:-bridge}"
SKIP_AUTH="${SKIP_AUTH:-false}"
NODE_NAME="node-$NODE_ID"
# a private local network
P2P_NETWORK="private"
P2P_NETWORK="${P2P_NETWORK:-"private"}"
# a node configuration directory
CONFIG_DIR="$HOME/.celestia-$NODE_TYPE-$P2P_NETWORK"
# directory and the files shared with the validator node
Expand All @@ -17,7 +17,7 @@ NODE_KEY_FILE="$CREDENTIALS_DIR/$NODE_NAME.key"
NODE_JWT_FILE="$CREDENTIALS_DIR/$NODE_NAME.jwt"
# directory where validator will write the genesis hash
GENESIS_DIR="/genesis"
GENESIS_HASH_FILE="$GENESIS_DIR/genesis_hash"
GENESIS_HASH_FILE="$GENESIS_DIR/genesis-hash-$P2P_NETWORK"

# Wait for the validator to set up and provision us via shared dir
wait_for_provision() {
Expand Down
18 changes: 14 additions & 4 deletions ci/run-validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ set -euxo pipefail
# or 1 if not provided
NODE_COUNT="${NODE_COUNT:-1}"
# a private local network
P2P_NETWORK="private"
P2P_NETWORK="${P2P_NETWORK:-"private"}"
# a validator node configuration directory
CONFIG_DIR="$CELESTIA_HOME/.celestia-app"
# the names of the keys
NODE_NAME=validator-0
NODE_NAME="validator-0"
# amounts of the coins for the keys
NODE_COINS="200000000000000utia"
VALIDATOR_COINS="1000000000000000utia"
# a directory and the files shared with the bridge nodes
CREDENTIALS_DIR="/credentials"
# directory where validator will write the genesis hash
GENESIS_DIR="/genesis"
GENESIS_HASH_FILE="$GENESIS_DIR/genesis_hash"
GENESIS_HASH_FILE="$GENESIS_DIR/genesis-hash-$P2P_NETWORK"

# Get the address of the node of given name
node_address() {
Expand Down Expand Up @@ -116,7 +116,8 @@ provision_da_nodes() {
"$peer_addr" \
"$NODE_COINS" \
--fees 21000utia \
--keyring-backend "test"
--keyring-backend "test" \
--chain-id "$P2P_NETWORK"
done

# Save the genesis hash for the DA node
Expand Down Expand Up @@ -160,6 +161,15 @@ setup_private_validator() {
dasel put -f "$CONFIG_DIR/config/app.toml" -t bool -v true grpc.enable
dasel put -f "$CONFIG_DIR/config/app.toml" -t string -v '0.0.0.0:9090' grpc.address

# Optionally, configure the block size
if [ -n "${BLOCK_SIZE:-""}" ]; then
dasel put -f "$CONFIG_DIR/config/genesis.json" -t string -v "${BLOCK_SIZE}" consensus.params.block.max_bytes
fi
# Optionally, configure the transactions ttl in mempool
if [ -n "${MEMPOOL_TX_TTL:-""}" ]; then
dasel put -f "$CONFIG_DIR/config/config.toml" -t int -v "${MEMPOOL_TX_TTL}" mempool.ttl-num-blocks
fi

# TODO: uncomment and remove grpcwebproxy, once CORS works with built-in grpc-web
# enable grpc-web
#dasel put -f "$CONFIG_DIR/config/app.toml" -t bool -v true grpc-web.enable
Expand Down
8 changes: 4 additions & 4 deletions client/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ impl StateApi {
validator_address: &ValAddress,
) -> AsyncGrpcCall<QueryDelegationResponse> {
let this = StateApi::new(self.inner.clone());
let validator_address = validator_address.clone();
let validator_address = *validator_address;

AsyncGrpcCall::new(move |context| async move {
let delegator_address = this.inner.address()?;
Expand All @@ -394,7 +394,7 @@ impl StateApi {
validator_address: &ValAddress,
) -> AsyncGrpcCall<QueryUnbondingDelegationResponse> {
let this = StateApi::new(self.inner.clone());
let validator_address = validator_address.clone();
let validator_address = *validator_address;

AsyncGrpcCall::new(move |context| async move {
let delegator_address = this.inner.address()?;
Expand All @@ -415,8 +415,8 @@ impl StateApi {
dest_validator_address: &ValAddress,
) -> AsyncGrpcCall<QueryRedelegationsResponse> {
let this = StateApi::new(self.inner.clone());
let src_validator_address = src_validator_address.clone();
let dest_validator_address = dest_validator_address.clone();
let src_validator_address = *src_validator_address;
let dest_validator_address = *dest_validator_address;

AsyncGrpcCall::new(move |context| async move {
let delegator_address = this.inner.address()?;
Expand Down
11 changes: 6 additions & 5 deletions grpc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tonic::metadata::MetadataMap;
use zeroize::Zeroizing;

use crate::boxed::{BoxedTransport, boxed};
use crate::client::SignerConfig;
use crate::client::AccountState;
use crate::grpc::Context;
use crate::signer::BoxedDocSigner;
use crate::utils::CondSend;
Expand Down Expand Up @@ -155,11 +155,12 @@ impl GrpcClientBuilder {
}
}

impl TryFrom<SignerKind> for SignerConfig {
impl TryFrom<SignerKind> for AccountState {
type Error = GrpcClientBuilderError;

fn try_from(value: SignerKind) -> Result<Self, Self::Error> {
match value {
SignerKind::Signer((pubkey, signer)) => Ok(SignerConfig { signer, pubkey }),
SignerKind::Signer((pubkey, signer)) => Ok(AccountState::new(pubkey, signer)),
SignerKind::PrivKeyBytes(bytes) => priv_key_signer(&bytes),
SignerKind::PrivKeyHex(string) => {
let bytes = Zeroizing::new(
Expand All @@ -172,12 +173,12 @@ impl TryFrom<SignerKind> for SignerConfig {
}
}

fn priv_key_signer(bytes: &[u8]) -> Result<SignerConfig, GrpcClientBuilderError> {
fn priv_key_signer(bytes: &[u8]) -> Result<AccountState, GrpcClientBuilderError> {
let signing_key =
SigningKey::from_slice(bytes).map_err(|_| GrpcClientBuilderError::InvalidPrivateKey)?;
let pubkey = signing_key.verifying_key().to_owned();
let signer = BoxedDocSigner::new(signing_key);
Ok(SignerConfig { signer, pubkey })
Ok(AccountState::new(pubkey, signer))
}

impl fmt::Debug for SignerKind {
Expand Down
Loading
Loading