blocknetdx / eth-payment-processor Goto Github PK
View Code? Open in Web Editor NEWeth-payment-processor
eth-payment-processor
use local/external host for eth or aBlock payment.
spin node if necessary
After the latest updates to eth-payment-processor
the container keeps restarting.
The only possible errors I can see in the logs are as follows:
column "min_amount_usd" of relation "payment" already exists
ADD payment min_amount_ablock_usd float8
column "min_amount_ablock_usd" of relation "payment" already exists
ADD payment min_amount_aablock_usd float8
column "min_amount_aablock_usd" of relation "payment" already exists
ADD payment min_amount_sysblock_usd float8
column "min_amount_sysblock_usd" of relation "payment" already exists
and:
Traceback (most recent call last):
File "/app/manager/payment_processor.py", line 22, in <module>
web3_helper = Web3Helper()
File "/app/manager/util/eth_payments.py", line 63, in __init__
self.w3[evm].middleware_onion.inject(geth_poa_middleware, layer=0)
AttributeError: 'NoneType' object has no attribute 'middleware_onion'
RENAME payment address eth_address
column "address" does not exist
docker ps
shows: blocknetdx/eth-payment-processor:latest "/bin/sh -c 'python3…" 16 hours ago Restarting (1) 32 seconds ago
@Tryou is reporting the payment processor (which runs /app/manager/main.py
in the exrproxy-env-payment-1
container) is using 100% of one CPU, even when no payment blockchains are attached to EXR ENV. It should be sitting idle, waiting for payment blockchains to be attached. @Tryou's comments:
flat 100% cpu usage with no connected chain and even 'between' the connect attempts =
problem with multithreading, main loop refresh timers, conflict between 2 py modules, etc
and
looking on GH, the big bag of changes made on Jan 11, 2022,
seems it went offroad from here,
maybe something with flask, async, threading, no idea
I don't know that we've tested whether it works to activate a new project with an aBLOCK payment, so I decided to test it (even though it cost me $10 in eth gas fees to send the aBLOCK!)
Here's what I did:
{
"result": {
"api_key": "P2kLB9PpK2Be_PzG6u97pTnVkjaVVGFChDNv2e9vm2A",
"expiry_time": "2022-02-14 04:00:26 EST",
"payment_amount_tier1_aablock": 64.7457,
"payment_amount_tier1_ablock": 1.367188,
"payment_amount_tier1_eth": 0.012199,
"payment_amount_tier2_aablock": 369.975426,
"payment_amount_tier2_ablock": 7.8125,
"payment_amount_tier2_eth": 0.069709,
"payment_avax_address": "0x56f9F4a48c4D614b51C6036BE53d7dd89Aa90a1e",
"payment_eth_address": "0xb847f6734975D99EB90E819DfEDfE666b4A15CD0",
"project_id": "8ff20bd2-3505-4ff2-826a-dbd6a36fa481"
}
}
0xb847f6734975D99EB90E819DfEDfE666b4A15CD0
list_projects
call to see if my new project had become active. It had not become active.exrproxy-env_eth_payment_api_1
container and found error messages like this:[2022-02-14:00:39:29] CRITICAL - error handling eth back event
Traceback (most recent call last):
File "/app/manager/util/eth_payments.py", line 164, in eth_start_back
self.handle_eth_events(events)
File "<string>", line 2, in handle_eth_events
File "/usr/local/lib/python3.8/site-packages/pony/orm/core.py", line 533, in new_func
result = func(*args, **kwargs)
File "/app/manager/util/eth_payments.py", line 246, in handle_eth_events
self.handle_eth_event(event)
File "/app/manager/util/eth_payments.py", line 283, in handle_eth_event
ablock_accounts = self.check_ablock_balance()
File "/app/manager/util/eth_payments.py", line 266, in check_ablock_balance
balance_contract = self.contract_ablock.functions.balanceOf(contract_address).call()
File "/usr/local/lib/python3.8/site-packages/web3/contract.py", line 878, in __call__
clone._set_function_info()
File "/usr/local/lib/python3.8/site-packages/web3/contract.py", line 883, in _set_function_info
self.abi = find_matching_fn_abi(
File "/usr/local/lib/python3.8/site-packages/web3/_utils/contracts.py", line 163, in find_matching_fn_abi
raise ValidationError(message)
web3.exceptions.ValidationError:
Could not identify the intended function with name `balanceOf`, positional argument(s) of type `(<class 'str'>,)` and keyword argument(s) of type `{}`.
Found 1 function(s) with the name `balanceOf`: ['balanceOf(address)']
Function invocation failed due to no matching argument types.
This was on my VPS4 if you want to login and poke around.
There are two distinct tokens on the SYS NEVM: SYS
and WSYS
.
Wrapped SYS is required to swap on the Pegasys AMM.
SYS is the token that is received by users who bridge from SYS UTXO to SYS NEVM and therefore the primary token of the SYS NEVM network.
Accepting only WSYS for XQuery and Hydra requires an extra step for users (swap from SYS > WSYS on Pegasys DEX) and therefore I would suggest we change WSYS to SYS.
Contract address for WSYS: 0xd3e822f3ef011Ca5f17D82C956D952D8d7C3A1BB
Contract address for SYS:
TBD before making any changes
eth-payment-processor
for EXR projects currently allows payment in aBLOCK, aaBLOCK and ETH but not AVAX.
An AVAX address is generated but AVAX doesn't show in the list of accepted tokens. eg:
'result': {
'project_id': project_name,
'api_key': api_key,
'payment_eth_address': eth_address,
'payment_avax_address': avax_address,
'payment_amount_tier1_eth': tier1_expected_amount,
'payment_amount_tier2_eth': tier2_expected_amount,
'payment_amount_tier1_ablock': tier1_expected_amount_ablock,
'payment_amount_tier2_ablock': tier2_expected_amount_ablock,
'payment_amount_tier1_aablock': tier1_expected_amount_aablock,
'payment_amount_tier2_aablock': tier2_expected_amount_aablock,
'expiry_time': payment_expires.strftime("%Y-%m-%d %H:%M:%S EST")
}
exr projects
auto-builder
——
Some suggested changes to the payment system...TBD
——
PAYMENT NOTES:
the time limit for any requested project to be paid for should be 24hrs (inactive projects that are not paid for in 24hrs will then be cancelled and cleared from the UI)
we should change this imho; not paid in 24hrs > cancel project > inform user to request new project
change to 24hrs
the api call count is relative to the amount paid and activate archival (i.e. access to all ETH blocks) if greater than tier2check for HOST_TYPE
env var to check if a http or a ws is required.
aaBlock payment should be permitted only if AVAX host is in env vars
Create a migration script that converts older versions of db models to new ones
File "/app/manager/main.py", line 12, in <module>
from util.eth_payments import Web3Helper
File "/app/manager/util/__init__.py", line 11, in <module>
discount_ablock = float((100 - os.environ.get('DISCOUNT_ABLOCK', 20))/100)
TypeError: unsupported operand type(s) for -: 'int' and 'str'```
To do:
request_project
to enable selecting the project type:
xquery
hydra
request_hydra_project
method to accept one of the following optional parameters:
archival
non-archival
non-archival
cost_per_1000_queries
eg $0.001/1000 query - TBDScenario:
Trying to request a new XQuery project via curl, and using the method request_project
is resulting in a delay of over a minute before any response.
Steps to reproduce
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"request_project","params": [],"id":1}'
To do:
Inspired by the successful activation of a project through aBLOCK payment, I went on to request a new project and activate it via ETH payment. The project_request
call yielded this (after rates were intentionally lowered on the server):
{
"result": {
"api_key": "yjUZiB-XFzARsgc2t11XuMkEtIJsHh1oAPA0LsbbhA0",
"expiry_time": "2022-02-15 06:10:01 EST",
"payment_amount_tier1_aablock": 1.752046,
"payment_amount_tier1_ablock": 0.390625,
"payment_amount_tier1_eth": 0.000332,
"payment_amount_tier2_aablock": 350.409251,
"payment_amount_tier2_ablock": 78.125,
"payment_amount_tier2_eth": 0.06631,
"payment_avax_address": "0xe59C639DA8278599c04503CF511b1adF972c61F3",
"payment_eth_address": "0xAD0ae3AB7E2Eae865dc1DeE3Fa195Ce13da32650",
"project_id": "ed7a4642-41f7-4593-86a8-be592ccc9272"
}
}
Then I sent 0.000332 ETH to the payment_eth_address
: https://etherscan.io/tx/0xb8b1c68b18a1b7aac843cfdcac4978a8bd6003c255a4d03d4033dd83b2790653
Then I checked the status of "project_id": "ed7a4642-41f7-4593-86a8-be592ccc9272", only to find it has not become active.
I'm seeing this in the payment processor logs:
[2022-02-15:02:51:12] CRITICAL - error handling eth back event
Traceback (most recent call last):
File "/app/manager/util/eth_payments.py", line 164, in eth_start_back
self.handle_eth_events(events)
File "<string>", line 2, in handle_eth_events
File "/usr/local/lib/python3.8/site-packages/pony/orm/core.py", line 533, in new_func
result = func(*args, **kwargs)
File "/app/manager/util/eth_payments.py", line 246, in handle_eth_events
self.handle_eth_event(event)
File "/app/manager/util/eth_payments.py", line 385, in handle_eth_event
payment_obj.project.api_token_count += calc_api_calls(value, 'ablock',
File "/usr/local/lib/python3.8/site-packages/pony/orm/core.py", line 2310, in __set__
new_val = attr.validate(new_val, obj, from_db=False)
File "/usr/local/lib/python3.8/site-packages/pony/orm/core.py", line 2544, in validate
val = Attribute.validate(attr, val, obj, entity, from_db)
File "/usr/local/lib/python3.8/site-packages/pony/orm/core.py", line 2215, in validate
val = converter.validate(val, obj)
File "/usr/local/lib/python3.8/site-packages/pony/orm/dbapiprovider.py", line 546, in validate
throw(ValueError, 'Value %r of attr %s is greater than the maximum allowed value %r'
File "/usr/local/lib/python3.8/site-packages/pony/utils/utils.py", line 106, in throw
raise exc
ValueError: Value 2168400007 of attr Project.api_token_count is greater than the maximum allowed value 2147483647
wait for nodes to sync and after that connect to them to fetch prices and check payments.
Memory usage by the exrproxy-env-payment-1 container grows over time. I've seen it grow up to 3.5 GB on one of my SNodes, which is much more than this simple container should require. Maybe it's just the memory occupied by the growing log file, or maybe it's a memory leak. It should be investigated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.