Skip to content

Commit

Permalink
Merge branch 'spec_update_vesting' of https://github.com/movebit/apto…
Browse files Browse the repository at this point in the history
…s-core into spec_update_vesting
  • Loading branch information
UIZorrot committed Jul 24, 2023
2 parents cf1cd1f + cf1accf commit a58a2db
Show file tree
Hide file tree
Showing 453 changed files with 4,432 additions and 16,116 deletions.
4 changes: 4 additions & 0 deletions .github/actions/fullnode-sync/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
NODE_LOG_FILE_PATH:
description: "The file path for the node logs to be written to."
required: true
METRICS_DUMP_FILE_PATH:
description: "The file path for the node metrics to be written to."
required: true

runs:
using: composite
Expand All @@ -42,3 +45,4 @@ runs:
CONTINUOUS_SYNCING_MODE: ${{ inputs.CONTINUOUS_SYNCING_MODE }}
DATA_DIR_FILE_PATH: ${{ inputs.DATA_DIR_FILE_PATH }}
NODE_LOG_FILE_PATH: ${{ inputs.NODE_LOG_FILE_PATH }}
METRICS_DUMP_FILE_PATH: ${{ inputs.METRICS_DUMP_FILE_PATH }}
42 changes: 34 additions & 8 deletions .github/actions/fullnode-sync/fullnode_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
FULLNODE_CONFIG_TEMPLATE_PATH = "config/src/config/test_data/public_full_node.yaml" # Relative to the aptos-core repo
GENESIS_BLOB_PATH = "https://raw.githubusercontent.com/aptos-labs/aptos-networks/main/{network}/genesis.blob" # Location inside the aptos-networks repo
LOCAL_METRICS_ENDPOINT = "http://127.0.0.1:9101/json_metrics" # The json metrics endpoint running on the local host
LOCAL_METRICS_ENDPOINT_TEXT = "http://127.0.0.1:9101/metrics" # The text metrics endpoint running on the local host
LOCAL_REST_ENDPOINT = "http://127.0.0.1:8080/v1" # The rest endpoint running on the local host
LEDGER_VERSION_API_STRING = "ledger_version" # The string to fetch the ledger version from the REST API
LEDGER_VERSION_METRICS_STRING = "aptos_state_sync_version.synced" # The string to fetch the ledger version from the metrics API
Expand Down Expand Up @@ -59,12 +60,7 @@ def get_synced_version_from_index_response(api_index_response, exit_if_none):
def get_metric_from_metrics_port(metric_name):
"""Gets and returns the metric from the metrics port. If no metric exists, returns 0."""
# Ping the metrics port
process = subprocess.Popen(["curl", "-s", LOCAL_METRICS_ENDPOINT], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
metrics_response, errors = process.communicate()
if metrics_response is None:
print_error_and_exit("Exiting! Unable to get the metrics from the localhost. Response is empty.")
if errors is not None and errors != b'':
print("Found output on stderr for get_synced_version_from_metrics_port: {errors}".format(errors=errors))
metrics_response = ping_metrics_port(False)

# Parse the metric value
try:
Expand All @@ -80,14 +76,41 @@ def get_metric_from_metrics_port(metric_name):
return int(metric_value)


def ping_metrics_port(use_text_endpoint):
"""Pings the metrics port and returns the result"""
# Ping the metrics endpoint
metrics_endpoint = LOCAL_METRICS_ENDPOINT_TEXT if use_text_endpoint else LOCAL_METRICS_ENDPOINT
process = subprocess.Popen(["curl", "-s", metrics_endpoint], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
metrics_response, errors = process.communicate()

# Process the response
if metrics_response is None:
print_error_and_exit("Exiting! Unable to get the metrics from the localhost. Response is empty.")
if errors is not None and errors != b'':
print("Found output on stderr for get_synced_version_from_metrics_port: {errors}".format(errors=errors))

# Return the metrics response
return metrics_response


def check_fullnode_is_still_running(fullnode_process_handle):
"""Verifies the fullnode is still running and exits if not"""
return_code = fullnode_process_handle.poll()
if return_code is not None:
print_error_and_exit("Exiting! The fullnode process terminated prematurely with return code: {return_code}!".format(return_code=return_code))


def monitor_fullnode_syncing(fullnode_process_handle, bootstrapping_mode, node_log_file_path, public_version, target_version):
def dump_node_metrics_to_file(metrics_dump_file_path):
"""Dumps the metrics to a file"""
# Ping the metrics port
metrics_response = ping_metrics_port(True)

# Write the metrics to a file
with open(metrics_dump_file_path, "w") as metrics_dump_file:
metrics_dump_file.write(str(metrics_response))


def monitor_fullnode_syncing(fullnode_process_handle, bootstrapping_mode, node_log_file_path, metrics_dump_file_path, public_version, target_version):
"""Monitors the ability of the fullnode to sync"""
print("Waiting for the node to synchronize!")
last_synced_version = 0 # The most recent synced version
Expand All @@ -103,6 +126,7 @@ def monitor_fullnode_syncing(fullnode_process_handle, bootstrapping_mode, node_l

# Fetch the latest synced version from the node metrics
synced_version = get_metric_from_metrics_port(LEDGER_VERSION_METRICS_STRING)
dump_node_metrics_to_file(metrics_dump_file_path)

# Check if we've synced to the public version
if not synced_to_public_version:
Expand Down Expand Up @@ -255,6 +279,7 @@ def main():
"CONTINUOUS_SYNCING_MODE",
"DATA_DIR_FILE_PATH",
"NODE_LOG_FILE_PATH",
"METRICS_DUMP_FILE_PATH",
]
if not all(env in os.environ for env in REQUIRED_ENVS):
raise Exception("Missing required ENV variables!")
Expand All @@ -266,6 +291,7 @@ def main():
CONTINUOUS_SYNCING_MODE = os.environ["CONTINUOUS_SYNCING_MODE"]
DATA_DIR_FILE_PATH = os.environ["DATA_DIR_FILE_PATH"]
NODE_LOG_FILE_PATH = os.environ["NODE_LOG_FILE_PATH"]
METRICS_DUMP_FILE_PATH = os.environ["METRICS_DUMP_FILE_PATH"]

# Check out the correct git ref (branch or commit hash)
checkout_git_ref(GIT_REF)
Expand All @@ -286,7 +312,7 @@ def main():
wait_for_fullnode_to_start(fullnode_process_handle)

# Monitor the ability for the fullnode to sync
monitor_fullnode_syncing(fullnode_process_handle, BOOTSTRAPPING_MODE, NODE_LOG_FILE_PATH, public_version, target_version)
monitor_fullnode_syncing(fullnode_process_handle, BOOTSTRAPPING_MODE, NODE_LOG_FILE_PATH, METRICS_DUMP_FILE_PATH, public_version, target_version)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fullnode-execute-devnet-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: "fullnode-execute-devnet-main"
on:
workflow_dispatch:
schedule:
- cron: "0 0,12 * * *" # At hour 0 and 12 - aka twice a day (UTC)
- cron: "0 1 * * *" # Once a day, at 01:00 (UTC)

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fullnode-execute-devnet-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: "fullnode-execute-devnet-stable"
on:
workflow_dispatch:
schedule:
- cron: "0 0,12 * * *" # At hour 0 and 12 - aka twice a day (UTC)
- cron: "30 1 * * *" # Once a day, at 01:30 (UTC)

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fullnode-fast-mainnet-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: "fullnode-fast-mainnet-main"
on:
workflow_dispatch:
schedule:
- cron: "0 0,12 * * *" # At hour 0 and 12 - aka twice a day (UTC)
- cron: "0 2 * * *" # Once a day, at 02:00 (UTC)

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fullnode-fast-mainnet-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: "fullnode-fast-mainnet-stable"
on:
workflow_dispatch:
schedule:
- cron: "0 0,12 * * *" # At hour 0 and 12 - aka twice a day (UTC)
- cron: "30 2 * * *" # Once a day, at 02:30 (UTC)

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fullnode-fast-testnet-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: "fullnode-fast-testnet-main"
on:
workflow_dispatch:
schedule:
- cron: "0 0,12 * * *" # At hour 0 and 12 - aka twice a day (UTC)
- cron: "0 3 * * *" # Once a day, at 03:00 (UTC)

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fullnode-fast-testnet-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: "fullnode-fast-testnet-stable"
on:
workflow_dispatch:
schedule:
- cron: "0 0,12 * * *" # At hour 0 and 12 - aka twice a day (UTC)
- cron: "30 3 * * *" # Once a day, at 03:30 (UTC)

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fullnode-intelligent-devnet-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: "fullnode-intelligent-devnet-main"
on:
workflow_dispatch:
schedule:
- cron: "0 0,12 * * *" # At hour 0 and 12 - aka twice a day (UTC)
- cron: "* 4 * * *" # Once a day, at 04:00 (UTC)

permissions:
contents: read
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/fullnode-intelligent-mainnet-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow runs a public fullnode using the `main` branch,
# connects the public fullnode to `mainnet` and synchronizes the
# node using execution or output syncing to verify that nothing
# has been broken.

name: "fullnode-intelligent-mainnet-main"
on:
workflow_dispatch:
schedule:
- cron: "30 4 * * *" # Once a day, at 04:30 (UTC)

permissions:
contents: read
id-token: write
actions: write #required for workflow cancellation via check-aptos-core

jobs:
check-repo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: aptos-labs/aptos-core/.github/actions/check-aptos-core@main
with:
cancel-workflow: ${{ github.event_name == 'schedule' }} # Cancel the workflow if it is scheduled on a fork

fullnode-intelligent-mainnet-main:
needs: check-repo
uses: ./.github/workflows/run-fullnode-sync.yaml
secrets: inherit
with:
TEST_NAME: fullnode-intelligent-mainnet-main
GIT_REF: main
NETWORK: mainnet
BOOTSTRAPPING_MODE: DownloadLatestStates
CONTINUOUS_SYNCING_MODE: ExecuteTransactionsOrApplyOutputs
35 changes: 35 additions & 0 deletions .github/workflows/fullnode-intelligent-mainnet-stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow runs a public fullnode using the `mainnet` branch,
# connects the public fullnode to `mainnet` and synchronizes the
# node using execution or output syncing to verify that nothing
# has been broken.

name: "fullnode-intelligent-mainnet-stable"
on:
workflow_dispatch:
schedule:
- cron: "0 5 * * *" # Once a day, at 05:00 (UTC)

permissions:
contents: read
id-token: write
actions: write #required for workflow cancellation via check-aptos-core

jobs:
check-repo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: aptos-labs/aptos-core/.github/actions/check-aptos-core@main
with:
cancel-workflow: ${{ github.event_name == 'schedule' }} # Cancel the workflow if it is scheduled on a fork

fullnode-intelligent-mainnet-stable:
needs: check-repo
uses: ./.github/workflows/run-fullnode-sync.yaml
secrets: inherit
with:
TEST_NAME: fullnode-intelligent-mainnet-stable
GIT_REF: mainnet
NETWORK: mainnet
BOOTSTRAPPING_MODE: DownloadLatestStates
CONTINUOUS_SYNCING_MODE: ExecuteTransactionsOrApplyOutputs
35 changes: 35 additions & 0 deletions .github/workflows/fullnode-intelligent-testnet-main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow runs a public fullnode using the `main` branch,
# connects the public fullnode to `testnet` and synchronizes the
# node using execution or output syncing to verify that nothing
# has been broken.

name: "fullnode-intelligent-testnet-main"
on:
workflow_dispatch:
schedule:
- cron: "30 5 * * *" # Once a day, at 05:30 (UTC)

permissions:
contents: read
id-token: write
actions: write #required for workflow cancellation via check-aptos-core

jobs:
check-repo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: aptos-labs/aptos-core/.github/actions/check-aptos-core@main
with:
cancel-workflow: ${{ github.event_name == 'schedule' }} # Cancel the workflow if it is scheduled on a fork

fullnode-intelligent-testnet-main:
needs: check-repo
uses: ./.github/workflows/run-fullnode-sync.yaml
secrets: inherit
with:
TEST_NAME: fullnode-intelligent-testnet-main
GIT_REF: main
NETWORK: testnet
BOOTSTRAPPING_MODE: DownloadLatestStates
CONTINUOUS_SYNCING_MODE: ExecuteTransactionsOrApplyOutputs
10 changes: 10 additions & 0 deletions .github/workflows/run-fullnode-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
CONTINUOUS_SYNCING_MODE: ${{ inputs.CONTINUOUS_SYNCING_MODE }}
DATA_DIR_FILE_PATH: /tmp/
NODE_LOG_FILE_PATH: /tmp/node_log
METRICS_DUMP_FILE_PATH: /tmp/metrics

- name: Upload node logs as an artifact
uses: actions/upload-artifact@v3
Expand All @@ -80,6 +81,15 @@ jobs:
/tmp/node_log
retention-days: 14

- name: Upload the metrics dump as an artifact
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: metrics
path: |
/tmp/metrics
retention-days: 14

- name: Post to a Slack channel on failure
if: failure()
id: slack
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a58a2db

Please sign in to comment.