tronprotocol / java-tron

Java implementation of the Tron whitepaper
GNU Lesser General Public License v3.0
3.72k stars 1.4k forks source link

{ error: 'TAPOS_ERROR', message: 'Tapos check error.' } In TRON PRIVATE CHAIN #5786

Closed charil10 closed 6 months ago

charil10 commented 6 months ago

When I do Wallet to Wallet transaction it is working fine. but When I do Wallet to smart Contract transaction its giving me TAPOS ERROR. I have checked all my nodes they are working fine and returning same blocknumber as well as my fullnode is proper synced as well. Whats happening here . I have set in all config : trx.referance.block="solid" also when I start checked the logs as well its solid. How can I solve this issue.? How can I fix it.

charil10 commented 6 months ago

this si the config file that Im using in SR nodes, if you find anything wrong do let me know:

net {
    type = mainnet
  #  type = testnet
}

storage {
  # Directory for storing persistent data

  db.version = 2,
  db.engine = "ROCKSDB",
  db.directory = "database",
  index.directory = "index",
 txCache={
  initOptimization = true
}
  # You can custom these 14 databases' configs:

  # account, account-index, asset-issue, block, block-index,
  # block_KDB, peers, properties, recent-block, trans,
  # utxo, votes, witness, witness_schedule.

  # Otherwise, db configs will remain defualt and data will be stored in
  # the path of "output-directory" or which is set by "-d" ("--output-directory").

  # Attention: name is a required field that must be set !!!
  properties = [
    //    {
    //      name = "account",
    //      path = "storage_directory_test",
    //      createIfMissing = true,
    //      paranoidChecks = true,
    //      verifyChecksums = true,
    //      compressionType = 1,        // compressed with snappy
    //      blockSize = 4096,           // 4  KB =         4 * 1024 B
    //      writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B
    //      cacheSize = 10485760,       // 10 MB = 10 * 1024 * 1024 B
    //      maxOpenFiles = 100
    //    },
    //    {
    //      name = "account-index",
    //      path = "storage_directory_test",
    //      createIfMissing = true,
    //      paranoidChecks = true,
    //      verifyChecksums = true,
    //      compressionType = 1,        // compressed with snappy
    //      blockSize = 4096,           // 4  KB =         4 * 1024 B
    //      writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B
    //      cacheSize = 10485760,       // 10 MB = 10 * 1024 * 1024 B
    //      maxOpenFiles = 100
    //    },
  ]

dbSettings={
levelNumber=7
blocksize=64
maxBytesForLevelBase=256
maxBytesforLevelMultiplier=10
level0FileNumCompactionTrigger=4
targetFileSizeBase=256
targetFileSizeMultiplier=1
}

needToUpdateAsset=true
backup={
enable=true
propPath="prop.properties"
bak1path="bak1/database"
bak2path="bak2/databse"
frequency=5000
}
}

# this part of config is used to node discovery.
node.discovery = {
  enable = true  # you should set this entry value with true if you want your node can be discovered by other node.
  persist = true  # this entry is used to determined to whether storing the peers in the database or not.
  bind.ip = "0.0.0.0"
  external.ip =172.233.93.191
}

# this part of config is used to set backup node for witness service.
node.backup {
  port = 10001
  priority = 8
  members = [
  ]

  dbSettings={
levelNumber=7
blocksize=64
maxBytesForLevelBase=256
maxBytesforLevelMultiplier=10
level0FileNumCompactionTrigger=4
targetFileSizeBase=256
targetFileSizeMultiplier=1
}

needToUpdateAsset=true
backup={
enable=true
propPath="prop.properties"
bak1path="bak1/database"
bak2path="bak2/database"
frequency=1000
}

}

#Enabling JSON-RPC service of a node

node.jsonrpc {
httpFullNodeEnable = true
httpFullNodePort = 50545
httpSolidityEnable = true
httpSolidityPort = 50555
}

node {
  # trust node for solidity node
  # trustNode = "ip:port"
  trustNode = "127.0.0.1:50051"

  # expose extension api to public or not
  walletExtensionApi = true

  listen.port = 16666

  connection.timeout = 2

  tcpNettyWorkThreadNum = 0

  udpNettyWorkThreadNum = 1

  # Number of validate sign thread, default availableProcessors / 2
  # validateSignThreadNum = 16

  maxActiveNodes = 200

  maxActiveNodesWithSameIp = 2

  minParticipationRate = 0

  # check the peer data transfer ,disconnect factor
  disconnectNumberFactor = 0.4
  maxConnectNumberFactor = 0.8
  receiveTcpMinDataLength = 2048
  isOpenFullTcpDisconnect = true

  p2p {
    version = 1 # 11111: mainnet; 20180622: testnet; you can set other number when you deploy one private net, but the node must have the same number in some private net. 
  }
 ####### add for prometheus start.
 metrics{
  prometheus{
  enable=true 
  port="9527"
  }
 }
 ####### add for prometheus end.

  active = [
    # Active establish connection in any case
    # Sample entries:
    # "ip:port",
    "34.201.212.73:16666",
"172.232.124.222:16666",
"172.105.47.84:16666",
"148.113.8.203:16666"]

  passive = [
    # Passive accept connection in any case
    # Sample entries:
    # "ip:port",
    # "ip:port"
"34.201.212.73:16666",
"172.232.124.222:16666",
"172.105.47.84:16666",
"148.113.8.203:16666"
  ]

  http {
    fullNodePort = 16667
    solidityPort = 16668
  }

  rpc {
    port = 16669

    # Number of gRPC thread, default availableProcessors / 2
    # thread = 16

    # The maximum number of concurrent calls permitted for each incoming connection
    # maxConcurrentCallsPerConnection =

    # The HTTP/2 flow control window, default 1MB
    # flowControlWindow =

    # Connection being idle for longer than which will be gracefully terminated
    maxConnectionIdleInMillis = 60000

    # Connection lasting longer than which will be gracefully terminated
    # maxConnectionAgeInMillis =

    # The maximum message size allowed to be received on the server, default 4MB
    # maxMessageSize =

    # The maximum size of header list allowed to be received, default 8192
    # maxHeaderListSize =

    # Transactions can only be broadcast if the number of effective connections is reached.
    minEffectiveConnection = 0
  }

  # Whether to enable the node detection function, default false
  # nodeDetectEnable = false

  # use your ipv6 address for node discovery and tcp connection, default false
  # enableIpv6 = false

  # if your node's highest block num is below than all your pees', try to acquire new connection. default false
  # effectiveCheckEnable = false

  # Dynamic loading configuration function, disabled by default
  # dynamicConfig = {
    # enable = false
    # Configuration file change check interval, default is 600 seconds
    # checkInterval = 600
  # }

  dns {
    # dns urls to get nodes, url format tree://{pubkey}@{domain}, default empty
    treeUrls = [
      #"tree://APFGGTFOBVE2ZNAB3CSMNNX6RRK3ODIRLP2AA5U4YFAA6MSYZUYTQ@nodes1.example.org",
    ]
  }
}

seed.node = {
  # List of the seed nodes. This is used to enable the node can connect when join one net at first.
  # If you deploy one private net, you must add some "ip:port" here for other node connecting.
  # Seed nodes are stable full nodes, and the first SuperNode must be inclued in.
  # example:
  # ip.list = [
  #   "ip:port",
  #   "ip:port"
  # ]
  ip.list = [ "34.201.212.73:16666","148.113.8.203:16666"]
}

genesis.block = {
  # Reserve balance
  assets = [
    {
      accountName = "Pixel Elite"
      accountType = "AssetIssue"
      address = "TNC7iW9d2PbAmGNs37FFtgf7HFvmEWtZo2"
      balance = "40000000000000"
    },
  {
      accountName = "Blackhole"
      accountType = "AssetIssue"
      address = "TUKZpDNnzAufcJQjmq9Eo2gQs8wTSKDfQY"
      balance = "-9223372036854775808"
    }
  ]

  witnesses = [
    {
      address:TPg35oEyGJmQx6pUACBhCe3yxCMYFnhR1M,
      url = "http://Blockdot.com",
      voteCount = 10000
    }
  ]

  timestamp = "0" #2017-8-26 12:00:00

  parentHash = "957dc2d350daecc7bb6a38f3938ebde0a0c1cedafe15f0edae4256a2907449f6"
}

localwitness = []
#localwitnesskeystore = [
#  "src/main/resources/localwitnesskeystore.json"  # if you do not set the localwitness above, you must set this value.Otherwise,your SuperNode can not produce the block. 
#]

block = {
  needSyncCheck = true # first node : false, other : true
  maintenanceTimeInterval = 21600000 // 1 day: 86400000(ms), 6 hours: 21600000(ms),15 mins : 900000
  proposalExpireTime=86400000
}

trx.referance.block="solid"

vm = {
  supportConstant = true
  minTimeRatio = 0.0
  maxTimeRatio = 5.0
}

committee = {
  allowCreationOfContracts = 1  //mainnet:0 (reset by committee),test:1
}

event.subscribe = {
  native = {
    useNativeQueue = true // if true, use native message queue, else use event plugin.
    bindport = 5555 // bind port
    sendqueuelength = 1000 //max length of send queue
  }

  path = "" // absolute path of plugin
  server = "" // target server address to receive event triggers
  dbconfig = "" // dbname|username|password
  contractParse = true,
  topics = [
    {
      triggerName = "block" // block trigger, the value can't be modified
      enable = true
      topic = "block" // plugin topic, the value could be modified
#        solidified = true    
},
    {
      triggerName = "transaction"
      enable = true
      topic = "transaction"
#        solidified = true
            ethCompatible = true
    },
    {
      triggerName = "contractevent"
      enable = true
      topic = "contractevent"
    },
    {
      triggerName = "contractlog"
      enable = true
      topic = "contractlog"
    },
    {
      triggerName = "solidity" // solidity block event trigger, the value can't be modified
      enable = true            // the default value is true
      topic = "solidity"
    },
{
          triggerName = "solidityevent"
          enable = true
          topic = "solidityevent"
        },
        {
          triggerName = "soliditylog"
          enable = true
          topic = "soliditylog"
          redundancy = true // if set true, solidityevent will also be regarded as soliditylog
        }
  ]

  filter = {
    fromblock = "earliest" // the value could be "", "earliest" or a specified block number as the beginning of the queried range
    toblock = "latest" // the value could be "", "latest" or a specified block number as end of the queried range
    contractAddress = [""]
    contractTopic = [""]
  }
}
enery.limit.block.num = 0
laurenceja commented 6 months ago

How did you create the transaction, calling the node's API directly or using a SDK?

charil10 commented 6 months ago

Im using tronweb to do it. Js sdk

laurenceja commented 6 months ago

For tronweb, if you don't set the reference block information for transaction manually, tronweb will use the latest block for reference automatically, but not the latest solidified block. So we can first get the latest solidified block through getNodeInfo, then set the block information for your transaction.

SukiratWarring commented 6 months ago

@laurenceja you mean that we have to calculate the raw_data.ref_block_bytes and the raw_data.ref_block_hash which are calcaulated respectively

raw_data.ref_block_bytes - The height of the transaction reference block, using the 6th to 8th (exclusive) bytes of the reference block height, a total of 2 bytes. The reference block is used in the TRON TAPOS mechanism, which can prevent a replay of a transaction on forks that do not include the referenced block. Generally, the latest solidified block is used as the reference block.
raw_data.ref_block_hash - The hash of the transaction reference block, using the 8th to 16th (exclusive) bytes of the reference block hash, a total of 8 bytes. The reference block is used in the TRON TAPOS mechanism, which can prevent a replay of a transaction on forks that do not include the referenced block. Generally, the latest solidified block is used as the reference block.

if the solidified block num is 1,000,000 The hexadecimal representation of 1,000,000 is f4240, which is only 5 characters long. This means it doesn't reach the 6th byte; it is less than 6 bytes long when we consider each byte is represented by two hexadecimal characters. or am i doing anything wrong?

charil10 commented 6 months ago

@laurenceja can you please share the code snippet to do it efficiently so we can understand it properly

charil10 commented 6 months ago

@laurenceja please do let me know . I really need to solve this ASAP

charil10 commented 6 months ago

@andelf @h4ck3rm1k3 @laurenceja @

aguinaldok4 commented 6 months ago

kris9773180017.192.168.0.100.8080:+639773180017.mail

MYVivo1820:112.201.70.172.9299/9773180017

laurenceja commented 6 months ago

@charil10 This code of tronweb may be helpful. https://github.com/tronprotocol/tronweb/blob/3a81bf15f790f35f03b5f9d9b7154afb653ef5f3/src/lib/transactionBuilder.js#L80

xxo1shine commented 6 months ago

@charil10 maybe you can refer to Java code:

Transaction.raw rawData = this.transaction.getRawData().toBuilder()
        .setRefBlockHash(ByteString.copyFrom(ByteArray.subArray(blockHash, 8, 16)))
        .setRefBlockBytes(ByteString.copyFrom(ByteArray.subArray(refBlockNum, 6, 8)))
vivian1912 commented 6 months ago

@charil10 Thanks for your contribution to java-tron. May I ask if this issue has been resolved? And do you have any other questions?

vivian1912 commented 6 months ago

@charil10 This issue will be closed as no update for a long time. Please feel free to re-open it if you still see the issue, thanks.