tronprotocol / java-tron

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

Build failed on linux. #1562

Closed hustxiaoc closed 5 years ago

hustxiaoc commented 5 years ago

org.tron.core.db.api.IndexHelperTest > classMethod FAILED java.lang.IllegalStateException: Failed to open SQLite connection for file: /home/xxx/tron/java-tron/output_IndexHelper_test/index/TransactionIndex.index at com.googlecode.cqengine.persistence.disk.DiskPersistence.getConnection(DiskPersistence.java:97) at com.googlecode.cqengine.index.sqlite.RequestScopeConnectionManager.getConnection(RequestScopeConnectionManager.java:61) at com.googlecode.cqengine.index.sqlite.SQLiteIndex.doAddAll(SQLiteIndex.java:435) at com.googlecode.cqengine.index.sqlite.SQLiteIndex.addAll(SQLiteIndex.java:425) at com.googlecode.cqengine.index.sqlite.SQLiteIdentityIndex.addAll(SQLiteIdentityIndex.java:113) at com.googlecode.cqengine.persistence.support.sqlite.SQLiteObjectStore.add(SQLiteObjectStore.java:106) at com.googlecode.cqengine.ConcurrentIndexedCollection.add(ConcurrentIndexedCollection.java:350) at org.tron.core.db.api.index.AbstractIndex.add(AbstractIndex.java:89) at org.tron.core.db.api.index.AbstractIndex.update(AbstractIndex.java:99) at org.tron.core.db.api.IndexHelper.update(IndexHelper.java:72) at org.tron.core.db.api.IndexHelper.update(IndexHelper.java:76) at org.tron.core.db.TransactionStore.put(TransactionStore.java:28) at org.tron.core.db.api.IndexHelperTest.init(IndexHelperTest.java:85)

    Caused by:
    org.sqlite.SQLiteException: [SQLITE_CANTOPEN]  Unable to open the database file (unable to open database file)
        at org.sqlite.core.DB.newSQLException(DB.java:909)
        at org.sqlite.core.DB.newSQLException(DB.java:921)
        at org.sqlite.core.DB.throwex(DB.java:886)
        at org.sqlite.core.NativeDB.prepare_utf8(Native Method)
        at org.sqlite.core.NativeDB.prepare(NativeDB.java:127)
        at org.sqlite.core.DB.prepare(DB.java:227)
        at org.sqlite.jdbc3.JDBC3Statement.execute(JDBC3Statement.java:60)
        at org.sqlite.SQLiteConfig.apply(SQLiteConfig.java:133)
        at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:85)
        at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:26)
        at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:24)
        at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:45)
        at org.sqlite.JDBC.createConnection(JDBC.java:114)
        at org.sqlite.SQLiteDataSource.getConnection(SQLiteDataSource.java:410)
        at org.sqlite.SQLiteDataSource.getConnection(SQLiteDataSource.java:398)
        at com.googlecode.cqengine.persistence.disk.DiskPersistence.getConnection(DiskPersistence.java:94)
        ... 12 more

org.tron.core.db.api.IndexHelperTest > classMethod FAILED java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:203) at org.tron.common.utils.FileUtil.recursiveDelete(FileUtil.java:75) at org.tron.core.config.args.Storage.deleteAllStoragePaths(Storage.java:183) at org.tron.core.config.args.Args.clearParam(Args.java:348) at org.tron.core.db.api.IndexHelperTest.removeDb(IndexHelperTest.java:98)

org.tron.core.actuator.TransferActuatorTest > initializationError FAILED java.lang.ClassNotFoundException: org.tron.core.actuator.TransferActuatorTest

    Caused by:
    java.io.FileNotFoundException: /home/xxx/tron/java-tron/build/classes/java/test/org/tron/core/actuator/TransferActuatorTest.class (打开的文件过多)
hustxiaoc commented 5 years ago

Anybody?

taihaofu commented 5 years ago

Please try something like: ulimit -n 65535 to enlarge your resource capability. Hope it works.

hustxiaoc commented 5 years ago

I've tried, not working

shydesky commented 5 years ago

I've tried, not working

thanks for your submission, we fix this problem on the branch develop.Have fun with Tron!!

hustxiaoc commented 5 years ago

Thanks, have you reproduced this issue?

taihaofu commented 5 years ago

Not reproduced, but we got similar issue before. So, please try it on develop and let us know if you still have the issue.

