Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploying TRC20 on a private node #6204

Open
dkatzan opened this issue Feb 19, 2025 · 10 comments
Open

Deploying TRC20 on a private node #6204

dkatzan opened this issue Feb 19, 2025 · 10 comments

Comments

@dkatzan
Copy link

dkatzan commented Feb 19, 2025

Hi, I'm trying to setup a local private chain for development and failing to deploy a TRC20 contract

initially, I saw logs in the form of:
22:28:29.424 INFO [qtp2038670805-30] [VM](Program.java:1134) minTimeRatio: 0.0, maxTimeRatio: 5.0, vm should end time in us: 107604299922, vm now time in us: 107604341724, vm start time in us: 107604249922

Which I suspect are a result of my running on an m1 mac, so everything is running slower with qemu-x86_64, I tried increasing maxTimeRatio, but it didn't seem to effect the vm timeout, so I ended up running in --debug mode to avoid this check

I now see errors of the form:

22:52:35.059 INFO  [qtp602052569-36] [VM](VM.java:92) VM halted: [Invalid operation code: opCode[d3];]
22:52:35.066 INFO  [qtp602052569-36] [VM](VMActuator.java:290) runtime result is :Invalid operation code: opCode[d3];

and found these relevant threads:
https://github.com/tronprotocol/java-tron/issues/5576#5576

and tried to follow, but still with no luck
this is my config :

committee = {
  allowCreationOfContracts = 1  //mainnet:0 (reset by committee),test:1
  allowMultiSign = 1
  allowSameTokenName = 1
  allowTvmTransferTrc10 = 1
  allowTvmConstantinople = 1
  allowTvmSolidity059 = 1
  allowMarketTransaction = 1
  allowDelegatedResource = 1
  changedDelegation = 1
  allowTvmShangHai = 1
)

and I tried having allowTvmTransferTrc10 both on and off but with no luck

my contract code was compiled from here and is :

"60806040523480156200001157600080fd5b50d380156200001f57600080fd5b50d280156200002d57600080fd5b506040518060400160405280600d81526020017f596f7572546f6b656e4e616d65000000000000000000000000000000000000008152506040518060400160405280600381526020017f59544e000000000000000000000000000000000000000000000000000000000081525060128260039080519060200190620000b49291906200038a565b508160049080519060200190620000cd9291906200038a565b5080600560006101000a81548160ff021916908360ff1602179055505050506200011a33620001016200012060201b60201c565b60ff16600a0a6402540be400026200013760201b60201c565b62000439565b6000600560009054906101000a900460ff16905090565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415620001db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f54524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b620001f7816002546200030160201b62000e771790919060201c565b60028190555062000255816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546200030160201b62000e771790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60008082840190508381101562000380576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620003cd57805160ff1916838001178555620003fe565b82800160010185558215620003fe579182015b82811115620003fd578251825591602001919060010190620003e0565b5b5090506200040d919062000411565b5090565b6200043691905b808211156200043257600081600090555060010162000418565b5090565b90565b610fc180620004496000396000f3fe608060405234801561001057600080fd5b50d3801561001d57600080fd5b50d2801561002a57600080fd5b50600436106100c35760003560e01c8063395093511161008b578063395093511461027957806370a08231146102df57806395d89b4114610337578063a457c2d7146103ba578063a9059cbb14610420578063dd62ed3e14610486576100c3565b806306fdde03146100c8578063095ea7b31461014b57806318160ddd146101b157806323b872dd146101cf578063313ce56714610255575b600080fd5b6100d06104fe565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101105780820151818401526020810190506100f5565b50505050905090810190601f16801561013d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101976004803603604081101561016157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105a0565b604051808215151515815260200191505060405180910390f35b6101b96105b7565b6040518082815260200191505060405180910390f35b61023b600480360360608110156101e557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105c1565b604051808215151515815260200191505060405180910390f35b61025d610672565b604051808260ff1660ff16815260200191505060405180910390f35b6102c56004803603604081101561028f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610689565b604051808215151515815260200191505060405180910390f35b610321600480360360208110156102f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b6040518082815260200191505060405180910390f35b61033f610776565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561037f578082015181840152602081019050610364565b50505050905090810190601f1680156103ac5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610406600480360360408110156103d057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610818565b604051808215151515815260200191505060405180910390f35b61046c6004803603604081101561043657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b6104e86004803603604081101561049c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108d4565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105965780601f1061056b57610100808354040283529160200191610596565b820191906000526020600020905b81548152906001019060200180831161057957829003601f168201915b5050505050905090565b60006105ad33848461095b565b6001905092915050565b6000600254905090565b60006105ce848484610b52565b610667843361066285600160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610dee90919063ffffffff16565b61095b565b600190509392505050565b6000600560009054906101000a900460ff16905090565b6000610724338461071f85600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e7790919063ffffffff16565b61095b565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561080e5780601f106107e35761010080835404028352916020019161080e565b820191906000526020600020905b8154815290600101906020018083116107f157829003601f168201915b5050505050905090565b60006108b333846108ae85600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610dee90919063ffffffff16565b61095b565b6001905092915050565b60006108ca338484610b52565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109e1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180610f6a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610f236022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bd8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180610f456025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610c5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610f006023913960400191505060405180910390fd5b610caf816000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610dee90919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d42816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e7790919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600082821115610e66576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b600082840390508091505092915050565b600080828401905083811015610ef5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe54524332303a207472616e7366657220746f20746865207a65726f206164647265737354524332303a20617070726f766520746f20746865207a65726f206164647265737354524332303a207472616e736665722066726f6d20746865207a65726f206164647265737354524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26474726f6e5820c45cfbe4a2707afa5f67d1200c0e0f068e72194e78866ed8706185185349794464736f6c63430005120031"

