Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from bloxbean/sanchonet
Browse files Browse the repository at this point in the history
Conway era support
  • Loading branch information
satran004 authored Jan 21, 2024
2 parents 3381aa3 + 358019a commit 6dc945b
Show file tree
Hide file tree
Showing 36 changed files with 1,445 additions and 107 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
java-version: '21'
distribution: 'liberica'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: 17
java-version: 21
distribution: 'liberica'
- name: Decode GPG Key
run: |
mkdir -p ~/.gradle/
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM ubuntu:22.04
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:17 $JAVA_HOME $JAVA_HOME
COPY --from=eclipse-temurin:21 $JAVA_HOME $JAVA_HOME
ENV PATH="${JAVA_HOME}/bin:${PATH}"
ENV STORE_VERSION=0.0.13-beta1
ENV STORE_VERSION=0.1.0-rc2-preview1

ARG TARGETOS
ARG TARGETARCH
Expand Down
35 changes: 21 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'org.springframework.boot' version '3.1.0'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.graalvm.buildtools.native' version '0.9.18'
id 'java'
id 'signing'
Expand All @@ -12,12 +12,17 @@ configurations {
}
}

sourceCompatibility = '17'
java {
sourceCompatibility = '21'
}

repositories {
//maven { url 'https://repo.spring.io/release' }
mavenCentral()
mavenLocal()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}

