Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 085-M-ReduceSmartCo…
Browse files Browse the repository at this point in the history
…ntractDup
  • Loading branch information
tinker-michaelj committed Jan 8, 2021
2 parents 8859586 + e28876c commit 4094c4c
Show file tree
Hide file tree
Showing 30 changed files with 1,074 additions and 118 deletions.
8 changes: 0 additions & 8 deletions hapi-fees/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,41 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.vintage.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest-all.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions hapi-proto/src/main/proto/TokenCreate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Token B has initial supply set to 10_012_345_678 and decimals set to 8. The numb
Creating immutable token: Token can be created as immutable if the adminKey is omitted. In this case, the name, symbol, treasury, management keys, expiry and renew properties cannot be updated. If a token is created as immutable, anyone is able to extend the expiry time by paying the fee.
*/
message TokenCreateTransactionBody {
string name = 1; // The publicly visible name of the token, specified as a string of only ASCII characters
string symbol = 2; // The publicly visible token symbol. It is UTF-8 capitalized alphabetical string identifying the token
string name = 1; // The publicly visible name of the token, limited to a UTF-8 encoding of length <tt>tokens.maxSymbolUtf8Bytes</tt>.
string symbol = 2; // The publicly visible token symbol, limited to a UTF-8 encoding of length <tt>tokens.maxTokenNameUtf8Bytes</tt>.
uint32 decimals = 3; // The number of decimal places a token is divisible by. This field can never be changed!
uint64 initialSupply = 4; // Specifies the initial supply of tokens to be put in circulation. The initial supply is sent to the Treasury Account. The supply is in the lowest denomination possible.
AccountID treasury = 5; // The account which will act as a treasury for the token. This account will receive the specified initial supply
Expand Down
8 changes: 0 additions & 8 deletions hedera-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,49 +321,41 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.vintage.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>${hamcrest-all.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
32 changes: 26 additions & 6 deletions hedera-node/src/main/java/com/hedera/services/ServicesState.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.hedera.services.state.merkle.MerkleEntityId;
import com.hedera.services.state.merkle.MerkleNetworkContext;
import com.hedera.services.state.merkle.MerkleOptionalBlob;
import com.hedera.services.state.merkle.MerkleSchedule;
import com.hedera.services.state.merkle.MerkleToken;
import com.hedera.services.state.merkle.MerkleTokenRelStatus;
import com.hedera.services.state.merkle.MerkleTopic;
Expand Down Expand Up @@ -100,6 +101,8 @@ static class ChildIndices {
static final int TOKEN_ASSOCIATIONS = 6;
static final int DISK_FS = 7;
static final int NUM_090_CHILDREN = 8;
static final int SCHEDULE_TXS = 8;
static final int NUM_0100_CHILDREN = 9;
}

ServicesContext ctx;
Expand All @@ -108,7 +111,7 @@ public ServicesState() {
}

public ServicesState(List<MerkleNode> children) {
super(ChildIndices.NUM_090_CHILDREN);
super(ChildIndices.NUM_0100_CHILDREN);
addDeserializedChildren(children, MERKLE_VERSION);
}

Expand Down Expand Up @@ -136,10 +139,12 @@ public int getVersion() {
public int getMinimumChildCount(int version) {
if (version == RELEASE_070_VERSION) {
return ChildIndices.NUM_070_CHILDREN;
} else if (version == RELEASE_080_VERSION) {
return ChildIndices.NUM_080_CHILDREN;
} else if (version == RELEASE_090_VERSION) {
return ChildIndices.NUM_090_CHILDREN;
} else {
return (version == RELEASE_080_VERSION)
? ChildIndices.NUM_080_CHILDREN
: ChildIndices.NUM_090_CHILDREN;
return ChildIndices.NUM_0100_CHILDREN;
}
}

Expand All @@ -160,6 +165,11 @@ public void initialize(MerkleInternal previous) {
log.info("Created disk file system after <=0.9.0 state restoration");
skipDiskFsHashCheck = true;
}
if (scheduleTxs() == null) {
setChild(ChildIndices.SCHEDULE_TXS,
new FCMap<>(new MerkleEntityId.Provider(), MerkleSchedule.LEGACY_PROVIDER));
log.info("Created scheduled txs FCMap after <= 0.10.0 state restoration");
}
}

@Override
Expand All @@ -184,7 +194,7 @@ public void init(Platform platform, AddressBook addressBook) {
} catch (ContextNotFoundException ignoreToInstantiateNewContext) {
ctx = new ServicesContext(nodeId, platform, this, properties);
}
if (getNumberOfChildren() < ChildIndices.NUM_090_CHILDREN) {
if (getNumberOfChildren() < ChildIndices.NUM_0100_CHILDREN) {
log.info("Init called on Services node {} WITHOUT Merkle saved state", nodeId);
long seqStart = bootstrapProps.getLongProperty("hedera.numReservedSystemEntities") + 1;
setChild(ChildIndices.NETWORK_CTX,
Expand All @@ -202,6 +212,8 @@ public void init(Platform platform, AddressBook addressBook) {
new FCMap<>(MerkleEntityAssociation.LEGACY_PROVIDER, MerkleTokenRelStatus.LEGACY_PROVIDER));
setChild(ChildIndices.DISK_FS,
new MerkleDiskFs(diskFsBaseDirPath, asLiteralString(ctx.nodeAccount())));
setChild(ChildIndices.SCHEDULE_TXS,
new FCMap<>(new MerkleEntityId.Provider(), MerkleSchedule.LEGACY_PROVIDER));
} else {
log.info("Init called on Services node {} WITH Merkle saved state", nodeId);

Expand Down Expand Up @@ -291,7 +303,9 @@ public synchronized ServicesState copy() {
accounts().copy(),
tokens().copy(),
tokenAssociations().copy(),
diskFs().copy()));
diskFs().copy(),
scheduleTxs().copy()
));
}

@Override
Expand Down Expand Up @@ -341,6 +355,7 @@ public void printHashes() {
" Tokens :: %s\n" +
" TokenAssociations :: %s\n" +
" DiskFs :: %s\n" +
" ScheduledTxs :: %s\n" +
" NetworkContext :: %s\n" +
" AddressBook :: %s",
getHash(),
Expand All @@ -350,6 +365,7 @@ public void printHashes() {
tokens().getHash(),
tokenAssociations().getHash(),
diskFs().getHash(),
scheduleTxs().getHash(),
networkCtx().getHash(),
addressBook().getHash()));
}
Expand All @@ -374,6 +390,10 @@ public FCMap<MerkleEntityAssociation, MerkleTokenRelStatus> tokenAssociations()
return getChild(ChildIndices.TOKEN_ASSOCIATIONS);
}

