Skip to content

Commit

Permalink
Merge branch 'develop' into 03640-contracts-nonce-externalization
Browse files Browse the repository at this point in the history
# Conflicts:
#	hedera-node/hedera-mono-service/src/test/java/com/hedera/node/app/service/mono/state/submerkle/EvmFnResultSerdeTest.java
#	hedera-node/hedera-mono-service/src/test/java/com/hedera/test/serde/SerializedForms.java
#	hedera-node/hedera-mono-service/src/test/java/com/hedera/test/utils/SeededPropertySource.java
  • Loading branch information
agadzhalov committed Jul 3, 2023
2 parents c0294f6 + 96ac267 commit de3d67a
Show file tree
Hide file tree
Showing 512 changed files with 18,360 additions and 8,479 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/node-zxc-build-release-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ jobs:
Artifact:
name: ${{ inputs.custom-job-label || 'Artifact' }}
runs-on: [self-hosted, Linux, large, ephemeral]
outputs:
version: ${{ steps.effective-version.outputs.number }}
steps:
- name: Install Semantic Version Tools
run: |
Expand Down Expand Up @@ -220,6 +222,13 @@ jobs:
EFF_VERSION="$(./gradlew showVersion --quiet | tr -d '[:space:]')"
echo "number=${EFF_VERSION}" >>"${GITHUB_OUTPUT}"
- name: Cache Build Artifacts
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # pin@v3
if: ${{ inputs.dry-run-enabled != true && !cancelled() && !failure() }}
with:
path: ${{ env.HOME }}/artifact-build
key: node-build-artifacts-${{ steps.effective-version.outputs.number }}-${{ github.sha }}

- name: Stage Artifact Build Folder
id: artifact-staging
run: |
Expand Down Expand Up @@ -328,3 +337,77 @@ jobs:
echo "::error title=Jenkins Trigger Failure::Failed to trigger the 'build-preview-testnet' job via the Jenkins 'preview' pipeline!"
exit 1
fi
local-node-images:
name: Local Node Images
runs-on: [ self-hosted, Linux, large, ephemeral ]
needs:
- Artifact
if: ${{ inputs.dry-run-enabled != true && inputs.version-policy == 'specified' && !cancelled() && !failure() }}
steps:
- name: Checkout Code
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3

- name: Authenticate to Google Cloud
id: google-auth
uses: google-github-actions/auth@ef5d53e30bbcd8d0836f4288f5e50ff3e086997d # pin@v1
with:
token_format: 'access_token'
workload_identity_provider: "projects/235822363393/locations/global/workloadIdentityPools/hedera-builds-pool/providers/hedera-builds-gh-actions"
service_account: "[email protected]"

- name: Setup QEmu Support
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # pin@v2

- name: Setup Docker Buildx Support
uses: docker/setup-buildx-action@16c0bc4a6e6ada2cfd8afd41d22d95379cf7c32a # pin@v2

- name: Docker Login
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # pin@v2
with:
registry: gcr.io
username: oauth2accesstoken
password: ${{ steps.google-auth.outputs.access_token }}

- name: Cache Build Artifacts
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # pin@v3
with:
fail-on-cache-miss: true
path: ${{ env.HOME }}/artifact-build
key: node-build-artifacts-${{ needs.Artifact.outputs.version }}-${{ github.sha }}

