Skip to content

Commit

Permalink
Merge pull request #12 from allbridge-io/eof/develop-merge
Browse files Browse the repository at this point in the history
EOF merge
  • Loading branch information
YaroslavNekryach authored Dec 18, 2023
2 parents 7d9e3cf + 7269a63 commit a103896
Show file tree
Hide file tree
Showing 188 changed files with 5,844 additions and 4,212 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Dockerfile
Dockerfile.*
.*.swp

.git
.github
.gitignore
.gitmodules
Expand Down
40 changes: 26 additions & 14 deletions .github/workflows/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@

DOCKER_USER = os.environ.get("DHUBU")
DOCKER_PASSWORD = os.environ.get("DHUBP")
IMAGE_NAME = 'neonlabsorg/evm_loader'
SOLANA_NODE_VERSION = 'v1.14.20'
SOLANA_BPF_VERSION = 'v1.14.20'
IMAGE_NAME = os.environ.get("IMAGE_NAME")
RUN_LINK_REPO = os.environ.get("RUN_LINK_REPO")
SOLANA_NODE_VERSION = 'v1.16.17'
SOLANA_BPF_VERSION = 'v1.16.17'

VERSION_BRANCH_TEMPLATE = r"[vt]{1}\d{1,2}\.\d{1,2}\.x.*"
docker_client = docker.APIClient()
Expand Down Expand Up @@ -105,7 +106,7 @@ def run_tests(github_sha):
project_name = f"neon-evm-{github_sha}"
stop_containers(project_name)