Thanks.

hustxiaoc commented 5 years ago

@taihaofu it works ok on develop branch, but i got another issue, the block id I calculated doesn't match the one the tronscan.

Here is the block data.

{
  "transactionsList": [
    {
      "assetName": "Pornhub",
      "ownerAddress": "TTiRxbVEtA5WXP4BnNSPemPf6bBwixoaxy",
      "toAddress": "TF1CjijsKtZf6GcJevXv5KXBviomkNcebN",
      "amount": 1,
      "contractType": 2,
      "hash": "cbd489613ce8ea975a95d0d864e8eb832a798f5e8b03abf3de32a20012805e59",
      "time": 1538221857856
    },
    {
      "ownerAddress": "TAzQd76CpFK4pk4sWpz3yLuVL9oouZKhGA",
      "toAddress": "TBUrU7Fa2DYWzJPGRThk68w2cymNXzkJ1U",
      "amount": 861034,
      "contractType": 1,
      "hash": "4a2ca944b729354805375d17eaccdb12727c7c5db82c537950f9de014d87b19c",
      "time": 1538221859397
    },
    {
      "assetName": "IPFS",
      "ownerAddress": "TSgQpZ3pMoLmxyApaWUSdeNeP2D9a1WQDA",
      "toAddress": "TVyGwmne4cz6sMQjyuo9Geyrrm23ocu4PR",
      "amount": 5,
      "contractType": 2,
      "hash": "087f9429c3e69bde89219a68e889da677c4b7461fb6780c9669c8b9e53aa5951",
      "time": 0
    },
    {
      "assetName": "Durex",
      "ownerAddress": "TXJnVqqwLSNmdXDLWn1Yfjhe8aZH2oaAuq",
      "toAddress": "TSgfuHs7ZityhQsJEd39zSTvXXzmfWM1Bw",
      "amount": 1,
      "contractType": 2,
      "hash": "e020d9e3dd9157ce6d29b57f208ecbb2ccf4bcddb9d874572386798a288f860b",
      "time": 1538221858716
    },
    {
      "assetName": "IGG",
      "ownerAddress": "TBFR6mgFjhMcUuBC4NPpqiRfvrs27RPvGZ",
      "toAddress": "TTeNmnrmR321tsecgHMnCcbdvtPbEHzFbK",
      "amount": 2,
      "contractType": 2,
      "hash": "d6efa19ecabcd9612f261dd8654d250a01f350bec598eee89b444735b37e6efa",
      "time": 1538221857162
    },
    {
      "assetName": "IPFS",
      "ownerAddress": "TV3NmH1enpu4X5Hur8Z16eCyNymTqKXQDP",
      "toAddress": "TJqKxpRrUVGDem7GtBx2zfVXL4byWnfyk8",
      "amount": 1,
      "contractType": 2,
      "hash": "9209e48413fa928fa464750c3c0abba551fe00661210576a6588f842148a348b",
      "time": 1538221859070
    },
    {
      "assetName": "Messenger",
      "ownerAddress": "TGB3AGQJMzsNdNLD46qe81zN6VWcn3vXhv",
      "toAddress": "TWdDnc2mSXwVEw1PeBRtBw5C1zJS8A3q4G",
      "amount": 1,
      "contractType": 2,
      "hash": "ec18a487b50fef60f3fcf2014b69e180acf55ddd284cea30b496d89a65e6af32",
      "time": 1538221859083
    },
    {
      "assetName": "Messenger",
      "ownerAddress": "TGB3AGQJMzsNdNLD46qe81zN6VWcn3vXhv",
      "toAddress": "TEv149aUafAED2guoZweqqxdakaqZEegtP",
      "amount": 1,
      "contractType": 2,
      "hash": "44b120b9ca145b8699dd18419309b74ae3226637cc256dfffe8781a9971e3d3d",
      "time": 1538221859216
    },
    {
      "ownerAddress": "TGohC6vGThQd6g8RArr1Mh6A4aokNw2pVz",
      "votesList": [
        null
      ],
      "support": false,
      "contractType": 4,
      "hash": "ec9ae435ede38861bf27f051aaff1a75c9f9a87fe48c3de5afeae5d7cda1e19d",
      "time": 1538221859519
    },
    {
      "assetName": "Pornhub",
      "ownerAddress": "TTiRxbVEtA5WXP4BnNSPemPf6bBwixoaxy",
      "toAddress": "TSgfuHs7ZityhQsJEd39zSTvXXzmfWM1Bw",
      "amount": 1,
      "contractType": 2,
      "hash": "7975a62a29e64152a316d45edd9accd3a9674ea7331301a1cc5d87430930c008",
      "time": 1538221859484
    },
    {
      "assetName": "IGG",
      "ownerAddress": "TBFR6mgFjhMcUuBC4NPpqiRfvrs27RPvGZ",
      "toAddress": "TEJTmy9wBJBQwk4dwrU6YBmjhrs9p5Wt37",
      "amount": 2,
      "contractType": 2,
      "hash": "5713706abf08cb4d40e8194e65c1bb9bcbd79f9bb0ef2399bb81de7ed2ee50c7",
      "time": 1538221861255
    },
    {
      "ownerAddress": "TUzHspLw5qJRoeJSaguRUQdZ97gN2ywPzC",
      "toAddress": "TPXnJz11sw1pztnUhArPn7vhdJ6Cm5GpMa",
      "amount": 4200633,
      "contractType": 1,
      "hash": "7947d1d02e4a6f7877c0ba91f3ce22f316963dea89da1f7c3399bb8a1a497e8b",
      "time": 1538221861385
    },
    {
      "assetName": "Durex",
      "ownerAddress": "TXJnVqqwLSNmdXDLWn1Yfjhe8aZH2oaAuq",
      "toAddress": "TPMwd8esjqfCPpTP2W4dV9jquucPYnBmvU",
      "amount": 1,
      "contractType": 2,
      "hash": "57a992fdbdfbc930f0f2c6c1aec3788e53051c67b422e8e9ca769a562540620f",
      "time": 1538221860336
    },
    {
      "assetName": "Messenger",
      "ownerAddress": "TGB3AGQJMzsNdNLD46qe81zN6VWcn3vXhv",
      "toAddress": "TUcBTXEwF8AvBuJ8PQaVrLcWpTL2d4q7oB",
      "amount": 1,
      "contractType": 2,
      "hash": "5777d59043b7e59b4894e835636eb8c1bf326eb786e0b8a93d58b21528946a9f",
      "time": 1538221860664
    },
    {
      "assetName": "IPFS",
      "ownerAddress": "TV3NmH1enpu4X5Hur8Z16eCyNymTqKXQDP",
      "toAddress": "TWdDnc2mSXwVEw1PeBRtBw5C1zJS8A3q4G",
      "amount": 1,
      "contractType": 2,
      "hash": "e53d7b62a5612b51c06ecfa724ee17b546b218668242488aac3cfb739746e497",
      "time": 1538221860644
    }
  ],
  "transactionsCount": 15,
  "totalTrx": 5061685,
  "size": 3983,
  "time": 1538221863000,
  "witnessAddress": "TTMNxTmRpBZnjtUnohX84j25NLkTqDga7j",
  "number": 2765981,
  "parentHash": "00000000002a349c9e737a05e0a22c217a4462bf5a06781df7f70dc33861385c",
  "hash": "4ba6490d10d98c603decb12b5dbf5949c8978ccf4f5fd7075effc838a3417d96"
}