- name: Stage SDK Artifacts
run: |
mkdir -p hedera-node/infrastructure/docker/containers/local-node/main-network-node/sdk
cp -rvf ${{ env.HOME }}/artifact-build/* hedera-node/infrastructure/docker/containers/local-node/main-network-node/sdk/
- name: Build Haveged Image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # pin@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
platforms: linux/amd64,linux/arm64
context: hedera-node/infrastructure/docker/containers/local-node/network-node-haveged
tags: gcr.io/hedera-registry/network-node-haveged:${{ needs.Artifact.outputs.version }}

- name: Build Base Image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # pin@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
platforms: linux/amd64,linux/arm64
context: hedera-node/infrastructure/docker/containers/local-node/network-node-base
tags: gcr.io/hedera-registry/network-node-base:${{ needs.Artifact.outputs.version }}

- name: Build Network Node Image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # pin@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
platforms: linux/amd64,linux/arm64
build-args: IMAGE_TAG=${{ needs.Artifact.outputs.version }}
context: hedera-node/infrastructure/docker/containers/local-node/main-network-node
tags: gcr.io/hedera-registry/main-network-node:${{ needs.Artifact.outputs.version }}
9 changes: 5 additions & 4 deletions hedera-node/configuration/compose/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Gossip / Networking #
#############################

chatter.useChatter, false
doUpnp, false
maxOutgoingSyncs, 1 # differs from mainnet
numConnections, 1000
useLoopbackIp, false
socket.doUpnp, false
socket.useLoopbackIp, false
sync.maxOutgoingSyncs, 1 # differs from mainnet
sync.syncAsProtocolEnabled, true
sync.syncProtocolPermitCount, 2 # differs from mainnet

#############################
# State #
Expand Down
11 changes: 5 additions & 6 deletions hedera-node/configuration/dev/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
# Gossip / Networking #
#############################

chatter.useChatter, false
doUpnp, false
maxOutgoingSyncs, 1 # differs from mainnet
numConnections, 1000
socket.doUpnp, false
socket.useLoopbackIp, false
sync.maxOutgoingSyncs, 1 # differs from mainnet
sync.syncAsProtocolEnabled, true
sync.syncProtocolPermitCount, 17
useLoopbackIp, false
sync.syncProtocolPermitCount, 2 # differs from mainnet

#############################
# State #
Expand Down Expand Up @@ -45,4 +44,4 @@ reconnect.asyncStreamTimeoutMilliseconds, 60000
metrics.csvFileName, MainNetStats
metrics.csvOutputFolder, data/stats
showInternalStats, true
prometheus.endpointEnabled, false # differs from mainnet
prometheus.endpointEnabled, false # differs from mainnet
9 changes: 5 additions & 4 deletions hedera-node/configuration/mainnet/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Gossip / Networking #
#############################

chatter.useChatter, false
doUpnp, false
maxOutgoingSyncs, 8
numConnections, 1000
useLoopbackIp, false
socket.doUpnp, false
socket.useLoopbackIp, false
sync.maxOutgoingSyncs, 8
sync.syncAsProtocolEnabled, true
sync.syncProtocolPermitCount, 17

#############################
# State #
Expand Down
9 changes: 5 additions & 4 deletions hedera-node/configuration/preprod/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Gossip / Networking #
#############################

chatter.useChatter, false
doUpnp, false
maxOutgoingSyncs, 4 # differs from mainnet
numConnections, 1000
useLoopbackIp, false
socket.doUpnp, false
socket.useLoopbackIp, false
sync.maxOutgoingSyncs, 4 # differs from mainnet
sync.syncAsProtocolEnabled, true
sync.syncProtocolPermitCount, 4 # differs from mainnet

#############################
# State #
Expand Down
9 changes: 4 additions & 5 deletions hedera-node/configuration/previewnet/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
# Gossip / Networking #
#############################

chatter.useChatter, false
doUpnp, false
maxOutgoingSyncs, 4 # differs from mainnet
numConnections, 1000
socket.doUpnp, false
socket.useLoopbackIp, false
sync.maxOutgoingSyncs, 4 # differs from mainnet
sync.syncAsProtocolEnabled, true
sync.syncProtocolPermitCount, 17
useLoopbackIp, false
sync.syncProtocolPermitCount, 4 # differs from mainnet

#############################
# State #
Expand Down
9 changes: 5 additions & 4 deletions hedera-node/configuration/testnet/settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Gossip / Networking #
#############################

chatter.useChatter, false
doUpnp, false
maxOutgoingSyncs, 4 # differs from mainnet
numConnections, 1000
useLoopbackIp, false
socket.doUpnp, false
socket.useLoopbackIp, false
sync.maxOutgoingSyncs, 4 # differs from mainnet
sync.syncAsProtocolEnabled, true
sync.syncProtocolPermitCount, 4 # differs from mainnet

#############################
# State #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,45 @@ public static String toString(@NonNull final SemanticVersion version) {
}
return baseVersion.toString();
}

/**
* Parses an account from a string of the form shardNum.realmNum.accountNum
* @param string The input string
* @return The corresponding {@link AccountID}
* @throws IllegalArgumentException if the string is not a dot-separated triplet of numbers
*/
public static AccountID parseAccount(@NonNull final String string) {
try {
final var parts = string.split("\\.");
return AccountID.newBuilder()
.shardNum(Long.parseLong(parts[0]))
.realmNum(Long.parseLong(parts[1]))
.accountNum(Long.parseLong(parts[2]))
.build();
} catch (final NumberFormatException | ArrayIndexOutOfBoundsException e) {
throw new IllegalArgumentException(String.format("'%s' is not a dot-separated triplet", string));
}
}

