Skip to content

Commit

Permalink
Merge branch 'feature_native-token-lease-op-support' into 'release-1.12'
Browse files Browse the repository at this point in the history
Feature native token lease op support

See merge request development/we/node/open-source-node!9
  • Loading branch information
apospelov committed Jun 7, 2023
2 parents 3d929c9 + e719abb commit bc8af05
Show file tree
Hide file tree
Showing 64 changed files with 2,078 additions and 988 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ envfile
.metals/
.bloop/

# State migration app
!state-migration/migration.jar

# vscode
.vscode
project/metals.sbt
Expand Down
96 changes: 76 additions & 20 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image: ${REGISTRY}/weit/docker:19.03.1
image: ${REGISTRY}/it/docker:19.03.1

services:
- name: ${REGISTRY}/weit/docker:19.03.1-dind
- name: ${REGISTRY}/it/docker:19.03.1-dind
alias: docker

variables:
Expand All @@ -14,7 +14,7 @@ stages:
- publish

.create-environment: &create-environment
image: ${REGISTRY}/weit/hseeberger/scala-sbt:11.0.14.1_1.6.2_2.12.15
image: ${REGISTRY}/it/hseeberger/scala-sbt:11.0.14.1_1.6.2_2.12.15
tags:
- wavesenterprise
before_script:
Expand Down Expand Up @@ -138,39 +138,94 @@ publish-docker-images:
stage: publish
tags:
- wavesenterprise
except:
- /^v[0-9].*$/
needs:
- compile
- assembly-node-jar
- assembly-generator-jar
before_script:
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
script:
- docker login -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}" "${REGISTRY}"
# Pull the latest image for using cache
- docker pull "${REGISTRY}/we/open-source-node:latest" || true
- docker pull "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest" || true

# open-source-node image
- cat Dockerfile | sed "s/\${REGISTRY}/${REGISTRY}/g" | docker build
--rm
--cache-from ${REGISTRY}/we/open-source-node:latest
--tag ${REGISTRY}/we/open-source-node:${CI_COMMIT_REF_NAME}
--tag ${REGISTRY}/we/open-source-node:latest
--cache-from ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
--tag ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}
--tag ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
--file -
.
- docker push "${REGISTRY}/we/open-source-node:${CI_COMMIT_REF_NAME}"
- docker push "${REGISTRY}/we/open-source-node:latest"
- docker push "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}"
- docker push "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest"

# open-source-node scratch image
- docker pull "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch" || true
- cat Dockerfile.scratch | docker build
--rm
--cache-from ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch
--build-arg REGISTRY=${REGISTRY}
--build-arg NODE_VERSION=${CI_COMMIT_REF_NAME}
--tag ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}-scratch
--tag ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch
--file -
.
- docker push "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}-scratch"
- docker push "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch"
cache: { }
dependencies:
- compile
- assembly-node-jar
- assembly-generator-jar

publish-clean-docker-images:
stage: publish
tags:
- wavesenterprise
only:
- /^v[0-9].*$/
needs:
- compile
- assembly-node-jar
- assembly-generator-jar
before_script:
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
script:
# Pull the latest image for using cache
- docker pull "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest" || true

# open-source-node image
- cat Dockerfile | sed "s/\${REGISTRY}/${REGISTRY}/g" | docker build
--rm
--cache-from ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
--tag ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}
--tag ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
--tag registry.wavesenterprise.com/mainnet/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}
--file -
.
- docker push "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}"
- docker push "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest"
- docker push "registry.wavesenterprise.com/mainnet/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}"

# open-source-node scratch image
- docker pull "${REGISTRY}/we/open-source-node:latest-scratch" || true
- docker pull "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch" || true
- cat Dockerfile.scratch | docker build
--rm
--cache-from ${REGISTRY}/we/open-source-node:latest-scratch
--cache-from ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch
--build-arg REGISTRY=${REGISTRY}
--build-arg NODE_VERSION=${CI_COMMIT_REF_NAME}
--tag ${REGISTRY}/we/open-source-node:${CI_COMMIT_REF_NAME}-scratch
--tag ${REGISTRY}/we/open-source-node:latest-scratch
--tag ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}-scratch
--tag registry.wavesenterprise.com/mainnet/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}-scratch
--tag ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch
--file -
.
- docker push "${REGISTRY}/we/open-source-node:${CI_COMMIT_REF_NAME}-scratch"
- docker push "${REGISTRY}/we/open-source-node:latest-scratch"
- docker push "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}-scratch"
- docker push "registry.wavesenterprise.com/mainnet/$CI_PROJECT_NAME:${CI_COMMIT_REF_NAME}-scratch"
- docker push "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch"
cache: { }
dependencies:
- compile
Expand All @@ -190,20 +245,20 @@ publish-images-dockerhub:
- docker login -u "${REGISTRY_USER}" -p "${REGISTRY_PASSWORD}" "${REGISTRY}"

# Pull latest image for using cache
- docker pull "${REGISTRY}/we/open-source-node:latest" || true
- docker pull "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest" || true

- cat Dockerfile | docker build
--rm
--cache-from ${REGISTRY}/we/open-source-node:latest
--cache-from ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
--tag wavesenterprise/node:${CI_COMMIT_REF_NAME}
--file -
.
- docker push "wavesenterprise/node:${CI_COMMIT_REF_NAME}"