And the block id I calculate is 00000000002a349d3decb12b5dbf5949c8978ccf4f5fd7075effc838a3417d96, but the real one is 00000000002a349dae6d2f05da3254d76f7334d273714b285dff9f72842c81dc, did i miss something?

shydesky commented 5 years ago

@taihaofu it works ok on develop branch, but i got another issue, the block id I calculated doesn't match the one the tronscan.

Here is the block data.

{
  "transactionsList": [
    {
      "assetName": "Pornhub",
      "ownerAddress": "TTiRxbVEtA5WXP4BnNSPemPf6bBwixoaxy",
      "toAddress": "TF1CjijsKtZf6GcJevXv5KXBviomkNcebN",
      "amount": 1,
      "contractType": 2,
      "hash": "cbd489613ce8ea975a95d0d864e8eb832a798f5e8b03abf3de32a20012805e59",
      "time": 1538221857856
    },
    {
      "ownerAddress": "TAzQd76CpFK4pk4sWpz3yLuVL9oouZKhGA",
      "toAddress": "TBUrU7Fa2DYWzJPGRThk68w2cymNXzkJ1U",
      "amount": 861034,
      "contractType": 1,
      "hash": "4a2ca944b729354805375d17eaccdb12727c7c5db82c537950f9de014d87b19c",
      "time": 1538221859397
    },
    {
      "assetName": "IPFS",
      "ownerAddress": "TSgQpZ3pMoLmxyApaWUSdeNeP2D9a1WQDA",
      "toAddress": "TVyGwmne4cz6sMQjyuo9Geyrrm23ocu4PR",
      "amount": 5,
      "contractType": 2,
      "hash": "087f9429c3e69bde89219a68e889da677c4b7461fb6780c9669c8b9e53aa5951",
      "time": 0
    },
    {
      "assetName": "Durex",
      "ownerAddress": "TXJnVqqwLSNmdXDLWn1Yfjhe8aZH2oaAuq",
      "toAddress": "TSgfuHs7ZityhQsJEd39zSTvXXzmfWM1Bw",
      "amount": 1,
      "contractType": 2,
      "hash": "e020d9e3dd9157ce6d29b57f208ecbb2ccf4bcddb9d874572386798a288f860b",
      "time": 1538221858716
    },
    {
      "assetName": "IGG",
      "ownerAddress": "TBFR6mgFjhMcUuBC4NPpqiRfvrs27RPvGZ",
      "toAddress": "TTeNmnrmR321tsecgHMnCcbdvtPbEHzFbK",
      "amount": 2,
      "contractType": 2,
      "hash": "d6efa19ecabcd9612f261dd8654d250a01f350bec598eee89b444735b37e6efa",
      "time": 1538221857162
    },
    {
      "assetName": "IPFS",
      "ownerAddress": "TV3NmH1enpu4X5Hur8Z16eCyNymTqKXQDP",
      "toAddress": "TJqKxpRrUVGDem7GtBx2zfVXL4byWnfyk8",
      "amount": 1,
      "contractType": 2,
      "hash": "9209e48413fa928fa464750c3c0abba551fe00661210576a6588f842148a348b",
      "time": 1538221859070
    },
    {
      "assetName": "Messenger",
      "ownerAddress": "TGB3AGQJMzsNdNLD46qe81zN6VWcn3vXhv",
      "toAddress": "TWdDnc2mSXwVEw1PeBRtBw5C1zJS8A3q4G",
      "amount": 1,
      "contractType": 2,
      "hash": "ec18a487b50fef60f3fcf2014b69e180acf55ddd284cea30b496d89a65e6af32",
      "time": 1538221859083
    },
    {
      "assetName": "Messenger",
      "ownerAddress": "TGB3AGQJMzsNdNLD46qe81zN6VWcn3vXhv",
      "toAddress": "TEv149aUafAED2guoZweqqxdakaqZEegtP",
      "amount": 1,
      "contractType": 2,
      "hash": "44b120b9ca145b8699dd18419309b74ae3226637cc256dfffe8781a9971e3d3d",
      "time": 1538221859216
    },
    {
      "ownerAddress": "TGohC6vGThQd6g8RArr1Mh6A4aokNw2pVz",
      "votesList": [
        null
      ],
      "support": false,
      "contractType": 4,
      "hash": "ec9ae435ede38861bf27f051aaff1a75c9f9a87fe48c3de5afeae5d7cda1e19d",
      "time": 1538221859519
    },
    {
      "assetName": "Pornhub",
      "ownerAddress": "TTiRxbVEtA5WXP4BnNSPemPf6bBwixoaxy",
      "toAddress": "TSgfuHs7ZityhQsJEd39zSTvXXzmfWM1Bw",
      "amount": 1,
      "contractType": 2,
      "hash": "7975a62a29e64152a316d45edd9accd3a9674ea7331301a1cc5d87430930c008",
      "time": 1538221859484
    },
    {
      "assetName": "IGG",
      "ownerAddress": "TBFR6mgFjhMcUuBC4NPpqiRfvrs27RPvGZ",
      "toAddress": "TEJTmy9wBJBQwk4dwrU6YBmjhrs9p5Wt37",
      "amount": 2,
      "contractType": 2,
      "hash": "5713706abf08cb4d40e8194e65c1bb9bcbd79f9bb0ef2399bb81de7ed2ee50c7",
      "time": 1538221861255
    },
    {
      "ownerAddress": "TUzHspLw5qJRoeJSaguRUQdZ97gN2ywPzC",
      "toAddress": "TPXnJz11sw1pztnUhArPn7vhdJ6Cm5GpMa",
      "amount": 4200633,
      "contractType": 1,
      "hash": "7947d1d02e4a6f7877c0ba91f3ce22f316963dea89da1f7c3399bb8a1a497e8b",
      "time": 1538221861385
    },
    {
      "assetName": "Durex",
      "ownerAddress": "TXJnVqqwLSNmdXDLWn1Yfjhe8aZH2oaAuq",
      "toAddress": "TPMwd8esjqfCPpTP2W4dV9jquucPYnBmvU",
      "amount": 1,
      "contractType": 2,
      "hash": "57a992fdbdfbc930f0f2c6c1aec3788e53051c67b422e8e9ca769a562540620f",
      "time": 1538221860336
    },
    {
      "assetName": "Messenger",
      "ownerAddress": "TGB3AGQJMzsNdNLD46qe81zN6VWcn3vXhv",
      "toAddress": "TUcBTXEwF8AvBuJ8PQaVrLcWpTL2d4q7oB",
      "amount": 1,
      "contractType": 2,
      "hash": "5777d59043b7e59b4894e835636eb8c1bf326eb786e0b8a93d58b21528946a9f",
      "time": 1538221860664
    },
    {
      "assetName": "IPFS",
      "ownerAddress": "TV3NmH1enpu4X5Hur8Z16eCyNymTqKXQDP",
      "toAddress": "TWdDnc2mSXwVEw1PeBRtBw5C1zJS8A3q4G",
      "amount": 1,
      "contractType": 2,
      "hash": "e53d7b62a5612b51c06ecfa724ee17b546b218668242488aac3cfb739746e497",
      "time": 1538221860644
    }
  ],
  "transactionsCount": 15,
  "totalTrx": 5061685,
  "size": 3983,
  "time": 1538221863000,
  "witnessAddress": "TTMNxTmRpBZnjtUnohX84j25NLkTqDga7j",
  "number": 2765981,
  "parentHash": "00000000002a349c9e737a05e0a22c217a4462bf5a06781df7f70dc33861385c",
  "hash": "4ba6490d10d98c603decb12b5dbf5949c8978ccf4f5fd7075effc838a3417d96"
}