/**
* Utility to convert an {@link AccountID} into a nicely formatted String.
* @param id The id to convert
* @return The string representation
*/
public static String toString(@NonNull final AccountID id) {
var builder = new StringBuilder()
.append(id.shardNum())
.append(".")
.append(id.realmNum())
.append(".");

if (id.hasAccountNum()) {
builder.append(id.accountNum());
} else if (id.hasAlias()) {
builder.append(id.alias());
} else {
builder.append("-");
}
return builder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import com.hedera.pbj.runtime.io.buffer.Bytes;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.List;

/**
* Provides information about the network.
Expand All @@ -31,4 +33,13 @@ public interface NetworkInfo {
*/
@NonNull
Bytes ledgerId();

@NonNull
NodeInfo selfNodeInfo();

@NonNull
List<NodeInfo> addressBook();

@Nullable
NodeInfo nodeInfo(long nodeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.hedera.hapi.node.base.AccountID;
import com.swirlds.common.system.address.AddressBook;
import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Summarizes useful information about the nodes in the {@link AddressBook} from the Platform. In
Expand All @@ -32,30 +31,13 @@ public interface NodeInfo {
*
* @return whether this node has zero stake.
*/
boolean isSelfZeroStake();
boolean zeroStake();

/**
* Returns the account parsed from the address book memo corresponding to the given node id.
* Returns the account ID corresponding with this node.
*
* @param nodeId the id of interest
* @return the account parsed from the address book memo corresponding to the given node id.
* @throws IllegalArgumentException if the book did not contain the id, or was missing an
* account for the id
* @return the account ID of the node.
* @throws IllegalStateException if the book did not contain the id, or was missing an account for the id
*/
@NonNull
AccountID accountOf(long nodeId);

/**
* Returns if the given node id is valid and the address book contains the id.
* @param nodeId the id of interest
* @return true if the given node id is valid. False otherwise.
*/
default boolean isValidId(long nodeId) {
try {
accountOf(nodeId);
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
AccountID accountId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

package com.hedera.node.app.spi.signatures;

import static java.util.Objects.requireNonNull;

import com.hedera.hapi.node.base.Key;
import com.hedera.hapi.node.state.token.Account;
import com.hedera.pbj.runtime.io.buffer.Bytes;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;

/**
Expand Down Expand Up @@ -68,4 +71,52 @@ default Bytes evmAlias() {
default boolean failed() {
return !passed();
}

/**
* Convenience method to create a SignatureVerification that failed
*
* @param key The key for which verification failed
*/
@NonNull
static SignatureVerification failedVerification(@NonNull final Key key) {
requireNonNull(key, "Key must not be null");
return new SignatureVerification() {
@NonNull
@Override
public Key key() {
return key;
}

@Override
public boolean passed() {
return false;
}
};
}

/**
* Convenience method to create a SignatureVerification for a hollow account that failed
*
* @param evmAlias The alias for which verification failed
*/
static SignatureVerification failedVerification(@NonNull final Bytes evmAlias) {
return new SignatureVerification() {
@Nullable
@Override
public Key key() {
return null;
}

@NonNull
@Override
public Bytes evmAlias() {
return evmAlias;
}

@Override
public boolean passed() {
return false;
}
};
}
}
Loading

0 comments on commit de3d67a

Please sign in to comment.