Skip to content

Commit

Permalink
feat(makefile): create genesis template with DRS from make file (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
omritoptix authored Dec 9, 2024
1 parent 0586dee commit bcd3815
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,26 @@ release:
release --clean --skip=validate

.PHONY: release-dry-run release

# Default DRS_VERSION if not set
DRS_VERSION ?= default-drs

.PHONY: generate-genesis
generate-genesis:
@if [ -z "$(env)" ]; then \
echo "Error: 'env' parameter is required. Use 'make generate-genesis env=mainnet' or 'make generate-genesis env=testnet'"; \
exit 1; \
fi
@if [ "$(env)" != "mainnet" ] && [ "$(env)" != "testnet" ]; then \
echo "Error: 'env' must be either 'mainnet' or 'testnet'"; \
exit 1; \
fi
@echo "Building and installing rollapp-wasm..."
@$(MAKE) install
@echo "Removing existing genesis file..."
@rm -f ${HOME}/.rollapp-wasm/config/genesis.json
@echo "Initializing rollapp-wasm..."
@rollapp-wasm init test
@echo "Running genesis template script..."
@./scripts/generate-genesis-template.sh $(env) $(DRS_VERSION)

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"genesis_time": "2024-12-09T07:41:25.834885Z",
"genesis_time": "2024-12-09T13:53:21.008106Z",
"chain_id": "rollappwasm_1234-1",
"initial_height": "1",
"consensus_params": {
Expand Down Expand Up @@ -244,7 +244,7 @@
"params": null,
"rollappparams": {
"params": {
"da": "mock",
"da": "celestia",
"drs_version": 1,
"min_gas_prices": []
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"genesis_time": "2024-12-09T07:41:25.834885Z",
"genesis_time": "2024-12-09T13:53:03.295272Z",
"chain_id": "rollappwasm_1234-1",
"initial_height": "1",
"consensus_params": {
Expand Down Expand Up @@ -244,7 +244,7 @@
"params": null,
"rollappparams": {
"params": {
"da": "mock",
"da": "celestia",
"drs_version": 1,
"min_gas_prices": []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
set -x

# Get environment parameter
if [ $# -eq 0 ]; then
echo "Error: Environment parameter (mainnet/testnet) is required"
# Get environment parameter
if [ $# -lt 2 ]; then
echo "Error: Both Environment (mainnet/testnet) and DRS parameters are required"
exit 1
fi

ENVIRONMENT=$1
DRS=$2

if [ "$ENVIRONMENT" != "mainnet" ] && [ "$ENVIRONMENT" != "testnet" ]; then
echo "Error: Environment must be either 'mainnet' or 'testnet'"
exit 1
Expand Down Expand Up @@ -35,6 +38,8 @@ update_params() {
dasel put -f "$TEMP_GENESIS" '.consensus_params.evidence.max_bytes' -v "$BLOCK_SIZE" || success=false
dasel put -f "$TEMP_GENESIS" 'app_state.distribution.params.base_proposer_reward' -v '0.8' || success=false
dasel put -f "$TEMP_GENESIS" 'app_state.distribution.params.community_tax' -v "0.00002" || success=false
dasel put -f "$TEMP_GENESIS" 'app_state.rollappparams.params.drs_version' -v "$DRS" -t int || success=false
dasel put -f "$TEMP_GENESIS" 'app_state.rollappparams.params.da' -v "celestia" || success=false


# Update jq command to use temp file
Expand Down Expand Up @@ -80,11 +85,11 @@ update_params() {
return 1
fi

# Create templates directory if it doesn't exist
mkdir -p ./genesis-templates
# Create templates directory with DRS subdirectory if it doesn't exist
mkdir -p "./genesis-templates/DRS/${DRS}"

# Copy the modified genesis file to the template location
cp "$TEMP_GENESIS" "./genesis-templates/genesis-${ENVIRONMENT}.json"
# Copy the modified genesis file to the DRS-specific template location
cp "$TEMP_GENESIS" "./genesis-templates/DRS/${DRS}/genesis-${ENVIRONMENT}.json"

# Cleanup temp directory
rm -rf "$TEMP_DIR"
Expand Down

0 comments on commit bcd3815

Please sign in to comment.