And the block id I calculate is 00000000002a349d3decb12b5dbf5949c8978ccf4f5fd7075effc838a3417d96, but the real one is 00000000002a349dae6d2f05da3254d76f7334d273714b285dff9f72842c81dc, did i miss something?

how did you calculate?

hustxiaoc commented 5 years ago
const block_hash = '4ba6490d10d98c603decb12b5dbf5949c8978ccf4f5fd7075effc838a3417d96';
const height = 2765981;
let heightBuffer = Buffer.from(height.toString('16'), 'hex');
heightBuffer = Buffer.concat([new Buffer(8), heightBuffer]).slice(-8);
const hashBuffer = Buffer.from(block_hash, 'hex');
heightBuffer.copy(hashBuffer);
console.log(hashBuffer.toString('hex'));

I also tried this https://github.com/tronprotocol/tron-demo/blob/master/demo/nodejs/server.js#L35

taihaofu commented 5 years ago
const block_hash = '4ba6490d10d98c603decb12b5dbf5949c8978ccf4f5fd7075effc838a3417d96';
const height = 2765981;
let heightBuffer = Buffer.from(height.toString('16'), 'hex');
heightBuffer = Buffer.concat([new Buffer(8), heightBuffer]).slice(-8);
const hashBuffer = Buffer.from(block_hash, 'hex');
heightBuffer.copy(hashBuffer);
console.log(hashBuffer.toString('hex'));

I also tried this https://github.com/tronprotocol/tron-demo/blob/master/demo/nodejs/server.js#L35

Curious about how you get the Block data you provide above?

blockId is generated basing on hash and height(replace the last 8 bytes of original hash). And the hash should be calculated basing on BlockHeader.raw_data in protobuf when you create a block.

Some related code: https://github.com/tronprotocol/java-tron/blob/3f5eadd9993d308aeb28d3dbd84ebc227b601a71/src/main/java/org/tron/core/capsule/BlockCapsule.java#L225

I tried it using tronprotocol/wallet-cli, and it works for height = 2765981 .

hustxiaoc commented 5 years ago

The block data is provided from the grpc api, what's the block hash of 2765981 based on tronprotocol/wallet-cli?