Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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 .buildkite/steps/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ docker pull neonlabsorg/evm_loader:${EVM_LOADER_REVISION}
docker build -t neonlabsorg/proxy:${REVISION} \
--build-arg SOLANA_REVISION=${SOLANA_REVISION} \
--build-arg EVM_LOADER_REVISION=${EVM_LOADER_REVISION} \
--build-arg PROXY_REVISION=${REVISION} \
.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ FROM neonlabsorg/solana:${SOLANA_REVISION} AS cli
FROM neonlabsorg/evm_loader:${EVM_LOADER_REVISION} AS spl

FROM ubuntu:20.04
ARG PROXY_REVISION

RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt -y install \
Expand Down Expand Up @@ -41,6 +42,7 @@ COPY --from=spl /opt/solana_utils.py \
COPY --from=spl /opt/neon-cli /spl/bin/emulator

COPY . /opt
RUN sed -i 's/NEON_PROXY_REVISION_TO_BE_REPLACED/'"$PROXY_REVISION"'/g' /opt/proxy/plugin/solana_rest_api.py
COPY proxy/operator-keypair.json /root/.config/solana/id.json
RUN cd /usr/local/lib/python3.8/dist-packages/ && patch -p0 </opt/solana-py.patch

Expand Down
5 changes: 5 additions & 0 deletions proxy/plugin/solana_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
modelInstance = None

EXTRA_GAS = int(os.environ.get("EXTRA_GAS", "0"))
NEON_PROXY_PKG_VERSION = '0.4.1-rc0'
NEON_PROXY_REVISION = 'NEON_PROXY_REVISION_TO_BE_REPLACED'

class EthereumModel:
def __init__(self):
Expand Down Expand Up @@ -86,6 +88,9 @@ def get_solana_account() -> Optional[sol_Account]:
solana_account = sol_Account(values)
return solana_account

def neon_proxy_version(self):
return 'Neon-proxy/v' + NEON_PROXY_PKG_VERSION + '-' + NEON_PROXY_REVISION

def web3_clientVersion(self):
neon_config_load(self)
return self.neon_config_dict['web3_clientVersion']
Expand Down
48 changes: 48 additions & 0 deletions proxy/testing/test_neon_proxy_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import unittest
import os
import requests
import json
import inspect

from proxy.plugin.solana_rest_api import NEON_PROXY_PKG_VERSION, NEON_PROXY_REVISION

proxy_url = os.environ.get('PROXY_URL', 'http://localhost:9090/solana')
headers = {'Content-type': 'application/json'}


def get_line_number():
cf = inspect.currentframe()
return cf.f_back.f_lineno


class TestNeonProxyVersion(unittest.TestCase):
@classmethod
def setUpClass(cls):
response = json.loads(requests.post(
proxy_url, headers=headers,
data=json.dumps({"jsonrpc": "2.0",
"id": get_line_number(),
"method": "eth_blockNumber",
"params": []
})).text)
print('response:', response)
block_number = response['result']
print('blockNumber:', int(block_number, 16))

def test_01_neon_proxy_version(self):
print("https://github.com/neonlabsorg/proxy-model.py/issues/320")
response = json.loads(requests.post(
proxy_url, headers=headers,
data=json.dumps({"jsonrpc": "2.0",
"id": get_line_number(),
"method": "neon_proxy_version",
"params": []
})).text)
print('response:', response)
neon_proxy_version = response['result']
print('neon_proxy_version:', neon_proxy_version)
self.assertEqual(neon_proxy_version, 'Neon-proxy/v' + NEON_PROXY_PKG_VERSION + '-' + NEON_PROXY_REVISION)


if __name__ == '__main__':
unittest.main()