Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
images:
runs-on: hiero-mirror-node-linux-medium
strategy:
fail-fast: false
matrix:
module:
[
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
name: Build
runs-on: hiero-mirror-node-linux-large
strategy:
fail-fast: false
matrix:
project:
- common
Expand Down Expand Up @@ -88,7 +89,7 @@ jobs:
if: ${{ matrix.schema == 'v1' && matrix.project != 'test' && always() && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) }}
run: ./gradlew :${{ matrix.project }}:uploadCoverage

- name: Execute Gradle using transaction executor
- name: Build and test web3 with modularized code
env:
HIERO_MIRROR_WEB3_EVM_MODULARIZEDSERVICES: "true"
HIERO_MIRROR_WEB3_EVM_MODULARIZEDTRAFFICPERCENT: "1.0"
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/non-zero-realm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# SPDX-License-Identifier: Apache-2.0

name: "Non-Zero Realm"
on:
schedule:
- cron: "0 0 * * *" # Daily at midnight
workflow_dispatch:
inputs:
branch:
description: "Branch"
required: true
type: string

defaults:
run:
shell: bash

permissions:
contents: read

env:
LC_ALL: C.UTF-8
CGO_ENABLED: 1

jobs:
build:
name: Build
env:
HIERO_MIRROR_COMMON_REALM: 127
HIERO_MIRROR_COMMON_SHARD: 113
HIERO_MIRROR_WEB3_EVM_MODULARIZEDSERVICES: "true"
HIERO_MIRROR_WEB3_EVM_MODULARIZEDTRAFFICPERCENT: "1.0"
runs-on: hiero-mirror-node-linux-large
strategy:
fail-fast: false
matrix:
project:
- common
- graphql
- grpc
- importer
- monitor
- rest
- rest-java
- rosetta
- web3
timeout-minutes: 40 # increase it from 20 minutes since some jobs often run longer on self-hosted runners
steps:
- name: Harden Runner
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
with:
egress-policy: audit

- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref }}

- name: Install JDK
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: temurin
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4

- name: Execute Gradle
run: ./gradlew :${{matrix.project}}:build
1 change: 1 addition & 0 deletions .github/workflows/release-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
jobs:
publish:
strategy:
fail-fast: false
matrix:
project:
- graphql
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
jobs:
image:
strategy:
fail-fast: false
matrix:
project:
- graphql
Expand Down
62 changes: 52 additions & 10 deletions rosetta/app/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"path/filepath"
"reflect"
"strconv"
"testing"
"time"

Expand Down Expand Up @@ -42,7 +43,9 @@ hiero:
host: 192.168.120.51
port: 12000
network: TESTNET`
realmEnvKey = "HIERO_MIRROR_COMMON_REALM"
serviceEndpoint = "192.168.0.1:50211"
shardEnvKey = "HIERO_MIRROR_COMMON_SHARD"
)

var expectedNodeRefreshInterval = 30 * time.Minute
Expand Down Expand Up @@ -82,7 +85,7 @@ func TestLoadCustomConfig(t *testing.T) {
if tt.fromCwd {
os.Chdir(tempDir)
} else {
em := envManager{}
em := newEnvManager()
em.SetEnv(apiConfigEnvKey, filePath)
t.Cleanup(em.Cleanup)
}
Expand All @@ -108,8 +111,10 @@ func TestLoadCustomConfigFromCwdAndEnvVar(t *testing.T) {
tempDir2, filePath2 := createYamlConfigFile(yml2, t)
defer os.RemoveAll(tempDir2)

em := envManager{}
em := newEnvManager()
em.SetEnv(apiConfigEnvKey, filePath2)
em.UnsetEnv(realmEnvKey)
em.UnsetEnv(shardEnvKey)
t.Cleanup(em.Cleanup)

// when
Expand All @@ -131,7 +136,7 @@ func TestLoadCustomConfigFromCwdAndEnvVar(t *testing.T) {
func TestLoadCustomConfigFromEnvVar(t *testing.T) {
// given
dbHost := "192.168.100.200"
em := envManager{}
em := newEnvManager()
em.SetEnv("HIERO_MIRROR_ROSETTA_DB_HOST", dbHost)
t.Cleanup(em.Cleanup)

Expand Down Expand Up @@ -165,7 +170,7 @@ func TestLoadCustomConfigInvalidYaml(t *testing.T) {
os.Chdir(tempDir)
}

em := envManager{}
em := newEnvManager()
em.SetEnv(apiConfigEnvKey, filePath)
t.Cleanup(em.Cleanup)

Expand All @@ -179,7 +184,7 @@ func TestLoadCustomConfigInvalidYaml(t *testing.T) {

func TestLoadCustomConfigByEnvVarFileNotFound(t *testing.T) {
// given
em := envManager{}
em := newEnvManager()
em.SetEnv(apiConfigEnvKey, "/foo/bar/not_found.yml")
t.Cleanup(em.Cleanup)

Expand Down Expand Up @@ -211,7 +216,7 @@ func TestLoadNodeMapFromEnv(t *testing.T) {

for _, tt := range tests {
t.Run(tt.value, func(t *testing.T) {
em := envManager{}
em := newEnvManager()
em.SetEnv("HIERO_MIRROR_ROSETTA_NODES", tt.value)
t.Cleanup(em.Cleanup)

Expand All @@ -229,7 +234,7 @@ func TestLoadNodeMapFromEnvError(t *testing.T) {
values := []string{"192.168.0.1:0.0.3", "192.168.0.1:50211:0.3", "192.168.0.1"}
for _, value := range values {
t.Run(value, func(t *testing.T) {
em := envManager{}
em := newEnvManager()
em.SetEnv("HIERO_MIRROR_ROSETTA_NODES", value)
t.Cleanup(em.Cleanup)

Expand Down Expand Up @@ -303,22 +308,59 @@ func createYamlConfigFile(content string, t *testing.T) (string, string) {
}

type envManager struct {
keys []string
added []string
overridden map[string]string
}

func (e *envManager) SetEnv(key, value string) {
if oldValue, present := os.LookupEnv(key); present {
e.overridden[key] = oldValue
} else {
e.added = append(e.added, key)
}
os.Setenv(key, value)
e.keys = append(e.keys, key)
}

func (e *envManager) UnsetEnv(key string) {
if value, present := os.LookupEnv(key); present {
e.overridden[key] = value
}
os.Unsetenv(key)
}

func (e *envManager) Cleanup() {
for _, key := range e.keys {
for _, key := range e.added {
os.Unsetenv(key)
}

for key, value := range e.overridden {
os.Setenv(key, value)
}
}

func newEnvManager() envManager {
return envManager{overridden: make(map[string]string)}
}

func getDefaultConfig() *Mirror {
config := fullConfig{}
yaml.Unmarshal([]byte(defaultConfig), &config)

if value, present := os.LookupEnv(realmEnvKey); present {
var err error
config.Hiero.Mirror.Common.Realm, err = strconv.ParseInt(value, 10, 64)
if err != nil {
panic(err)
}
}

if value, present := os.LookupEnv(shardEnvKey); present {
var err error
config.Hiero.Mirror.Common.Shard, err = strconv.ParseInt(value, 10, 64)
if err != nil {
panic(err)
}
}

return &config.Hiero.Mirror
}
Loading