run_subprocess(f"docker-compose -p {project_name} -f ./evm_loader/docker-compose-ci.yml up -d")
run_subprocess(f"docker-compose -p {project_name} -f ./ci/docker-compose-ci.yml up -d")
container_name = get_solana_container_name(project_name)
click.echo("Start tests")
exec_id = docker_client.exec_create(
Expand All @@ -126,6 +127,9 @@ def run_tests(github_sha):
print("Part of tests are skipped")

exec_status = docker_client.exec_inspect(exec_id['Id'])["ExitCode"]

run_subprocess(f"docker-compose -p {project_name} -f ./ci/docker-compose-ci.yml logs dk-neon-api")

stop_containers(project_name)

if tests_are_failed or exec_status == 1:
Expand All @@ -134,17 +138,17 @@ def run_tests(github_sha):

def get_solana_container_name(project_name):
data = subprocess.run(
f"docker-compose -p {project_name} -f ./evm_loader/docker-compose-ci.yml ps",
f"docker-compose -p {project_name} -f ./ci/docker-compose-ci.yml ps",
shell=True, capture_output=True, text=True).stdout
click.echo(data)
pattern = rf'{project_name}_[a-zA-Z0-9_]+'
pattern = rf'{project_name}_solana_[1-9]+'

match = re.search(pattern, data)
return match.group(0)


def stop_containers(project_name):
run_subprocess(f"docker-compose -p {project_name} -f ./evm_loader/docker-compose-ci.yml down")
run_subprocess(f"docker-compose -p {project_name} -f ./ci/docker-compose-ci.yml down")


@cli.command(name="trigger_proxy_action")
Expand All @@ -155,16 +159,22 @@ def stop_containers(project_name):
@click.option('--token')
@click.option('--is_draft')
@click.option('--labels')
def trigger_proxy_action(head_ref_branch, base_ref_branch, github_ref, github_sha, token, is_draft, labels):
@click.option('--pr_url')
@click.option('--pr_number')
def trigger_proxy_action(head_ref_branch, base_ref_branch, github_ref, github_sha, token, is_draft, labels,
pr_url, pr_number):
is_develop_branch = github_ref in ['refs/heads/develop', 'refs/heads/master']
is_tag_creating = 'refs/tags/' in github_ref
is_version_branch = re.match(VERSION_BRANCH_TEMPLATE, github_ref.replace("refs/heads/", "")) is not None
is_FTS_labeled_not_draft = 'FullTestSuit' in labels and is_draft != "true"
is_FTS_labeled_not_draft = 'fullTestSuit' in labels and is_draft != "true"
is_extended_FTS_labeled_not_draft = 'extendedFullTestSuit' in labels and is_draft != "true"

if is_develop_branch or is_tag_creating or is_version_branch or is_FTS_labeled_not_draft:
full_test_suite = "true"
if is_extended_FTS_labeled_not_draft:
test_set = "extendedFullTestSuite"
elif is_develop_branch or is_tag_creating or is_version_branch or is_FTS_labeled_not_draft:
test_set = "fullTestSuite"
else:
full_test_suite = "false"
test_set = "basic"

github = GithubClient(token)

Expand All @@ -181,14 +191,16 @@ def trigger_proxy_action(head_ref_branch, base_ref_branch, github_ref, github_sh
proxy_branch = 'develop'
click.echo(f"Proxy branch: {proxy_branch}")

initial_pr = f"{pr_url}/{pr_number}/comments" if pr_number else ""

runs_before = github.get_proxy_runs_list(proxy_branch)
runs_count_before = github.get_proxy_runs_count(proxy_branch)
github.run_proxy_dispatches(proxy_branch, github_ref, github_sha, full_test_suite)
github.run_proxy_dispatches(proxy_branch, github_ref, github_sha, test_set, initial_pr)
wait_condition(lambda: github.get_proxy_runs_count(proxy_branch) > runs_count_before)

runs_after = github.get_proxy_runs_list(proxy_branch)
proxy_run_id = list(set(runs_after) - set(runs_before))[0]
link = f"https://github.com/neonlabsorg/proxy-model.py/actions/runs/{proxy_run_id}"
link = f"https://github.com/{RUN_LINK_REPO}/actions/runs/{proxy_run_id}"
click.echo(f"Proxy run link: {link}")
click.echo("Waiting for completed status...")
wait_condition(lambda: github.get_proxy_run_info(proxy_run_id)["status"] == "completed", timeout_sec=10800, delay=5)
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/github_api_client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import click
import requests
import os


class GithubClient():
PROXY_ENDPOINT = "https://api.github.com/repos/neonlabsorg/proxy-model.py"
PROXY_ENDPOINT = os.environ.get("PROXY_ENDPOINT")

def __init__(self, token):
self.headers = {"Authorization": f"Bearer {token}",
Expand All @@ -22,11 +23,12 @@ def get_proxy_runs_count(self, proxy_branch):
f"{self.PROXY_ENDPOINT}/actions/workflows/pipeline.yml/runs?branch={proxy_branch}", headers=self.headers)
return int(response.json()["total_count"])

def run_proxy_dispatches(self, proxy_branch, github_ref, github_sha, full_test_suite):
def run_proxy_dispatches(self, proxy_branch, github_ref, github_sha, test_set, initial_pr):
data = {"ref": proxy_branch,
"inputs": {"full_test_suite": full_test_suite,
"inputs": {"test_set": test_set,
"neon_evm_commit": github_sha,
"neon_evm_branch": github_ref}
"neon_evm_branch": github_ref,
"initial_pr": initial_pr}
}
response = requests.post(
f"{self.PROXY_ENDPOINT}/actions/workflows/pipeline.yml/dispatches", json=data, headers=self.headers)
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ on:
env:
DHUBU: ${{secrets.DHUBU}}
DHUBP: ${{secrets.DHUBP}}
IMAGE_NAME: ${{vars.IMAGE_NAME}}
PROXY_ENDPOINT: ${{vars.PROXY_ENDPOINT}}
RUN_LINK_REPO: ${{vars.RUN_LINK_REPO}}
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-neon-evm:
runs-on: build-runner
runs-on: neon-evm-1
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -64,9 +67,11 @@ jobs:
--github_ref=${{ github.ref }} \
--token=${{secrets.GHTOKEN }} \
--is_draft=${{github.event.pull_request.draft}} \
--labels='${{ toJson(github.event.pull_request.labels.*.name) }}'
--labels='${{ toJson(github.event.pull_request.labels.*.name) }}' \
--pr_url="${{ github.api_url }}/repos/${{ github.repository }}/issues" \
--pr_number="${{ github.event.pull_request.number }}"
finalize-image:
runs-on: build-runner
runs-on: neon-evm-1
needs:
- trigger-proxy-tests
- run-neon-evm-tests
Expand Down
64 changes: 32 additions & 32 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
ARG SOLANA_IMAGE
# Install BPF SDK
FROM solanalabs/rust:1.64.0 AS builder
FROM solanalabs/rust:1.69.0 AS builder
RUN cargo install rustfilt
WORKDIR /opt
ARG SOLANA_BPF_VERSION
RUN sh -c "$(curl -sSfL https://release.solana.com/"${SOLANA_BPF_VERSION}"/install)" && \
/root/.local/share/solana/install/active_release/bin/sdk/bpf/scripts/install.sh
/root/.local/share/solana/install/active_release/bin/sdk/sbf/scripts/install.sh
ENV PATH=/root/.local/share/solana/install/active_release/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin


# Build evm_loader
FROM builder AS evm-loader-builder
COPY ./evm_loader/ /opt/evm_loader/
WORKDIR /opt/evm_loader
COPY . /opt/neon-evm/
WORKDIR /opt/neon-evm/evm_loader
ARG REVISION
ENV NEON_REVISION=${REVISION}
RUN cargo fmt --check && \
cargo clippy --release && \
cargo build --release && \
cargo build-sbf --arch bpf --features devnet && cp target/deploy/evm_loader.so target/deploy/evm_loader-devnet.so && \
cargo build-sbf --arch bpf --features testnet && cp target/deploy/evm_loader.so target/deploy/evm_loader-testnet.so && \
cargo build-sbf --arch bpf --features govertest && cp target/deploy/evm_loader.so target/deploy/evm_loader-govertest.so && \
cargo build-sbf --arch bpf --features govertest,emergency && cp target/deploy/evm_loader.so target/deploy/evm_loader-govertest-emergency.so && \
cargo build-sbf --arch bpf --features mainnet && cp target/deploy/evm_loader.so target/deploy/evm_loader-mainnet.so && \
cargo build-sbf --arch bpf --features mainnet,emergency && cp target/deploy/evm_loader.so target/deploy/evm_loader-mainnet-emergency.so && \
cargo build-sbf --arch bpf --features ci --dump
cargo build-bpf --features devnet && cp target/deploy/evm_loader.so target/deploy/evm_loader-devnet.so && \
cargo build-bpf --features testnet && cp target/deploy/evm_loader.so target/deploy/evm_loader-testnet.so && \
cargo build-bpf --features govertest && cp target/deploy/evm_loader.so target/deploy/evm_loader-govertest.so && \
cargo build-bpf --features govertest,emergency && cp target/deploy/evm_loader.so target/deploy/evm_loader-govertest-emergency.so && \
cargo build-bpf --features mainnet && cp target/deploy/evm_loader.so target/deploy/evm_loader-mainnet.so && \
cargo build-bpf --features mainnet,emergency && cp target/deploy/evm_loader.so target/deploy/evm_loader-mainnet-emergency.so && \
cargo build-bpf --features ci --dump

# Build Solidity contracts
FROM ethereum/solc:0.8.0 AS solc
FROM ubuntu:20.04 AS contracts
RUN apt-get update && \
DEBIAN_FRONTEND=nontineractive apt-get -y install xxd && \
rm -rf /var/lib/apt/lists/* /var/lib/apt/cache/*
COPY evm_loader/tests/contracts/*.sol /opt/
COPY evm_loader/tests/eof-contracts/*.binary /opt/eof-contracts/
COPY evm_loader/solidity/*.sol /opt/
COPY tests/contracts/*.sol /opt/
COPY tests/eof-contracts/*.binary /opt/eof-contracts/
COPY solidity/*.sol /opt/
#COPY evm_loader/tests/test_solidity_precompiles.json /opt/
COPY --from=solc /usr/bin/solc /usr/bin/solc
WORKDIR /opt/
Expand All @@ -52,10 +52,10 @@ RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install vim less openssl ca-certificates curl python3 python3-pip parallel && \
rm -rf /var/lib/apt/lists/*

COPY evm_loader/tests/requirements.txt /tmp/
COPY tests/requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt

COPY /evm_loader/solidity/ /opt/contracts/contracts/
#COPY /evm_loader/solidity/ /opt/contracts/contracts/
WORKDIR /opt

COPY --from=solana \
Expand All @@ -74,26 +74,26 @@ RUN /opt/solana/bin/solana program dump metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518
COPY evm_loader/solana-run-neon.sh \
/opt/solana/bin/

COPY --from=evm-loader-builder /opt/evm_loader/target/deploy/evm_loader*.so /opt/
COPY --from=evm-loader-builder /opt/evm_loader/target/deploy/evm_loader-dump.txt /opt/
COPY --from=evm-loader-builder /opt/evm_loader/target/release/neon-cli /opt/
COPY --from=evm-loader-builder /opt/evm_loader/target/release/neon-api /opt/
COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/deploy/evm_loader*.so /opt/
COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/deploy/evm_loader-dump.txt /opt/
COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/release/neon-cli /opt/
COPY --from=evm-loader-builder /opt/neon-evm/evm_loader/target/release/neon-api /opt/
COPY --from=solana /usr/bin/spl-token /opt/spl-token
COPY --from=contracts /opt/ /opt/solidity/
COPY --from=contracts /usr/bin/solc /usr/bin/solc
COPY evm_loader/wait-for-solana.sh \
evm_loader/wait-for-neon.sh \
evm_loader/create-test-accounts.sh \
evm_loader/deploy-evm.sh \
evm_loader/deploy-test.sh \
evm_loader/evm_loader-keypair.json \
COPY ci/wait-for-solana.sh \
ci/wait-for-neon.sh \
ci/deploy-evm.sh \
ci/deploy-test.sh \
ci/create-test-accounts.sh \
ci/evm_loader-keypair.json \
/opt/

COPY evm_loader/keys/ /opt/keys
COPY evm_loader/tests /opt/tests
COPY evm_loader/operator1-keypair.json /root/.config/solana/id.json
COPY evm_loader/operator2-keypair.json /root/.config/solana/id2.json
COPY ci/operator-keypairs/ /opt/operator-keypairs
COPY tests /opt/tests
COPY ci/operator-keypairs/id.json /root/.config/solana/id.json
COPY ci/operator-keypairs/id2.json /root/.config/solana/id2.json
COPY ci/keys/ /opt/keys


ENV CONTRACTS_DIR=/opt/solidity/
#ENV CONTRACTS_DIR=/opt/solidity/
ENV PATH=/opt/solana/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt
105 changes: 16 additions & 89 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,92 +1,19 @@
Business Source License 1.1
Neon EVM License

License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
"Business Source License" is a trademark of MariaDB Corporation Ab.

-----------------------------------------------------------------------------

Parameters

Licensor: Neon Labs

Licensed Work: Neon EVM
The Licensed Work is (c) 2021 Neon Labs

-----------------------------------------------------------------------------
Copyright (c) 2023 by Neon Protocol Ltd.
All rights reserved.

Terms

The Licensor hereby grants you the right to copy, modify, create derivative
works, redistribute, and make non-production use of the Licensed Work. The
Licensor may make an Additional Use Grant, above, permitting limited
production use.

Effective on the Change Date, or the fourth anniversary of the first publicly
available distribution of a specific version of the Licensed Work under this
License, whichever comes first, the Licensor hereby grants you rights under
the terms of the Change License, and the rights granted in the paragraph
above terminate.

If your use of the Licensed Work does not comply with the requirements
currently in effect as described in this License, you must purchase a
commercial license from the Licensor, its affiliated entities, or authorized
resellers, or you must refrain from using the Licensed Work.

All copies of the original and modified Licensed Work, and derivative works
of the Licensed Work, are subject to this License. This License applies
separately for each version of the Licensed Work and the Change Date may vary
for each version of the Licensed Work released by Licensor.

You must conspicuously display this License on each original or modified copy
of the Licensed Work. If you receive the Licensed Work in original or
modified form from a third party, the terms and conditions set forth in this
License apply to your use of that work.

Any use of the Licensed Work in violation of this License will automatically
terminate your rights under this License for the current and all other
versions of the Licensed Work.

This License does not grant you any right in any trademark or logo of
Licensor or its affiliates (provided that you may use a trademark or logo of
Licensor as expressly required by this License).

TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
TITLE.

MariaDB hereby grants you permission to use this License’s text to license
your works, and to refer to it using the trademark "Business Source License",
as long as you comply with the Covenants of Licensor below.

-----------------------------------------------------------------------------

Covenants of Licensor

In consideration of the right to use this License’s text and the "Business
Source License" name and trademark, Licensor covenants to MariaDB, and to all
other recipients of the licensed work to be provided by Licensor:

1. To specify as the Change License the GPL Version 2.0 or any later version,
or a license that is compatible with GPL Version 2.0 or a later version,
where "compatible" means that software provided under the Change License can
be included in a program with software provided under GPL Version 2.0 or a
later version. Licensor may specify additional Change Licenses without
limitation.

2. To either: (a) specify an additional grant of rights to use that does not
impose any additional restriction on the right granted in this License, as
the Additional Use Grant; or (b) insert the text "None".

3. To specify a Change Date.

4. Not to modify this License in any other way.

-----------------------------------------------------------------------------

Notice

The Business Source License (this document, or the "License") is not an Open
Source license. However, the Licensed Work will eventually be made available
under an Open Source License, as stated in this License.
1. Grant of license: non-commercial usage for information purposes only, without the right to copy or compile.
2. Restrictions: The code, in whole or in part (“Licensed Work”), may not be copied, reproduced, distributed, modified, or forked without explicit prior written permission from Neon Protocol Ltd.
3. No Redistribution: Redistribution of the source code or any derivative work is strictly prohibited. If you wish to use in any way or distribute the software, please request permission by contacting legal@neonfoundation.io.
4. Audit and Enforcement: Neon Protocol Ltd. reserves the right to audit uses of the Licensed Work to ensure compliance with this license.
5. Legal Recourse for Violation: Violations may result in legal action, including injunctions, damages, and recovery of legal costs.
6. Notification of Changes: Any modifications under permission must be documented and communicated to Neon Protocol Ltd.
7. Attribution and Branding: Distributions (if approved by Neon Protocol Ltd) must include attribution to Neon Protocol Ltd. and adhere to specified branding guidelines.
8. Limitations on Transferability: Rights and permissions under this license are non-transferable and non-sublicensable, unless explicitly allowed by Neon Protocol Ltd.
9. Acknowledgement: Permitted redistributions must include: “Copyright (c) 2023 by Neon Protocol Ltd”.
10. License Scope: Applies to all versions of the Licensed Work, including copies, modifications, and derivatives.
11. Termination for Violation: Any violation terminates your rights for all versions of the Licensed Work.
12. Trademark Rights: No rights granted in any trademark or logo of the Neon Protocol Ltd, except as required by this License.
13. Disclaimer: The Licensed Work is provided “AS IS” without any warranties
File renamed without changes.
Loading

0 comments on commit a103896

Please sign in to comment.