Remove old docker stuff and upgrade telegram frontend to use ipfs async apis

pull/23/head
Guillermo Rodriguez 2023-09-28 21:23:04 -03:00
parent 1b13cf25cc
commit fe4574c5dc
No known key found for this signature in database
GPG Key ID: EC3AB66D5D83B392
16 changed files with 10 additions and 4632 deletions

View File

@ -1,4 +1,4 @@
from python:3.10.0
from python:3.11
env DEBIAN_FRONTEND=noninteractive

View File

@ -1,22 +0,0 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y wget
# install eosio tools
RUN wget https://github.com/AntelopeIO/leap/releases/download/v4.0.1/leap_4.0.1-ubuntu22.04_amd64.deb
RUN apt-get install -y ./leap_4.0.1-ubuntu22.04_amd64.deb
RUN mkdir -p /root/nodeos
WORKDIR /root/nodeos
COPY config.ini config.ini
COPY contracts contracts
COPY genesis genesis
EXPOSE 42000
EXPOSE 29876
EXPOSE 39999
CMD sleep 9999999999

View File

@ -1,52 +0,0 @@
agent-name = Telos Skynet Testnet
wasm-runtime = eos-vm-jit
eos-vm-oc-compile-threads = 4
eos-vm-oc-enable = true
chain-state-db-size-mb = 65536
enable-account-queries = true
http-server-address = 0.0.0.0:42000
access-control-allow-origin = *
contracts-console = true
http-validate-host = false
p2p-listen-endpoint = 0.0.0.0:29876
p2p-server-address = 0.0.0.0:29876
verbose-http-errors = true
state-history-endpoint = 0.0.0.0:39999
trace-history = true
chain-state-history = true
trace-history-debug-mode = true
state-history-dir = state-history
sync-fetch-span = 1600
max-clients = 250
signature-provider = EOS5fLreY5Zq5owBhmNJTgQaLqQ4ufzXSTpStQakEyfxNFuUEgNs1=KEY:5JnvSc6pewpHHuUHwvbJopsew6AKwiGnexwDRc2Pj2tbdw6iML9
disable-subjective-billing = true
max-transaction-time = 500
read-only-read-window-time-us = 600000
abi-serializer-max-time-ms = 2000000
p2p-max-nodes-per-host = 1
connection-cleanup-period = 30
allowed-connection = any
http-max-response-time-ms = 100000
max-body-size = 10000000
enable-stale-production = true
plugin = eosio::http_plugin
plugin = eosio::chain_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::net_api_plugin
plugin = eosio::net_plugin
plugin = eosio::producer_plugin
plugin = eosio::producer_api_plugin
plugin = eosio::state_history_plugin

View File