Any help would be appreciated

@angrynurd
Copy link

@dkatzan
Let me understand your issue: You are running a private java-tron chain on an M1 Mac using QEMU to simulate an x86_64 environment and have deployed a TRC20 contract on it. However, the contract deployment fails, and a timeout error in instruction execution occurs.

Here's my understanding:
Running in a QEMU-simulated x86_64 environment causes 2 problems:
1). performance degradation (since QEMU performs dynamic binary translation to simulate the x86_64 architecture, its execution efficiency is far lower than that of a native x86_64 system, leading to overall slower running speed)
2). reduced precision (the TVM relies on accurate timing to determine whether a contract is executing normally. For example, the VM controls execution time using preset parameters like maxTimeRatio. The additional delay introduced by QEMU may cause a discrepancy between the "expected time" and "actual time" on the timer, which in turn leads the VM to mistakenly think that the contract execution has timed out or that an operation is invalid).

Therefore, when running in a QEMU environment, the drastic slowdown in processing speed means that simply increasing the maxTimeRatio parameter cannot fully compensate for the mismatch caused by the underlying execution delay.

Suggestion: If conditions permit, it is recommended to deploy the same TRC20 contract on a native x86_64 device to see if the same issue still occurs. This can help rule out problems related to the simulated environment.

@Sunny6889
Copy link

@dkatzan one way to verify it is your local machine's performance problem, you could try to deploy your TRC-20 contract on Transcan Nile Testnet first.

@angrynurd
Copy link

By the way,I looked at your contract code. The contract mainly inherits from the standard TRC20 and TRC20Detailed implementations. The code itself is very standard and is not much different from common TRC20 contracts. It also uses Solidity version 0.5.0 and does not introduce any particularly new opcodes or instructions. However, the suggestion of @Sunny6889 is good, and you can give it a try to confirm that the problem is not related to the contract compilation.

@dkatzan
Copy link
Author

dkatzan commented Feb 20, 2025

@angrynurd @Sunny6889 Thx for u quick response, I can confirm I was able to succesfully deploy my contract into nile testnet

So the issues seems unrelated to contract completion

I also think the issue is not related to running in my arm machine with QEMU since I added the --debug flag, causing the node to now timeout on CPU performance, so I believe it has something to do with my configuration?

@Sunny6889
Copy link

@dkatzan Does your hardware configuration meet the minimum hardware requirements? Additionally, what are your JVM flags? You can find this information by running the command jcmd <pid> VM.flags.

@dkatzan
Copy link
Author

dkatzan commented Feb 20, 2025

Hi @Sunny6889
I'm running the official docker image on my m1 mac with 32GB memory
so I pull the image, start it locally with my a different entrypoint to just start it in a shell,
I use this config file with the changes in committee I mentioned above

I then start the node with the command:
/java-tron/bin/FullNode --witness -c supernode.conf
which is similar to the entry point of the image

running jcmd returned

-XX:CICompilerCount=3 -XX:+CMSParallelRemarkEnabled -XX:+CMSScavengeBeforeRemark -XX:InitialHeapSize=329252864 -XX:MaxHeapSize=5240782848 -XX:MaxNewSize=348913664 -XX:MaxTenuringThreshold=6 -XX:MinHeapDeltaBytes=196608 -XX:NewSize=109707264 -XX:OldPLABSize=16 -XX:OldSize=219545600 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:ReservedCodeCacheSize=268435456 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseConcMarkSweepGC -XX:+UseParNewGC

not sure how I can start the Java process with different JVM flags while running it with the /java-tron/bin/FullNode executable?

@dkatzan
Copy link
Author

dkatzan commented Feb 20, 2025

Hi, I think I got it to work
not sure what exactly made the difference, but I now start my node using
/java-tron/bin/FullNode --witness -c supernode.conf --debug -jvm "{-Xmx6g -XX:+HeapDumpOnOutOfMemoryError}"
and I managed to deploy my contract

thx for the support!

@Sunny6889
Copy link

@dkatzan Good for it. Suggested jvm params for java-tron is -Xmx14g -Xmn2g, used to set max heapsize to 14GB and GC space large up to 2G.

@dkatzan
Copy link
Author

dkatzan commented Feb 24, 2025

@Sunny6889 are those the suggested params even for running a private node?
in this guide https://developers.tron.network/docs/tron-private-chain for running a private chain, the suggested command is $ java -Xmx6g -XX:+HeapDumpOnOutOfMemoryError -jar FullNode.jar --witness -c supernode.conf

@Sunny6889
Copy link

@dkatzan oh, there's no need for a private node if the transaction volume is very limited. My previous suggestion was for a mainnet node, as the syncing transaction volume is significantly larger in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants