Skip to content

Commit

Permalink
added DEVNET_SOLANA_URL (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinaNikolaevaa authored Jan 13, 2025
1 parent f796f79 commit 13b3f36
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .github/actions/create-tf-stand/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ runs:
echo "USE PRICE: ${{ inputs.use_real_price }}"
ssh_key='/tmp/ci-stands'
echo "${{ inputs.ci_stands_key_hcloud }}" >> ${ssh_key} && chmod 400 ${ssh_key}
python3 ./clickfile.py infra deploy --current_branch ${{ github.ref_name}} --head_branch ${{ github.head_ref }} --base_branch ${{ github.base_ref }} --use-real-price ${{inputs.use_real_price}}
python3 ./clickfile.py infra deploy --current_branch ${{ github.ref_name}} \
--head_branch ${{ github.head_ref }} \
--base_branch ${{ github.base_ref }} \
--use-real-price ${{inputs.use_real_price}} \
--devnet-solana-url ${{env.DEVNET_SOLANA_URL}}
- uses: actions/upload-artifact@v4
with:
name: tf-state
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ env:
NETWORK: ${{ github.event.inputs.network || 'terraform' }}
NUMPROCESSES: ${{ github.event.inputs.numprocesses || 8 }}
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
SOLANA_URL: "${{ secrets.SOLANA_URL }}"
DEVNET_SOLANA_URL: "${{ secrets.SOLANA_URL }}"
FAUCET_URL: "${{ secrets.DEVNET_FAUCET_URL }}"
IMAGE: ${{ github.repository_owner }}/neon_tests
DOCKER_HUB_ORG_NAME: ${{ github.repository_owner }}
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
-e ETH_BANK_PRIVATE_KEY_MAINNET=${{ secrets.ETH_BANK_PRIVATE_KEY_MAINNET }} \
-e BANK_PRIVATE_KEY_MAINNET=${{ secrets.BANK_PRIVATE_KEY_MAINNET }} \
-e BANK_PRIVATE_KEY=${{ secrets.BANK_PRIVATE_KEY }} \
-e SOLANA_URL \
-e DEVNET_SOLANA_URL \
-e SOLANA_IP -e PROXY_IP \
--name=${{ env.CONTAINER }} ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }} /bin/bash
- name: Run basic proxy tests
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/compiler_compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ env:
NETWORK: ${{ github.event.inputs.network || 'terraform' }}
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
FAUCET_URL: "${{ secrets.DEVNET_FAUCET_URL }}"
SOLANA_URL: "${{ secrets.SOLANA_URL }}"
DEVNET_SOLANA_URL: "${{ secrets.SOLANA_URL }}"
NUMPROCESSES: 2
IMAGE: ${{ github.repository_owner }}/neon_tests
CONTAINER: compilers-${{ github.run_id }}
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
timeout-minutes: 20
run: |
docker exec -i ${{ env.CONTAINER }} \
/bin/bash -c "export DEVNET_FAUCET_URL=${{ env.FAUCET_URL }} && export SOLANA_URL=${{ env.SOLANA_URL }} && \
/bin/bash -c "export DEVNET_FAUCET_URL=${{ env.FAUCET_URL }} && export DEVNET_SOLANA_URL=${{ env.DEVNET_SOLANA_URL }} && \
export SOLANA_IP=${{ env.SOLANA_IP }} && export PROXY_IP=${{ env.PROXY_IP }} && \
python3 ./clickfile.py run compiler_compatibility --network ${{ env.NETWORK }} --numprocesses ${{ env.NUMPROCESSES }}"
- name: "Generate allure report"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/economy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
IMAGE: ${{ github.repository_owner }}/neon_tests
CONTAINER: "economy-${{ github.run_id }}"
DOCKER_HUB_ORG_NAME: ${{ github.repository_owner }}
DEVNET_SOLANA_URL: ${{secrets.SOLANA_URL}}
jobs:
dockerize:
if: ${{ github.ref_name != 'develop'}}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
IMAGE: ${{ github.repository_owner }}/neon_tests
CONTAINER: services-${{ github.run_id }}
FAUCET_URL: "${{ secrets.DEVNET_FAUCET_URL }}"
SOLANA_URL: "${{ secrets.SOLANA_URL }}"
DEVNET_SOLANA_URL: "${{ secrets.SOLANA_URL }}"
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
DOCKER_HUB_ORG_NAME: ${{ github.repository_owner }}
jobs:
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
- name: "Run Playwright Tests"
run: |
docker exec -i ${{ env.CONTAINER }} \
/bin/bash -c "export DEVNET_FAUCET_URL=${{ env.FAUCET_URL }} && export SOLANA_URL=${{ env.SOLANA_URL }} && \
/bin/bash -c "export DEVNET_FAUCET_URL=${{ env.FAUCET_URL }} && export DEVNET_SOLANA_URL=${{ env.DEVNET_SOLANA_URL }} && \
xvfb-run python3 ./clickfile.py run ui --network=${{ env.NETWORK }} --ui-item=neonpass"
- name: "Generate allure report"
if: always()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ on:
env:
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
FAUCET_URL: "${{ secrets.DEVNET_FAUCET_URL }}"
SOLANA_URL: "${{ secrets.SOLANA_URL }}"
DEVNET_SOLANA_URL: "${{ secrets.SOLANA_URL }}"
NUMPROCESSES: 4
IMAGE: ${{ github.repository_owner }}/neon_tests
CONTAINER: services-${{ github.run_id }}
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
id: services
run: |
docker exec -i ${{ env.CONTAINER }} \
/bin/bash -c "export DEVNET_FAUCET_URL=${{ env.FAUCET_URL }} && export SOLANA_URL=${{ env.SOLANA_URL }} && \
/bin/bash -c "export DEVNET_FAUCET_URL=${{ env.FAUCET_URL }} && export DEVNET_SOLANA_URL=${{ env.DEVNET_SOLANA_URL }} && \
python3 ./clickfile.py run services --network ${{ env.NETWORK }} --numprocesses ${{ env.NUMPROCESSES }}"
- name: "Generate allure report"
if: always()
Expand Down
4 changes: 3 additions & 1 deletion clickfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,8 @@ def get_stand_param(current_branch, head_branch, base_branch, param):
@click.option("--head_branch", default="", help="Feature branch name")
@click.option("--base_branch", default="", help="Target branch of the pull request")
@click.option("--use-real-price", required=False, default="0", help="Remove CONST_GAS_PRICE from proxy")
def deploy(current_branch, head_branch, base_branch, use_real_price):
@click.option("--devnet-solana-url", required=True, help="Solana devnet url")
def deploy(current_branch, head_branch, base_branch, devnet_solana_url, use_real_price):
# use feature branch or version tag as tag for proxy, evm and faucet images or use latest
env = define_stand_env_by_branch(current_branch, head_branch, base_branch)
use_real_price = True if use_real_price == "1" else False
Expand All @@ -1064,6 +1065,7 @@ def deploy(current_branch, head_branch, base_branch, use_real_price):
env["faucet_tag"],
env["evm_branch"],
env["proxy_branch"],
devnet_solana_url,
use_real_price)


Expand Down
7 changes: 2 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def pytest_configure(config: Config):
global COST_REPORT_DIR
COST_REPORT_DIR = config.getoption("--cost_reports_dir")

solana_url_env_vars = ["SOLANA_URL", "DEVNET_INTERNAL_RPC", "MAINNET_INTERNAL_RPC"]
network_name = config.getoption("--network")
envs_file = config.getoption("--envs")
with open(pathlib.Path().parent.parent / envs_file, "r+") as f:
Expand All @@ -132,10 +131,8 @@ def pytest_configure(config: Config):
env = environments[network_name]
env["name"] = EnvName(network_name)
if network_name in ["devnet", "tracer_ci"]:
for solana_env_var in solana_url_env_vars:
if solana_env_var in os.environ and os.environ[solana_env_var]:
env["solana_url"] = os.environ.get(solana_env_var)
break
if "DEVNET_SOLANA_URL" in os.environ and os.environ["DEVNET_SOLANA_URL"]:
env["solana_url"] = os.environ.get("DEVNET_SOLANA_URL")
if "PROXY_URL" in os.environ and os.environ["PROXY_URL"]:
env["proxy_url"] = os.environ.get("PROXY_URL")
if "DEVNET_FAUCET_URL" in os.environ and os.environ["DEVNET_FAUCET_URL"]:
Expand Down
6 changes: 4 additions & 2 deletions deploy/cli/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
os.environ["TF_VAR_run_number"] = os.environ.get("GITHUB_RUN_NUMBER", "0")
os.environ["TF_VAR_branch"] = os.environ.get("GITHUB_REF_NAME", "develop").replace("/", "-").replace("_", "-")