@ -1,360 +0,0 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT Thu Apr 14 07:49:43 2022",
"version": "eosio::abi/1.1",
"structs": [
{
"name": "action",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "name",
"type": "name"
},
{
"name": "authorization",
"type": "permission_level[]"
},
{
"name": "data",
"type": "bytes"
}
]
},
{
"name": "approval",
"base": "",
"fields": [
{
"name": "level",
"type": "permission_level"
},
{
"name": "time",
"type": "time_point"
}
]
},
{
"name": "approvals_info",
"base": "",
"fields": [
{
"name": "version",
"type": "uint8"
},
{
"name": "proposal_name",
"type": "name"
},
{
"name": "requested_approvals",
"type": "approval[]"
},
{
"name": "provided_approvals",
"type": "approval[]"
}
]
},
{
"name": "approve",
"base": "",
"fields": [
{
"name": "proposer",
"type": "name"
},
{
"name": "proposal_name",
"type": "name"
},
{
"name": "level",
"type": "permission_level"
},
{
"name": "proposal_hash",
"type": "checksum256$"
}
]
},
{
"name": "cancel",
"base": "",
"fields": [
{
"name": "proposer",
"type": "name"
},
{
"name": "proposal_name",
"type": "name"
},
{
"name": "canceler",
"type": "name"
}
]
},
{
"name": "exec",
"base": "",
"fields": [
{
"name": "proposer",
"type": "name"
},
{
"name": "proposal_name",
"type": "name"
},
{
"name": "executer",
"type": "name"
}
]
},
{
"name": "extension",
"base": "",
"fields": [
{
"name": "type",
"type": "uint16"
},
{
"name": "data",
"type": "bytes"
}
]
},
{
"name": "invalidate",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
}
]
},
{
"name": "invalidation",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "last_invalidation_time",
"type": "time_point"
}
]
},
{
"name": "old_approvals_info",
"base": "",
"fields": [
{
"name": "proposal_name",
"type": "name"
},
{
"name": "requested_approvals",
"type": "permission_level[]"
},
{
"name": "provided_approvals",
"type": "permission_level[]"
}
]
},
{
"name": "permission_level",
"base": "",
"fields": [
{
"name": "actor",
"type": "name"
},
{
"name": "permission",
"type": "name"
}
]
},
{
"name": "proposal",
"base": "",
"fields": [
{
"name": "proposal_name",
"type": "name"
},
{
"name": "packed_transaction",
"type": "bytes"
}
]
},
{
"name": "propose",
"base": "",
"fields": [
{
"name": "proposer",
"type": "name"
},
{
"name": "proposal_name",
"type": "name"
},
{
"name": "requested",
"type": "permission_level[]"
},
{
"name": "trx",
"type": "transaction"
}
]
},
{
"name": "transaction",
"base": "transaction_header",
"fields": [
{
"name": "context_free_actions",
"type": "action[]"
},
{
"name": "actions",
"type": "action[]"
},
{
"name": "transaction_extensions",
"type": "extension[]"
}
]
},
{
"name": "transaction_header",
"base": "",
"fields": [
{
"name": "expiration",
"type": "time_point_sec"
},
{
"name": "ref_block_num",
"type": "uint16"
},
{
"name": "ref_block_prefix",
"type": "uint32"
},
{
"name": "max_net_usage_words",
"type": "varuint32"
},
{
"name": "max_cpu_usage_ms",
"type": "uint8"
},
{
"name": "delay_sec",
"type": "varuint32"
}
]
},
{
"name": "unapprove",
"base": "",
"fields": [
{
"name": "proposer",
"type": "name"
},
{
"name": "proposal_name",
"type": "name"
},
{
"name": "level",
"type": "permission_level"
}
]
}
],
"types": [],
"actions": [
{
"name": "approve",
"type": "approve",
"ricardian_contract": ""
},
{
"name": "cancel",
"type": "cancel",
"ricardian_contract": ""
},
{
"name": "exec",
"type": "exec",
"ricardian_contract": ""
},
{
"name": "invalidate",
"type": "invalidate",
"ricardian_contract": ""
},
{
"name": "propose",
"type": "propose",
"ricardian_contract": ""
},
{
"name": "unapprove",
"type": "unapprove",
"ricardian_contract": ""
}
],
"tables": [
{
"name": "approvals",
"type": "old_approvals_info",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "approvals2",
"type": "approvals_info",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "invals",
"type": "invalidation",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "proposal",
"type": "proposal",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],
"variants": [],
"abi_extensions": []
}

File diff suppressed because one or more lines are too long

View File