- docker pull "${REGISTRY}/we/open-source-node:latest-scratch" || true
- docker pull "${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch" || true
- cat Dockerfile.scratch | docker build
--rm
--cache-from ${REGISTRY}/we/open-source-node:latest-scratch
--cache-from ${REGISTRY}/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest-scratch
--build-arg REGISTRY=${REGISTRY}
--build-arg NODE_VERSION=${CI_COMMIT_REF_NAME}
--tag wavesenterprise/node:${CI_COMMIT_REF_NAME}-scratch
Expand Down Expand Up @@ -238,3 +293,4 @@ publish-nexus-artifacts:
- assembly-node-jar
- assembly-generator-jar
- assembly-transactions-signer-jar

2 changes: 1 addition & 1 deletion Dockerfile.scratch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG REGISTRY
ARG NODE_VERSION

FROM ${REGISTRY}/we/open-source-node:${NODE_VERSION} AS NODE
FROM ${REGISTRY}/development/we/node/open-source-node:${NODE_VERSION} AS NODE

RUN sed -i 's/openjdk-[[:digit:]]*/openjdk/g' launcher.py
RUN cp -r /usr/local/lib/$( \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Our jar file should now be built and available at `./node/target/node-*.jar`

### Build docker image
```
docker build --tag wavesenterprise/node:v1.12.2 .
docker build --tag wavesenterprise/node:v1.12.3 .
```

## Usage
Expand Down
6 changes: 3 additions & 3 deletions node/src/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
node-0:
image: wavesenterprise/node:v1.12.2
image: wavesenterprise/node:v1.12.3
ports:
- "6862:6862"
- "6864:6864"
Expand All @@ -19,7 +19,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
restart: always
node-1:
image: wavesenterprise/node:v1.12.2
image: wavesenterprise/node:v1.12.3
ports:
- "6872:6862"
- "6874:6864"
Expand All @@ -37,7 +37,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
restart: always
node-2:
image: wavesenterprise/node:v1.12.2
image: wavesenterprise/node:v1.12.3
ports:
- "6882:6862"
- "6884:6864"
Expand Down
57 changes: 2 additions & 55 deletions node/src/docker/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,55 +134,6 @@ def move_files(src, dst):
shutil.move(src_f, dst)


def migrate_state(data_directory, we_config_path, state_migration_class):
migrated_file_path = '{}/MIGRATED'.format(data_directory)
is_migrated = os.path.exists(migrated_file_path)

if is_migrated:
logger.info('Data has been already migrated')
return

# Execution continues in two cases:
# 1. the state is 1.4-ish and requires migration
# 2. the state is made from scratch on 1.5.0 or 1.5.1, and is ok, but doesn't have MIGRATED file
db_backup = os.path.join(data_directory, 'db_backup')
db_backup_exists = os.path.exists(db_backup)
db_exists = os.path.exists(data_directory)

if not db_backup_exists and db_exists:
logger.info("Backing up current state: copying from '{}' to '{}'".format(data_directory, db_backup))
move_files(data_directory, db_backup)

logger.info('Starting or continuing migration...')

# build command
cmd = ['{}/bin/java'.format(java_home)]
cmd.extend(['-Xmx1024m'])
cmd.extend(['-Dmigration.source-path={}'.format(db_backup)])
cmd.extend(['-Dmigration.target-path={}'.format(data_directory)])
cmd.extend(['-Dmigration.config-path={}'.format(we_config_path)])
cmd.extend(['-cp', '{}:/node/lib/*'.format(jar_file), state_migration_class])

logger.info(' '.join(cmd))

p = subprocess.Popen(cmd)
p.wait()

if p.returncode == 0:
# Create data_directory, if it doesn't exist
if not os.path.exists(data_directory):
logger.info("Creating data-directory '{}'".format(data_directory))
os.makedirs(data_directory)
# create MIGRATED file at data_directory
open(migrated_file_path, 'w').close()
logger.info("Created '{}' file".format(migrated_file_path))
if os.path.exists(db_backup):
logger.info('Removing obsolete db backup...')
shutil.rmtree(db_backup)
else:
raise RuntimeError("Migration process failed")


def clean_data_state(data_dir):
if os.path.exists(data_dir):
try:
Expand Down Expand Up @@ -311,7 +262,7 @@ def run_snapshot_starter(data_dir, conf):
f"No need to launch SnapshotStarterApp. Datadir is empty: {is_datadir_empty}, genesis is snapshot-based: {is_genesis_snapshot_based}")


def prepare_node(app, state_migration_class):
def prepare_node(app):
if app == ExecutableApp.node:
data_dir = find_data_directory(conf)
clean_state = os.getenv('CLEAN_STATE', False)
Expand All @@ -321,9 +272,6 @@ def prepare_node(app, state_migration_class):

run_snapshot_starter(data_dir, conf)

# Migrate RocksDB to new database scheme
migrate_state(data_dir, config_path, state_migration_class)


def run_cmd(exec_app, node_class, generator_class, default_options):
if exec_app == ExecutableApp.generator:
Expand Down Expand Up @@ -407,8 +355,7 @@ def validate_crypto(config, config_file):

validate_crypto(conf, config_path)

state_migration_class = 'com.wavesenterprise.StateMigration'
prepare_node(exec_app, state_migration_class)
prepare_node(exec_app)

default_options = [
('-XX:+', 'AlwaysPreTouch'),
Expand Down
Loading

0 comments on commit bc8af05

Please sign in to comment.