terraform = Terraform(working_dir=pathlib.Path(__file__).parent.parent / "hetzner")

WEB3_CLIENT = NeonChainWeb3Client(os.environ.get("PROXY_URL"))
Expand All @@ -45,7 +44,7 @@ def set_github_env(envs: tp.Dict, upper=True) -> None:


def deploy_infrastructure(
evm_tag, proxy_tag, faucet_tag, evm_branch, proxy_branch, use_real_price: bool = False
evm_tag, proxy_tag, faucet_tag, evm_branch, proxy_branch, devnet_solana_url, use_real_price: bool = False
) -> dict:
print(
f"Deploy infrastructure with evm_tag: {evm_tag}, "
Expand All @@ -57,6 +56,8 @@ def deploy_infrastructure(
os.environ["TF_VAR_proxy_image_tag"] = proxy_tag
os.environ["TF_VAR_proxy_model_commit"] = proxy_branch
os.environ["TF_VAR_dockerhub_org_name"] = os.environ.get("GITHUB_REPOSITORY_OWNER")
os.environ["TF_VAR_devnet_solana_url"] = devnet_solana_url
os.environ["TF_LOG"] = "DEBUG"

if use_real_price:
os.environ["TF_VAR_use_real_price"] = "1"
Expand Down Expand Up @@ -88,6 +89,7 @@ def destroy_infrastructure():
os.environ["TF_VAR_proxy_image_tag"] = "latest"
os.environ["TF_VAR_proxy_model_commit"] = "develop"
os.environ["TF_VAR_dockerhub_org_name"] = os.environ.get("GITHUB_REPOSITORY_OWNER")
os.environ["TF_VAR_devnet_solana_url"] = os.environ.get("DEVNET_SOLANA_URL")

log = logging.getLogger()
log.handlers = []
Expand Down
4 changes: 4 additions & 0 deletions deploy/hetzner/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ variable "neon_evm_commit" {
type = string
}

variable "devnet_solana_url" {
type = string
}

variable "faucet_model_commit" {
type = string
Expand All @@ -43,6 +46,7 @@ data "template_file" "solana_init" {
neon_evm_commit = var.neon_evm_commit
faucet_model_commit = var.faucet_model_commit
dockerhub_org_name = var.dockerhub_org_name
devnet_solana_url = var.devnet_solana_url
}
}

Expand Down
3 changes: 3 additions & 0 deletions deploy/hetzner/solana_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export REVISION=${proxy_image_tag}
export NEON_EVM_COMMIT=${neon_evm_commit}
export FAUCET_COMMIT=${faucet_model_commit}
export DOCKERHUB_ORG_NAME=${dockerhub_org_name}
export DEVNET_SOLANA_URL=${devnet_solana_url}
export PROXY_IMAGE_NAME="neon-proxy.py"

# Receive docker-compose file and create override file
Expand All @@ -50,6 +51,8 @@ cat > docker-compose-ci.override.yml<<EOF
version: "3"
services:
solana:
environment:
DEVNET_SOLANA_URL: $DEVNET_SOLANA_URL
ports:
- "8899:8899"
- "8900:8900"
Expand Down
7 changes: 4 additions & 3 deletions integration/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,16 @@ def account_with_all_tokens(
) -> LocalAccount:
neon_account = web3_client.create_account_with_balance(faucet, bank_account=eth_bank_account, amount=500)
if web3_client_sol:
lamports = 10 * LAMPORT_PER_SOL
if pytestconfig.environment.use_bank:
evm_loader.send_sol(bank_account, solana_account.pubkey(), int(1 * LAMPORT_PER_SOL))
evm_loader.send_sol(bank_account, solana_account.pubkey(), lamports)
else:
evm_loader.request_airdrop(solana_account.pubkey(), 1 * LAMPORT_PER_SOL)
evm_loader.request_airdrop(solana_account.pubkey(), lamports)
evm_loader.deposit_wrapped_sol_from_solana_to_neon(
solana_account,
neon_account,
web3_client_sol.eth.chain_id,
int(1 * LAMPORT_PER_SOL),
lamports,
)
for client in [web3_client_usdt, web3_client_eth]:
if client:
Expand Down
39 changes: 21 additions & 18 deletions integration/tests/economy/test_economics.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_send_neon_to_non_existent_account(
w3_client, token_price = client_and_price
sol_balance_before = operator.get_solana_balance()
token_balance_before = operator.get_token_balance(w3_client)
transfer_value = 50000000
transfer_value = 500000
acc2 = w3_client.create_account()
receipt = w3_client.send_tokens(account_with_all_tokens, acc2, transfer_value, tx_type=tx_type)
assert w3_client.get_balance(acc2) == transfer_value
Expand Down Expand Up @@ -125,21 +125,23 @@ def test_send_tokens_to_exist_account(
assert_profit(sol_diff, sol_price, token_diff, token_price, w3_client.native_token_name)

def test_send_neon_token_without_chain_id(
self, account_with_all_tokens, web3_client, sol_price, operator, neon_price
self, account_with_all_tokens, web3_client, sol_price, operator, neon_price, faucet
):
# for neon token transactions without chain_id NeonEVM execute it inside NEON network
# checks eip1820
# for a transaction without chain_id users need in 1000 times more neon tokens for the execution
faucet.request_neon(account_with_all_tokens.address, 10000)
acc2 = web3_client.create_account()
sol_balance_before = operator.get_solana_balance()
token_balance_before = operator.get_token_balance(web3_client)

instruction_tx = web3_client.make_raw_tx(
account_with_all_tokens.address, acc2.address, web3.Web3.to_wei(0.1, "ether"), estimate_gas=True
account_with_all_tokens.address, acc2.address, 1000, estimate_gas=True
)

instruction_tx.pop("chainId")

web3_client.send_transaction(account_with_all_tokens, instruction_tx)

sol_balance_after = operator.get_solana_balance()
token_balance_after = operator.get_token_balance(web3_client)
sol_diff = sol_balance_before - sol_balance_after
Expand Down Expand Up @@ -868,13 +870,14 @@ def test_deploy_contract_alt_off(
# if no fails - other tests interference
"""Trigger transaction than requires less than 30 accounts"""
accounts_quantity = 10
sender = accounts[1]
sol_balance_before = operator.get_solana_balance()
token_balance_before = operator.get_token_balance(web3_client)

tx = web3_client.make_raw_tx(from_=accounts[0].address, tx_type=tx_type)
tx = web3_client.make_raw_tx(from_=sender.address, tx_type=tx_type)

instr = alt_contract.functions.fill(accounts_quantity).build_transaction(tx)
receipt = web3_client.send_transaction(accounts[0], instr)
receipt = web3_client.send_transaction(sender, instr)
block = int(receipt["blockNumber"])

response = wait_for_block(sol_client, block)
Expand All @@ -895,12 +898,13 @@ def test_deploy_contract_alt_off(
)
get_gas_used_percent(web3_client, receipt)

def test_deploy_big_contract_with_structures(self, client_and_price, account_with_all_tokens, sol_price, operator):
def test_deploy_big_contract_with_structures(self, client_and_price, web3_client, web3_client_sol,
account_with_all_tokens, sol_price, operator):
w3_client, token_price = client_and_price

sol_balance_before = operator.get_solana_balance()
token_balance_before = operator.get_token_balance(w3_client)

make_nonce_the_biggest_for_chain(account_with_all_tokens, w3_client, [web3_client, web3_client_sol])
contract, receipt = w3_client.deploy_and_get_contract("EIPs/ERC3475", "0.8.10", account_with_all_tokens)

sol_balance_after = operator.get_solana_balance()
Expand All @@ -920,16 +924,15 @@ def test_deploy_big_contract_with_structures_eip_1559(
sol_price: float,
operator: Operator,
):
sender_account = accounts[3]

sol_balance_before = operator.get_solana_balance()
token_balance_before = operator.get_token_balance(web3_client)

account = accounts.create_account()

contract, receipt = web3_client.deploy_and_get_contract(
contract="EIPs/ERC3475",
version="0.8.10",
account=account,
account=sender_account,
tx_type=TransactionType.EIP_1559,
)

Expand Down Expand Up @@ -1032,13 +1035,13 @@ def test_eip_1559_profit(
account_with_all_tokens: LocalAccount,
sol_price: float
):
# Calculate profit and expense with a type-0 transaction
# Calculate profit and compare with a type-0 transaction, type-0 transaction should be more profitable
w3_client, token_price = client_and_price
sol_balance_before = operator.get_solana_balance()
token_balance_before = operator.get_token_balance(w3_client)

recipient_0 = w3_client.create_account()
value = 1000000
value = 100

w3_client.send_tokens(
from_=account_with_all_tokens,
Expand All @@ -1059,10 +1062,10 @@ def test_eip_1559_profit(
sol_balance_before = operator.get_solana_balance()
token_balance_before = operator.get_token_balance(w3_client)

base_fee_per_gas = w3_client.base_fee_per_gas()
base_fee_multiplier = 1.1
max_priority_fee_per_gas = 100000000
max_fee_per_gas = int((base_fee_per_gas * base_fee_multiplier) + max_priority_fee_per_gas)
latest_block: web3.types.BlockData = w3_client._web3.eth.get_block(block_identifier="latest") # noqa
base_fee_per_gas = latest_block.baseFeePerGas # noqa
max_priority_fee_per_gas = w3_client._web3.eth._max_priority_fee() # noqa
max_fee_per_gas = (5 * base_fee_per_gas) + max_priority_fee_per_gas
recipient_2 = w3_client.create_account()

w3_client.send_tokens_eip_1559(
Expand All @@ -1085,4 +1088,4 @@ def test_eip_1559_profit(
profit_tx_type_2 = revenue_usd_2 - expense_usd_2

# compare operator profits
assert profit_tx_type_2 > profit_tx_type_0
assert profit_tx_type_2 < profit_tx_type_0
2 changes: 1 addition & 1 deletion utils/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def lower(self):


class InputTestConstants(Enum):
NEW_USER_REQUEST_AMOUNT = 200
NEW_USER_REQUEST_AMOUNT = 400
DEFAULT_TRANSFER_AMOUNT = 0.1
SAMPLE_AMOUNT = 0.5
ROUND_DIGITS = 3
Expand Down
35 changes: 22 additions & 13 deletions utils/faucet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,28 @@ def __init__(
self.web3_client = web3_client

def request_neon(self, address: str, amount: int = 100) -> requests.Response:
assert address.startswith("0x")
assert address.startswith("0x"), "Invalid address format"
url = urllib.parse.urljoin(self._url, "request_neon")
balance_before = self.web3_client.get_balance(address)
response = self._session.post(url, json={"amount": amount, "wallet": address})
counter = 0
while "Blockhash not found" in response.text and counter < 3:
time.sleep(3)
response = self._session.post(url, json={"amount": amount, "wallet": address})
counter += 1
assert (
response.ok
), "Faucet returned error: {}, status code: {}, url: {}".format(
response.text, response.status_code, response.url
)

max_retries = 5
retry_delay = 3 # seconds

for attempt in range(max_retries):
try:
response = self._session.post(url, json={"amount": amount, "wallet": address})
if "Blockhash not found" in response.text:
time.sleep(retry_delay)
continue
response.raise_for_status()
break
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError) as e:
if attempt < max_retries - 1:
time.sleep(retry_delay)
else:
raise RuntimeError(
"Failed to request neon after {} attempts: {}".format(max_retries, str(e))
)

wait_condition(lambda: self.web3_client.get_balance(address) > balance_before)
return response
return response

0 comments on commit 13b3f36

Please sign in to comment.