@ -1,185 +0,0 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.1",
"types": [],
"structs": [
{
"name": "account",
"base": "",
"fields": [
{
"name": "balance",
"type": "asset"
}
]
},
{
"name": "close",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "symbol",
"type": "symbol"
}
]
},
{
"name": "create",
"base": "",
"fields": [
{
"name": "issuer",
"type": "name"
},
{
"name": "maximum_supply",
"type": "asset"
}
]
},
{
"name": "currency_stats",
"base": "",
"fields": [
{
"name": "supply",
"type": "asset"
},
{
"name": "max_supply",
"type": "asset"
},
{
"name": "issuer",
"type": "name"
}
]
},
{
"name": "issue",
"base": "",
"fields": [
{
"name": "to",
"type": "name"
},
{
"name": "quantity",
"type": "asset"
},
{
"name": "memo",
"type": "string"
}
]
},
{
"name": "open",
"base": "",
"fields": [
{
"name": "owner",
"type": "name"
},
{
"name": "symbol",
"type": "symbol"
},
{
"name": "ram_payer",
"type": "name"
}
]
},
{
"name": "retire",
"base": "",
"fields": [
{
"name": "quantity",
"type": "asset"
},
{
"name": "memo",
"type": "string"
}
]
},
{
"name": "transfer",
"base": "",
"fields": [
{
"name": "from",
"type": "name"
},
{
"name": "to",
"type": "name"
},
{
"name": "quantity",
"type": "asset"
},
{
"name": "memo",
"type": "string"
}
]
}
],
"actions": [
{
"name": "close",
"type": "close",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Close Token Balance\nsummary: 'Close {{nowrap owner}}s zero quantity balance'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/token.png#207ff68b0406eaa56618b08bda81d6a0954543f36adc328ab3065f31a5c5d654\n---\n\n{{owner}} agrees to close their zero quantity balance for the {{symbol_to_symbol_code symbol}} token.\n\nRAM will be refunded to the RAM payer of the {{symbol_to_symbol_code symbol}} token balance for {{owner}}."
},
{
"name": "create",
"type": "create",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Create New Token\nsummary: 'Create a new token'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/token.png#207ff68b0406eaa56618b08bda81d6a0954543f36adc328ab3065f31a5c5d654\n---\n\n{{$action.account}} agrees to create a new token with symbol {{asset_to_symbol_code maximum_supply}} to be managed by {{issuer}}.\n\nThis action will not result any any tokens being issued into circulation.\n\n{{issuer}} will be allowed to issue tokens into circulation, up to a maximum supply of {{maximum_supply}}.\n\nRAM will deducted from {{$action.account}}s resources to create the necessary records."
},
{
"name": "issue",
"type": "issue",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Issue Tokens into Circulation\nsummary: 'Issue {{nowrap quantity}} into circulation and transfer into {{nowrap to}}s account'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/token.png#207ff68b0406eaa56618b08bda81d6a0954543f36adc328ab3065f31a5c5d654\n---\n\nThe token manager agrees to issue {{quantity}} into circulation, and transfer it into {{to}}s account.\n\n{{#if memo}}There is a memo attached to the transfer stating:\n{{memo}}\n{{/if}}\n\nIf {{to}} does not have a balance for {{asset_to_symbol_code quantity}}, or the token manager does not have a balance for {{asset_to_symbol_code quantity}}, the token manager will be designated as the RAM payer of the {{asset_to_symbol_code quantity}} token balance for {{to}}. As a result, RAM will be deducted from the token managers resources to create the necessary records.\n\nThis action does not allow the total quantity to exceed the max allowed supply of the token."
},
{
"name": "open",
"type": "open",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Open Token Balance\nsummary: 'Open a zero quantity balance for {{nowrap owner}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/token.png#207ff68b0406eaa56618b08bda81d6a0954543f36adc328ab3065f31a5c5d654\n---\n\n{{ram_payer}} agrees to establish a zero quantity balance for {{owner}} for the {{symbol_to_symbol_code symbol}} token.\n\nIf {{owner}} does not have a balance for {{symbol_to_symbol_code symbol}}, {{ram_payer}} will be designated as the RAM payer of the {{symbol_to_symbol_code symbol}} token balance for {{owner}}. As a result, RAM will be deducted from {{ram_payer}}s resources to create the necessary records."
},
{
"name": "retire",
"type": "retire",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Remove Tokens from Circulation\nsummary: 'Remove {{nowrap quantity}} from circulation'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/token.png#207ff68b0406eaa56618b08bda81d6a0954543f36adc328ab3065f31a5c5d654\n---\n\nThe token manager agrees to remove {{quantity}} from circulation, taken from their own account.\n\n{{#if memo}} There is a memo attached to the action stating:\n{{memo}}\n{{/if}}"
},
{
"name": "transfer",
"type": "transfer",
"ricardian_contract": "---\nspec_version: \"0.2.0\"\ntitle: Transfer Tokens\nsummary: 'Send {{nowrap quantity}} from {{nowrap from}} to {{nowrap to}}'\nicon: http://127.0.0.1/ricardian_assets/eosio.contracts/icons/transfer.png#5dfad0df72772ee1ccc155e670c1d124f5c5122f1d5027565df38b418042d1dd\n---\n\n{{from}} agrees to send {{quantity}} to {{to}}.\n\n{{#if memo}}There is a memo attached to the transfer stating:\n{{memo}}\n{{/if}}\n\nIf {{from}} is not already the RAM payer of their {{asset_to_symbol_code quantity}} token balance, {{from}} will be designated as such. As a result, RAM will be deducted from {{from}}s resources to refund the original RAM payer.\n\nIf {{to}} does not have a balance for {{asset_to_symbol_code quantity}}, {{from}} will be designated as the RAM payer of the {{asset_to_symbol_code quantity}} token balance for {{to}}. As a result, RAM will be deducted from {{from}}s resources to create the necessary records."
}
],
"tables": [
{
"name": "accounts",
"type": "account",
"index_type": "i64",
"key_names": [],
"key_types": []
},
{
"name": "stat",
"type": "currency_stats",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],
"variants": []
}

View File