ext {
Expand All @@ -27,16 +32,16 @@ ext {
dependencies {
implementation 'org.springframework.shell:spring-shell-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
implementation 'org.springframework.boot:spring-boot-starter-logging'

implementation('com.bloxbean.cardano:yaci:0.2.0-beta2') {
implementation('com.bloxbean.cardano:yaci:0.3.0-beta9-e9eb81d-SNAPSHOT') {
exclude group: 'com.bloxbean.cardano', module: 'cardano-client-core'
}
implementation 'com.bloxbean.cardano:cardano-client-lib:0.5.0-alpha.3'
implementation 'com.bloxbean.cardano:cardano-client-backend:0.5.0-alpha.3'
implementation 'com.bloxbean.cardano:cardano-client-backend-blockfrost:0.5.0-alpha.3'
implementation 'com.bloxbean.cardano:cardano-client-supplier-local:0.5.0-alpha.3'
implementation 'com.bloxbean.cardano:cardano-client-lib:0.5.0'
implementation 'com.bloxbean.cardano:cardano-client-backend:0.5.0'
implementation 'com.bloxbean.cardano:cardano-client-backend-blockfrost:0.5.0'
implementation 'com.bloxbean.cardano:cardano-client-supplier-local:0.5.0'

implementation 'org.jeasy:easy-rules-core:4.1.0'
implementation 'org.jeasy:easy-rules-mvel:4.1.0'
Expand Down Expand Up @@ -70,13 +75,15 @@ tasks.named('test') {
// removeYamlSupport = false
//}

task genClusterTemplatesZip(type: Zip) {
from sourceSets.main.resources
include 'localcluster/**/*'
archiveName 'localcluster.zip'
destinationDir(new File("build/resources/main"))
tasks.register('genClusterTemplatesZip', Zip) {
from sourceSets.main.resources
include 'localcluster/**/*'

archiveFileName.set('localcluster.zip')
destinationDirectory.set(layout.buildDirectory.dir('resources/main'))
}


compileJava {
dependsOn genClusterTemplatesZip
}
Expand Down
4 changes: 2 additions & 2 deletions docker/download-amd64.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
file=cardano-node-8.1.2-linux.tar.gz
wget https://github.com/input-output-hk/cardano-node/releases/download/8.1.2/cardano-node-8.1.2-linux.tar.gz
file=cardano-node-8.7.3-linux.tar.gz
wget https://github.com/IntersectMBO/cardano-node/releases/download/8.7.3/cardano-node-8.7.3-linux.tar.gz

mkdir /app/cardano-bin

Expand Down
12 changes: 11 additions & 1 deletion docker/download-arm64.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
file=8_1_2.zip
file=cardano-8_7_3-aarch64-static-musl-ghc_963.zip
dir=cardano-8_7_3-aarch64-static-musl-ghc_963
wget https://github.com/armada-alliance/cardano-node-binaries/raw/main/static-binaries/$file

unzip $file
mv $dir cardano-node
mv cardano-node /app/cardano-bin/
rm $file

submit_api_file=cardano-submit-api-3_2_1.zip
wget https://github.com/armada-alliance/cardano-node-binaries/raw/main/static-binaries/cardano-submit-api/$submit_api_file

unzip $submit_api_file
mv cardano-submit-api /app/cardano-bin/

rm $submit_api_file
4 changes: 2 additions & 2 deletions docker/download-kupo.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
file=kupo-2.5.1-amd64-Linux.tar.gz
wget https://github.com/CardanoSolutions/kupo/releases/download/v2.5/$file
file=kupo-2.7.2-amd64-Linux.tar.gz
wget https://github.com/CardanoSolutions/kupo/releases/download/v2.7/$file

mkdir /app/kupo

Expand Down
2 changes: 1 addition & 1 deletion docker/download-ogmios.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=v5.6.0
version=v6.0.0
file=ogmios-${version}-x86_64-linux.zip
wget https://github.com/CardanoSolutions/ogmios/releases/download/${version}/$file

Expand Down
5 changes: 5 additions & 0 deletions docker/store-application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ spring.jpa.properties.hibernate.order_inserts=true

store.cardano.byron-genesis-file=/clusters/default/genesis/byron/genesis.json
store.cardano.shelley-genesis-file=/clusters/default/genesis/shelley/genesis.json
store.cardano.alonzo-genesis-file=/clusters/default/genesis/shelley/genesis.alonzo.json
store.cardano.conway-genesis-file=/clusters/default/genesis/shelley/genesis.conway.json

store.blocks.epoch-calculation-interval=3600

store.account.enabled=true
store.account.balance-aggregation-enabled=true
store.account.history-cleanup-enabled=false

store.live.enabled=true

store.epoch.endpoints.epoch.local.enabled=true
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group = com.bloxbean.cardano
artifactId = yaci-cli
version = 0.0.19
version = 0.0.20-beta1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public AttributedString getPrompt() {
return new AttributedString("yaci-cli:>",
AttributedStyle.DEFAULT.foreground(AttributedStyle.GREEN).bold());
} else {
String clusterName = CommandContext.INSTANCE.getProperty(ClusterCommands.CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(ClusterCommands.CLUSTER_NAME);
if (clusterName == null)
clusterName = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.bloxbean.cardano.client.plutus.spec.PlutusData;
import com.bloxbean.cardano.client.plutus.spec.serializers.PlutusDataJsonConverter;
import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Point;
import com.bloxbean.cardano.yaci.core.protocol.localstate.api.Era;
import com.bloxbean.cardano.yaci.core.util.HexUtil;
import com.bloxbean.cardano.yacicli.commands.common.Groups;
import com.bloxbean.cardano.yacicli.commands.common.RootLogService;
Expand Down Expand Up @@ -37,7 +38,7 @@
@RequiredArgsConstructor
@Slf4j
public class ClusterCommands {
public static final String CUSTER_NAME = "custer_name";
public static final String CLUSTER_NAME = "cluster_name";
private final ClusterService localClusterService;
private final RootLogService rootLogService;
private final ClusterUtilService clusterUtilService;
Expand Down Expand Up @@ -66,8 +67,10 @@ public void startLocalClusterContext(@ShellOption(value = {"-n", "--name"}, defa

localClusterService.startClusterContext(clusterName, msg -> writeLn(msg));

var clusterInfo = localClusterService.getClusterInfo(clusterName);
CommandContext.INSTANCE.setCurrentMode(CommandContext.Mode.LOCAL_CLUSTER);
CommandContext.INSTANCE.setProperty(CUSTER_NAME, clusterName);
CommandContext.INSTANCE.setProperty(CLUSTER_NAME, clusterName);
CommandContext.INSTANCE.setEra(clusterInfo.getEra());
writeLn(success("Switched to %s", clusterName));
} catch (Exception e) {
writeLn(error(e.getMessage()));
Expand All @@ -82,7 +85,8 @@ public void createCluster(@ShellOption(value = {"-n", "--name"}, defaultValue =
@ShellOption(value = {"-b", "--block-time"}, help = "Block time in sec. (1 - 20)", defaultValue = "1") double blockTime,
@ShellOption(value = {"-e", "--epoch-length"}, help = "No of slots in an epoch", defaultValue = "500") int epochLength,
@ShellOption(value = {"-o", "--overwrite"}, defaultValue = "false", help = "Overwrite existing node directory. default: false") boolean overwrite,
@ShellOption(value = {"--start"}, defaultValue = "false", help = "Automatically start the node after create. default: false") boolean start
@ShellOption(value = {"--start"}, defaultValue = "false", help = "Automatically start the node after create. default: false") boolean start,
@ShellOption(value = {"--era"}, defaultValue = "babbage", help = "Era (babbage, conway)") String era
) {

try {
Expand All @@ -101,6 +105,19 @@ public void createCluster(@ShellOption(value = {"-n", "--name"}, defaultValue =
return;
}

//Era check
Era nodeEra;
if (era == null || era.isEmpty())
nodeEra = Era.Babbage;
else if (era.equalsIgnoreCase("babbage"))
nodeEra = Era.Babbage;
else if (era.equalsIgnoreCase("conway"))
nodeEra = Era.Conway;
else {
writeLn(error("Invalid era. Valid values are babbage, conway"));
return;
}

long protocolMagic = 42; //always 42 for now.

//stop any cluster if running
Expand All @@ -117,6 +134,7 @@ public void createCluster(@ShellOption(value = {"-n", "--name"}, defaultValue =
.p2pEnabled(false)
.masterNode(true)
.isBlockProducer(true)
.era(nodeEra)
.build();

boolean success = localClusterService.createNodeClusterFolder(clusterName, clusterInfo, overwrite, (msg) -> writeLn(msg));
Expand All @@ -126,7 +144,8 @@ public void createCluster(@ShellOption(value = {"-n", "--name"}, defaultValue =

//change to Local Cluster Context
CommandContext.INSTANCE.setCurrentMode(CommandContext.Mode.LOCAL_CLUSTER);
CommandContext.INSTANCE.setProperty(CUSTER_NAME, clusterName);
CommandContext.INSTANCE.setProperty(CLUSTER_NAME, clusterName);
CommandContext.INSTANCE.setEra(nodeEra);

if (start)
startLocalCluster();
Expand All @@ -140,7 +159,7 @@ public void createCluster(@ShellOption(value = {"-n", "--name"}, defaultValue =
@ShellMethod(value = "Get devnet info", key = "info")
@ShellMethodAvailability("localClusterCmdAvailability")
private void getClusterInfo() {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(CLUSTER_NAME);
try {
printClusterInfo(clusterName);
} catch (Exception e) {
Expand Down Expand Up @@ -175,7 +194,7 @@ public void deleteLocalCluster(@ShellOption(value = {"-n", "--name"}, help = "No
@ShellMethod(value = "Start local devnet", key = "start")
@ShellMethodAvailability("localClusterCmdAvailability")
public void startLocalCluster() {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(CLUSTER_NAME);
boolean started = localClusterService.startCluster(clusterName);
if (!started)
return;
Expand All @@ -201,7 +220,7 @@ public void startLocalCluster() {
@ShellMethod(value = "Stop the running local devnet", key = "stop")
@ShellMethodAvailability("localClusterCmdAvailability")
public void stopLocalCluster() {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(CLUSTER_NAME);
localClusterService.stopCluster(msg -> writeLn(msg));

publisher.publishEvent(new ClusterStopped(clusterName));
Expand All @@ -210,7 +229,7 @@ public void stopLocalCluster() {
@ShellMethod(value = "Reset local devnet. Delete data and logs folder and restart.", key = "reset")
@ShellMethodAvailability("localClusterCmdAvailability")
public void resetLocalCluster() {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(CLUSTER_NAME);
localClusterService.stopCluster(msg -> writeLn(msg));
publisher.publishEvent(new ClusterStopped(clusterName));

Expand Down Expand Up @@ -252,7 +271,7 @@ public void ltail(
@ShellOption(value = {"--log-level"}, defaultValue = ShellOption.NULL, help = "Log level") String logLevel,
@ShellOption(value = {"--color-mode"}, defaultValue = "dark", help = "Color mode (dark, light") String colorMode
) {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(CLUSTER_NAME);
OutputFormatter outputFormatter = new DefaultOutputFormatter(shellHelper);
try {
localClusterService.ltail(clusterName, showMint, showInputs, showMetadata, showDatumhash, showInlineDatum, grouping, outputFormatter);
Expand All @@ -264,9 +283,10 @@ public void ltail(
@ShellMethod(value = "Show available utxos at default accounts", key = "show-default-accounts")
@ShellMethodAvailability("localClusterCmdAvailability")
public void listDefaultAccounts() {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(CLUSTER_NAME);
Era era = CommandContext.INSTANCE.getEra();

Map<String, List<Utxo>> utxosMap = accountService.getUtxosAtDefaultAccounts(clusterName, msg -> writeLn(msg));
Map<String, List<Utxo>> utxosMap = accountService.getUtxosAtDefaultAccounts(clusterName, era, msg -> writeLn(msg));
utxosMap.entrySet().forEach(entry -> {
writeLn(header(AnsiColors.CYAN_BOLD, "Address"));
writeLn(entry.getKey());
Expand All @@ -282,9 +302,10 @@ public void listDefaultAccounts() {
@ShellMethodAvailability("localClusterCmdAvailability")
public void topUp(@ShellOption(value = {"-a", "--address"}, help = "Receiver address") String address,
@ShellOption(value = {"-v", "--value"}, help = "Ada value") double adaValue) {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(CLUSTER_NAME);
Era era = CommandContext.INSTANCE.getEra();

accountService.topup(clusterName, address, adaValue, msg -> writeLn(msg));
accountService.topup(clusterName, era, address, adaValue, msg -> writeLn(msg));
clusterUtilService.waitForNextBlocks(1, msg -> writeLn(msg));

writeLn(info("Available utxos") + "\n");
Expand All @@ -295,9 +316,10 @@ public void topUp(@ShellOption(value = {"-a", "--address"}, help = "Receiver add
@ShellMethodAvailability("localClusterCmdAvailability")
public void getUtxos(@ShellOption(value = {"-a", "--address"}, help = "Address") String address,
@ShellOption(value = {"--pretty-print-inline-datum"}, defaultValue = "false") boolean prettyPrintInlineDatum) {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);
String clusterName = CommandContext.INSTANCE.getProperty(CLUSTER_NAME);
Era era = CommandContext.INSTANCE.getEra();

List<Utxo> utxos = accountService.getUtxos(clusterName, address, msg -> writeLn(msg));
List<Utxo> utxos = accountService.getUtxos(clusterName, era, address, msg -> writeLn(msg));

AtomicInteger index = new AtomicInteger(0);
utxos.forEach(utxo -> {
Expand Down Expand Up @@ -325,8 +347,6 @@ public void getUtxos(@ShellOption(value = {"-a", "--address"}, help = "Address")
@ShellMethod(value = "Get tip/current block number", key = "tip")
@ShellMethodAvailability("localClusterCmdAvailability")
public void getTip() {
String clusterName = CommandContext.INSTANCE.getProperty(CUSTER_NAME);

Tuple<Long, Point> tuple = clusterUtilService.getTip(msg -> writeLn(msg));
writeLn(successLabel("Block#", String.valueOf(tuple._1)));
writeLn(successLabel("Slot#", String.valueOf(tuple._2.getSlot())));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bloxbean.cardano.yacicli.commands.localcluster;

import com.bloxbean.cardano.yaci.core.protocol.localstate.api.Era;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -22,6 +23,7 @@ public class ClusterInfo {
private boolean masterNode;
private boolean isBlockProducer;
private String adminNodeUrl; //Only for peer nodes
private Era era;

@Builder.Default
private int ogmiosPort = 1337;
Expand Down
Loading

0 comments on commit 6dc945b

Please sign in to comment.