Skip to content

Commit

Permalink
Consensus parameters made into long
Browse files Browse the repository at this point in the history
  • Loading branch information
spoto committed Aug 29, 2023
1 parent 9ef99c2 commit 62676cf
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ public abstract class CodeSignature extends AbstractMarshallable {
/**
* The method {@code getMaxErrorLength} of the manifest.
*/
public final static MethodSignature GET_MAX_ERROR_LENGTH = new NonVoidMethodSignature(ClassType.MANIFEST, "getMaxErrorLength", BasicTypes.INT);
public final static MethodSignature GET_MAX_ERROR_LENGTH = new NonVoidMethodSignature(ClassType.MANIFEST, "getMaxErrorLength", BasicTypes.LONG);

/**
* The method {@code getMaxDependencies} of the manifest.
*/
public final static MethodSignature GET_MAX_DEPENDENCIES = new NonVoidMethodSignature(ClassType.MANIFEST, "getMaxDependencies", BasicTypes.INT);
public final static MethodSignature GET_MAX_DEPENDENCIES = new NonVoidMethodSignature(ClassType.MANIFEST, "getMaxDependencies", BasicTypes.LONG);

/**
* The method {@code getMaxCumulativeSizeOfDependencies} of the manifest.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ public InitializedNodeImpl(Node parent, ConsensusConfig consensus, Path takamaka
// we create the manifest, passing the storage array of validators in store and their powers
var request = new ConstructorCallTransactionRequest
(new byte[0], gamete, nonceOfGamete, "", _1_000_000, ZERO, takamakaCodeReference,
new ConstructorSignature(ClassType.MANIFEST, ClassType.STRING, ClassType.STRING, BasicTypes.INT,
BasicTypes.INT, BasicTypes.LONG,
new ConstructorSignature(ClassType.MANIFEST, ClassType.STRING, ClassType.STRING, BasicTypes.LONG,
BasicTypes.LONG, BasicTypes.LONG,
BasicTypes.BOOLEAN, BasicTypes.BOOLEAN, BasicTypes.BOOLEAN, BasicTypes.BOOLEAN,
ClassType.STRING, ClassType.GAMETE, BasicTypes.LONG, function, function),
new StringValue(consensus.getGenesisTime().toString()),
new StringValue(consensus.getChainId()), new IntValue(consensus.getMaxErrorLength()), new IntValue(consensus.getMaxDependencies()),
new StringValue(consensus.getChainId()), new LongValue(consensus.getMaxErrorLength()), new LongValue(consensus.getMaxDependencies()),
new LongValue(consensus.getMaxCumulativeSizeOfDependencies()), new BooleanValue(consensus.allowsSelfCharged()),
new BooleanValue(consensus.allowsUnsignedFaucet()), new BooleanValue(consensus.allowsMintBurnFromGamete()),
new BooleanValue(consensus.skipsVerification()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ public String toString() {
String chainId = getChainId();
builder.append(" ├─ chainId: ").append(chainId).append("\n");

int maxErrorLength = ((IntValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
long maxErrorLength = ((LongValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
(manifest, _100_000, takamakaCode, CodeSignature.GET_MAX_ERROR_LENGTH, manifest))).value;

builder.append(" ├─ maxErrorLength: ").append(maxErrorLength).append("\n");

int maxDependencies = ((IntValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
long maxDependencies = ((LongValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
(manifest, _100_000, takamakaCode, CodeSignature.GET_MAX_DEPENDENCIES, manifest))).value;

builder.append(" ├─ maxDependencies: ").append(maxDependencies).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,10 @@ protected final String trimmedMessage(Throwable t) {
String message = t.getMessage();
int length = message.length();

int maxErrorLength = caches.getConsensusParams().getMaxErrorLength();
long maxErrorLength = caches.getConsensusParams().getMaxErrorLength();

if (length > maxErrorLength)
return message.substring(0, maxErrorLength) + "...";
return message.substring(0, (int) maxErrorLength) + "...";
else
return message;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ public final void recomputeConsensus() {
String publicKeyOfGamete = ((StringValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
(manifest, _100_000, takamakaCode, CodeSignature.PUBLIC_KEY, gamete))).value;

int maxErrorLength = ((IntValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
long maxErrorLength = ((LongValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
(manifest, _100_000, takamakaCode, CodeSignature.GET_MAX_ERROR_LENGTH, manifest))).value;

int maxDependencies = ((IntValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
long maxDependencies = ((LongValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
(manifest, _100_000, takamakaCode, CodeSignature.GET_MAX_DEPENDENCIES, manifest))).value;

long maxCumulativeSizeOfDependencies = ((LongValue) node.runInstanceMethodCallTransaction(new InstanceMethodCallTransactionRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public interface ConsensusConfig {
* Yields the maximal length of the error message kept in the store of the node.
* Beyond this threshold, the message gets truncated.
*/
int getMaxErrorLength();
long getMaxErrorLength();

/**
* Yields the maximal number of dependencies in the classpath of a transaction.
*/
int getMaxDependencies();
long getMaxDependencies();

/**
* Yields the maximal cumulative size (in bytes) of the instrumented jars of the dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public interface ConsensusConfigBuilder<T extends ConsensusConfigBuilder<T>> {
* @param maxErrorLength the maximal length of the error message kept in the store of the node
* @return this builder
*/
T setMaxErrorLength(int maxErrorLength);
T setMaxErrorLength(long maxErrorLength);

/**
* Sets the maximal number of dependencies in the classpath of a transaction.
*
* @param maxDependencies the maximal number of dependencies in the classpath of a transaction
* @return this builder
*/
T setMaxDependencies(int maxDependencies);
T setMaxDependencies(long maxDependencies);

/**
* Sets the maximal cumulative size (in bytes) of the instrumented jars of the dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public abstract class ConsensusConfigImpl implements ConsensusConfig {
* The maximal length of the error message kept in the store of the node.
* Beyond this threshold, the message gets truncated.
*/
public final int maxErrorLength;
public final long maxErrorLength;

/**
* The maximal number of dependencies in the classpath of a transaction.
*/
public final int maxDependencies;
public final long maxDependencies;

/**
* The maximal cumulative size (in bytes) of the instrumented jars of the dependencies
Expand Down Expand Up @@ -389,12 +389,12 @@ public String getChainId() {
}

@Override
public int getMaxErrorLength() {
public long getMaxErrorLength() {
return maxErrorLength;
}

@Override
public int getMaxDependencies() {
public long getMaxDependencies() {
return maxDependencies;
}

Expand Down Expand Up @@ -553,13 +553,13 @@ protected ConsensusConfigBuilder<?> fill(ConsensusConfigBuilder<?> builder) {
public abstract static class ConsensusConfigBuilderImpl<T extends ConsensusConfigBuilder<T>> implements ConsensusConfigBuilder<T> {
private String chainId = "";
private LocalDateTime genesisTime = LocalDateTime.now(ZoneId.of("UTC"));
private int maxErrorLength = 300;
private long maxErrorLength = 300L;
private boolean allowsSelfCharged = false;
private boolean allowsUnsignedFaucet = false;
private boolean allowsMintBurnFromGamete = false;
private SignatureAlgorithm<SignedTransactionRequest> signature;
private BigInteger maxGasPerTransaction = BigInteger.valueOf(1_000_000_000L);
private int maxDependencies = 20;
private long maxDependencies = 20;
private long maxCumulativeSizeOfDependencies = 10_000_000L;
private BigInteger initialGasPrice = BigInteger.valueOf(100L);
private boolean ignoresGasPrice = false;
Expand Down Expand Up @@ -612,11 +612,11 @@ protected ConsensusConfigBuilderImpl(Toml toml) throws NoSuchAlgorithmException
if (chainId != null)
setChainId(chainId);

// TODO: remove all type conversions below
var maxErrorLength = toml.getLong("max_error_length");
if (maxErrorLength != null)
setMaxErrorLength((int) (long) maxErrorLength);
setMaxErrorLength(maxErrorLength);

// TODO: remove all type conversions below
var maxDependencies = toml.getLong("max_dependencies");
if (maxDependencies != null)
setMaxDependencies((int) (long) maxDependencies);
Expand Down Expand Up @@ -723,13 +723,13 @@ public T setChainId(String chainId) {
}

@Override
public T setMaxErrorLength(int maxErrorLength) {
public T setMaxErrorLength(long maxErrorLength) {
this.maxErrorLength = maxErrorLength;
return getThis();
}

@Override
public T setMaxDependencies(int maxDependencies) {
public T setMaxDependencies(long maxDependencies) {
this.maxDependencies = maxDependencies;
return getThis();
}
Expand Down Expand Up @@ -820,7 +820,7 @@ public T setInitialInflation(long initialInflation) {

@Override
public T setPercentStaked(int percentStaked) {
if (percentStaked < 0 || percentStaked > 100_000_000L)
if (percentStaked < 0 || percentStaked > 100_000_000)
throw new IllegalArgumentException("percentStaked must be between 0 and 100_000_000");

this.percentStaked = percentStaked;
Expand All @@ -829,7 +829,7 @@ public T setPercentStaked(int percentStaked) {

@Override
public T setBuyerSurcharge(int buyerSurcharge) {
if (buyerSurcharge < 0 || buyerSurcharge > 100_000_000L)
if (buyerSurcharge < 0 || buyerSurcharge > 100_000_000)
throw new IllegalArgumentException("buyerSurcharge must be between 0 and 100_000_000");

this.buyerSurcharge = buyerSurcharge;
Expand All @@ -838,7 +838,7 @@ public T setBuyerSurcharge(int buyerSurcharge) {

@Override
public T setSlashingForMisbehaving(int slashingForMisbehaving) {
if (slashingForMisbehaving < 0 || slashingForMisbehaving > 100_000_000L)
if (slashingForMisbehaving < 0 || slashingForMisbehaving > 100_000_000)
throw new IllegalArgumentException("slashingForMisbehaving must be between 0 and 100_000_000");

this.slashingForMisbehaving = slashingForMisbehaving;
Expand All @@ -847,7 +847,7 @@ public T setSlashingForMisbehaving(int slashingForMisbehaving) {

@Override
public T setSlashingForNotBehaving(int slashingForNotBehaving) {
if (slashingForNotBehaving < 0 || slashingForNotBehaving > 100_000_000L)
if (slashingForNotBehaving < 0 || slashingForNotBehaving > 100_000_000)
throw new IllegalArgumentException("slashingForNotBehaving must be between 0 and 100_000_000");

this.slashingForNotBehaving = slashingForNotBehaving;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package io.hotmoka.tools.internal.moka;

import io.hotmoka.helpers.ManifestHelpers;
import io.hotmoka.node.api.Node;
import io.hotmoka.remote.RemoteNode;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
Expand All @@ -32,7 +31,7 @@ public class Info extends AbstractCommand {

@Override
protected void execute() throws Exception {
try (Node node = RemoteNode.of(remoteNodeConfig(url))) {
try (var node = RemoteNode.of(remoteNodeConfig(url))) {
System.out.println("\nInfo about the node:\n" + ManifestHelpers.of(node));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public final class Manifest<V extends Validator> extends ExternallyOwnedAccount
* The maximal length of the error message kept in the store of the node.
* Beyond this threshold, the message gets truncated.
*/
private final int maxErrorLength;
private final long maxErrorLength;

/**
* The maximal number of dependencies in the classpath of a transaction.
*/
private final int maxDependencies;
private final long maxDependencies;

/**
* The maximal cumulative size (in bytes) of the instrumented jars of the dependencies of a transaction.
Expand Down Expand Up @@ -144,7 +144,7 @@ public final class Manifest<V extends Validator> extends ExternallyOwnedAccount
* @param builderOfGasStation the builder of the gas station of the node having the manifest
* @throws RequirementViolationException if any parameter is null or any builder yields null or the maximal error length is negative
*/
public Manifest(String genesisTime, String chainId, int maxErrorLength, int maxDependencies, long maxCumulativeSizeOfDependencies, boolean allowsSelfCharged,
public Manifest(String genesisTime, String chainId, long maxErrorLength, long maxDependencies, long maxCumulativeSizeOfDependencies, boolean allowsSelfCharged,
boolean allowsFaucet, boolean allowsMintBurnFromGamete, boolean skipsVerification, String signature, Gamete gamete, long verificationVersion,
Function<Manifest<V>, Validators<V>> builderOfValidators, Function<Manifest<V>, GasStation<V>> builderOfGasStation) {

Expand Down Expand Up @@ -204,7 +204,7 @@ public Manifest(String genesisTime, String chainId, int maxErrorLength, int maxD
*
* @return the length
*/
public final @View int getMaxErrorLength() {
public final @View long getMaxErrorLength() {
return maxErrorLength;
}

Expand All @@ -214,7 +214,7 @@ public Manifest(String genesisTime, String chainId, int maxErrorLength, int maxD
*
* @return the maximal number of dependencies
*/
public final @View int getMaxDependencies() {
public final @View long getMaxDependencies() {
return maxDependencies;
}

Expand Down

0 comments on commit 62676cf

Please sign in to comment.