public FCMap<MerkleEntityId, MerkleSchedule> scheduleTxs() {
return getChild(ChildIndices.SCHEDULE_TXS);
}

public MerkleNetworkContext networkCtx() {
return getChild(ChildIndices.NETWORK_CTX);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ public Set<String> allPropertyNames() {
"ledger.tokenTransfers.maxLen",
"rates.intradayChangeLimitPercent",
"tokens.maxPerAccount",
"tokens.maxSymbolLength",
"tokens.maxTokenNameLength"
"tokens.maxSymbolUtf8Bytes",
"tokens.maxTokenNameUtf8Bytes"
);

static final Set<String> NODE_PROPS = Set.of(
Expand Down Expand Up @@ -289,8 +289,8 @@ public static Function<String, Object> transformFor(String prop) {
entry("ledger.tokenTransfers.maxLen", AS_INT),
entry("ledger.totalTinyBarFloat", AS_LONG),
entry("tokens.maxPerAccount", AS_INT),
entry("tokens.maxSymbolLength", AS_INT),
entry("tokens.maxTokenNameLength", AS_INT),
entry("tokens.maxSymbolUtf8Bytes", AS_INT),
entry("tokens.maxTokenNameUtf8Bytes", AS_INT),
entry("contracts.localCall.estRetBytes", AS_INT),
entry("contracts.maxStorageKb", AS_INT),
entry("contracts.defaultLifetime", AS_LONG),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public class GlobalDynamicProperties {
private final PropertySource properties;

private int maxTokensPerAccount;
private int maxTokensSymbolLength;
private int maxTokensNameLength;
private int maxTokenSymbolUtf8Bytes;
private int maxTokenNameUtf8Bytes;
private int maxFileSizeKb;
private int cacheRecordsTtl;
private int maxContractStorageKb;
Expand Down Expand Up @@ -68,8 +68,8 @@ public GlobalDynamicProperties(
public void reload() {
shouldKeepRecordsInState = properties.getBooleanProperty("ledger.keepRecordsInState");
maxTokensPerAccount = properties.getIntProperty("tokens.maxPerAccount");
maxTokensSymbolLength = properties.getIntProperty("tokens.maxSymbolLength");
maxTokensNameLength = properties.getIntProperty("tokens.maxTokenNameLength");
maxTokenSymbolUtf8Bytes = properties.getIntProperty("tokens.maxSymbolUtf8Bytes");
maxTokenNameUtf8Bytes = properties.getIntProperty("tokens.maxTokenNameUtf8Bytes");
maxAccountNum = properties.getLongProperty("ledger.maxAccountNum");
maxFileSizeKb = properties.getIntProperty("files.maxSizeKb");
fundingAccount = AccountID.newBuilder()
Expand Down Expand Up @@ -103,16 +103,16 @@ public int maxTokensPerAccount() {
return maxTokensPerAccount;
}

public int maxTokenSymbolLength() {
return maxTokensSymbolLength;
public int maxTokenSymbolUtf8Bytes() {
return maxTokenSymbolUtf8Bytes;
}

public long maxAccountNum() {
return maxAccountNum;
}

public int maxTokenNameLength() {
return maxTokensNameLength;
public int maxTokenNameUtf8Bytes() {
return maxTokenNameUtf8Bytes;
}

public int maxFileSizeKb() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* ‍
*/

import com.hedera.services.state.merkle.MerkleToken;
import com.hederahashgraph.api.proto.java.ServicesConfigurationList;
import com.hederahashgraph.api.proto.java.Setting;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -74,7 +75,13 @@ public class ScreenedSysFileProps implements PropertySource {
entry("accountBalanceExportPeriodMinutes", legacy -> "" + (60 * Integer.parseInt(legacy)))
);
private static Map<String, Predicate<Object>> VALUE_SCREENS = Map.ofEntries(
entry("rates.intradayChangeLimitPercent", limitPercent -> (int)limitPercent > 0)
entry("rates.intradayChangeLimitPercent", limitPercent -> (int)limitPercent > 0),
entry(
"tokens.maxSymbolUtf8Bytes",
maxUtf8Bytes -> (int)maxUtf8Bytes <= MerkleToken.UPPER_BOUND_SYMBOL_UTF8_BYTES),
entry(
"tokens.maxTokenNameUtf8Bytes",
maxUtf8Bytes -> (int)maxUtf8Bytes <= MerkleToken.UPPER_BOUND_TOKEN_NAME_UTF8_BYTES)
);

Map<String, Object> from121 = Collections.emptyMap();
Expand Down
Loading

0 comments on commit 4094c4c

Please sign in to comment.