In order to build this service you have to have an installed:
We are using Tron Trident libraries for communicating with TRON node via gRPC. You can install them by executing following command:
sh ./install_tron_trident_jars.sh
In order to build this service with testing you should execute following command:
mvn clean install
This will launch incremental build of modules and also running tests. This includes integration tests which requires a Docker to be up and running (we are using PostgreSQL Docker image for testing).
As a result you will have a JAR file for your service in the transaction-manager/target/
folder.
In order to skip testing phase (it will skip compiling and running tests), you can use following command:
mvn clean install -DskipTests
This will compile a JAR file under transaction-manager/target/
path (should have name something like transaction-manager-0.0.1.jar
).
In order to run the server you have to create Spring properties file (transaction-manager/src/main/resources/application-<profile>.yml
).
Template for the properties file can be found at: transaction-manager/src/main/resources/application-template.yml
You have to define values for placeholders or replace placeholders with relevant properties. These are:
POSTGRES_JDBC_URL
- JDBC URL to PostgreSQL serverPOSTGRES_USER
- username to use for authorization in PostgreSQLPOSTGRES_PASSWORD
- password for authorization in PostgreSQLTRANSATRON_URL
- URL to TransaTron serverTRANSATRON_API_KEY
- API key for authorization on TransaTron serverPAYMENT_DEPOSIT_ADDRESS
- an address for receiving payments from usersTRONGRID_PRIVATE_KEY
- private key to use inApiWrapper
(does not necessary have to be a wallet with resources, we won't use this wallet for making transactions, it is just that we cannot createApiWrapper
instance without it)TRONGRID_API_KEY
- API key for authorization on TronGridTRON_ENERGY_MARKET_WALLET
- Tron Energy Market wallet addressTRON_ENERGY_API_KEY
- API key for authorization on Tron Energy Market
You can run the server with the following command:
java -jar -Dspring.profiles.active=<profile> transaction-manager/target/transaction-manager-0.0.1.jar
Where <profile>
is a profile that you have created and placed under transaction-manager/src/main/resources/
folder
NOTE: authors of this project do not recommend you to store private keys in properties of production systems, this approach is valid only for PoC
In order for service being able to delegate and reclaim resources from user addresses we have to sign those transactions.
In order to sign those transactions we are storing private keys in properties file under, wallets.private-keys
property which expects a mapping of address (Tron58 format) to private key.
At the moment of writing it is recommended to use Correto JDK provided by AWS, version 17 (LTS version of JDK)
It is recommended to explicitly specify amount of memory to use by the application:
-Xms
- initial memory allocation pool (which is also a minimal)-Xmx
- maximum memory allocation pool-XX:+UseG1GC
- use G1 garbage collector
It is also recommended to use following params which may help you with troubleshooting whenever it happens.
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.host=<host-mask>
-Dcom.sun.management.jmxremote.port=<port>
-Dcom.sun.management.jmxremote.rmi.port=<port>
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-XX:+HeapDumpOnOutOfMemoryError
- indicates that JVM should generate a heap dump when allocation of the Java memory cannot be satisfied-XX:HeapDumpPath=/path/to/directory/transaction-manager-<timestamp>.hprof
- a path to the heap dump file-XX:ErrorFile=/path/to/directory/transaction-manager-<timestamp>_error.log
- a path to fatal error log