@ -1,130 +0,0 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT Thu Apr 14 07:49:40 2022",
"version": "eosio::abi/1.1",
"structs": [
{
"name": "action",
"base": "",
"fields": [
{
"name": "account",
"type": "name"
},
{
"name": "name",
"type": "name"
},
{
"name": "authorization",
"type": "permission_level[]"
},
{
"name": "data",
"type": "bytes"
}
]
},
{
"name": "exec",
"base": "",
"fields": [
{
"name": "executer",
"type": "name"
},
{
"name": "trx",
"type": "transaction"
}
]
},
{
"name": "extension",
"base": "",
"fields": [
{
"name": "type",
"type": "uint16"
},
{
"name": "data",
"type": "bytes"
}
]
},
{
"name": "permission_level",
"base": "",
"fields": [
{
"name": "actor",
"type": "name"
},
{
"name": "permission",
"type": "name"
}
]
},
{
"name": "transaction",
"base": "transaction_header",
"fields": [
{
"name": "context_free_actions",
"type": "action[]"
},
{
"name": "actions",
"type": "action[]"
},
{
"name": "transaction_extensions",
"type": "extension[]"
}
]
},
{
"name": "transaction_header",
"base": "",
"fields": [
{
"name": "expiration",
"type": "time_point_sec"
},
{
"name": "ref_block_num",
"type": "uint16"
},
{
"name": "ref_block_prefix",
"type": "uint32"
},
{
"name": "max_net_usage_words",
"type": "varuint32"
},
{
"name": "max_cpu_usage_ms",
"type": "uint8"
},
{
"name": "delay_sec",
"type": "varuint32"
}
]
}
],
"types": [],
"actions": [
{
"name": "exec",
"type": "exec",
"ricardian_contract": ""
}
],
"tables": [],
"ricardian_clauses": [],
"variants": [],
"abi_extensions": []
}

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
{
"initial_timestamp": "2023-05-22T00:00:00.000",
"initial_key": "EOS5fLreY5Zq5owBhmNJTgQaLqQ4ufzXSTpStQakEyfxNFuUEgNs1",
"initial_configuration": {
"max_block_net_usage": 1048576,
"target_block_net_usage_pct": 1000,
"max_transaction_net_usage": 1048575,
"base_per_transaction_net_usage": 12,
"net_usage_leeway": 500,
"context_free_discount_net_usage_num": 20,
"context_free_discount_net_usage_den": 100,
"max_block_cpu_usage": 200000,
"target_block_cpu_usage_pct": 1000,
"max_transaction_cpu_usage": 150000,
"min_transaction_cpu_usage": 100,
"max_transaction_lifetime": 3600,
"deferred_trx_expiration_window": 600,
"max_transaction_delay": 3888000,
"max_inline_action_size": 4096,
"max_inline_action_depth": 4,
"max_authority_depth": 6
}
}

View File

@ -21,8 +21,7 @@ from telebot.types import InputMediaPhoto
from telebot.async_telebot import AsyncTeleBot
from skynet.db import open_new_database, open_database_connection
from skynet.ipfs import get_ipfs_file
from skynet.ipfs.docker import open_ipfs_node
from skynet.ipfs import get_ipfs_file, AsyncIPFSHTTP
from skynet.constants import *
from . import *
@ -43,7 +42,8 @@ class SkynetTelegramFrontend:
db_host: str,
db_user: str,
db_pass: str,
remote_ipfs_node: str,
ipfs_node: str,
remote_ipfs_node: str | None,
key: str
):
self.token = token
@ -60,17 +60,13 @@ class SkynetTelegramFrontend:
self.bot = AsyncTeleBot(token, exception_handler=SKYExceptionHandler)
self.cleos = CLEOS(None, None, url=node_url, remote=node_url)
self.hyperion = HyperionAPI(hyperion_url)
self.ipfs_node = AsyncIPFSHTTP(ipfs_node)
self._exit_stack = ExitStack()
self._async_exit_stack = AsyncExitStack()
async def start(self):
self.ipfs_node = self._exit_stack.enter_context(
open_ipfs_node())
# self.ipfs_node.connect(self.remote_ipfs_node)
logging.info(
f'connected to remote ipfs node: {self.remote_ipfs_node}')
if self.remote_ipfs_node:
await self.ipfs_node.connect(self.remote_ipfs_node)
self.db_call = await self._async_exit_stack.enter_async_context(
open_database_connection(
@ -80,7 +76,6 @@ class SkynetTelegramFrontend:
async def stop(self):
await self._async_exit_stack.aclose()
self._exit_stack.close()
@acm
async def open(self):

View File

@ -219,8 +219,9 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'):
image.save(f'ipfs-docker-staging/image.png', format='PNG')
ipfs_hash = ipfs_node.add('image.png')
ipfs_node.pin(ipfs_hash)
ipfs_info = await ipfs_node.add('image.png')
ipfs_hash = ipfs_info['Hash']
await ipfs_node.pin(ipfs_hash)
logging.info(f'published input image {ipfs_hash} on ipfs')