From ee259584c46bfe9802dd869082ba7d9357f6fb0f Mon Sep 17 00:00:00 2001 From: mikeluxue Date: Tue, 11 Apr 2023 14:32:51 +0800 Subject: [PATCH 1/4] feat(core): increase default tx expiration time --- .../core/src/main/java/org/tron/trident/core/ApiWrapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java b/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java index 1256d89..83b4a54 100644 --- a/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java +++ b/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java @@ -105,7 +105,7 @@ */ public class ApiWrapper { - public static final long TRANSACTION_DEFAULT_EXPIRATION_TIME = 60 * 1_000L; //60 seconds + public static final long TRANSACTION_DEFAULT_EXPIRATION_TIME = 300 * 1_000L; //300 seconds public final WalletGrpc.WalletBlockingStub blockingStub; public final WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity; From 928d908844cfb68859a74896add195815b3b2a33 Mon Sep 17 00:00:00 2001 From: mikeluxue Date: Tue, 11 Apr 2023 14:48:48 +0800 Subject: [PATCH 2/4] feat(core): restore default tx expiration time --- .../core/src/main/java/org/tron/trident/core/ApiWrapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java b/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java index 83b4a54..49ee35b 100644 --- a/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java +++ b/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java @@ -105,7 +105,7 @@ */ public class ApiWrapper { - public static final long TRANSACTION_DEFAULT_EXPIRATION_TIME = 300 * 1_000L; //300 seconds + public static final long TRANSACTION_DEFAULT_EXPIRATION_TIME = 60 * 1_000L; //60 seconds public final WalletGrpc.WalletBlockingStub blockingStub; public final WalletSolidityGrpc.WalletSolidityBlockingStub blockingStubSolidity; @@ -282,7 +282,7 @@ private TransactionCapsule createTransactionCapsuleWithoutValidate( } //build transaction trx.setTransactionCreate(false); - BlockExtention solidHeadBlock = blockingStubSolidity.getNowBlock2(EmptyMessage.getDefaultInstance()); + BlockExtention solidHeadBlock = blockingStub.getNowBlock2(EmptyMessage.getDefaultInstance()); //get solid head blockId byte[] blockHash = Utils.getBlockId(solidHeadBlock).getBytes(); trx.setReference(solidHeadBlock.getBlockHeader().getRawData().getNumber(), blockHash); From 0281ab7dc2d30be83c06ae895094fb62e24cf475 Mon Sep 17 00:00:00 2001 From: mikeluxue Date: Tue, 11 Apr 2023 14:50:16 +0800 Subject: [PATCH 3/4] feat(core): refactor codes --- .../main/java/org/tron/trident/core/ApiWrapper.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java b/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java index 49ee35b..02ee100 100644 --- a/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java +++ b/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java @@ -282,12 +282,12 @@ private TransactionCapsule createTransactionCapsuleWithoutValidate( } //build transaction trx.setTransactionCreate(false); - BlockExtention solidHeadBlock = blockingStub.getNowBlock2(EmptyMessage.getDefaultInstance()); - //get solid head blockId - byte[] blockHash = Utils.getBlockId(solidHeadBlock).getBytes(); - trx.setReference(solidHeadBlock.getBlockHeader().getRawData().getNumber(), blockHash); + BlockExtention headBlock = blockingStub.getNowBlock2(EmptyMessage.getDefaultInstance()); + //get head blockId + byte[] blockHash = Utils.getBlockId(headBlock).getBytes(); + trx.setReference(headBlock.getBlockHeader().getRawData().getNumber(), blockHash); - long expiration = solidHeadBlock.getBlockHeader().getRawData().getTimestamp() + TRANSACTION_DEFAULT_EXPIRATION_TIME; + long expiration = headBlock.getBlockHeader().getRawData().getTimestamp() + TRANSACTION_DEFAULT_EXPIRATION_TIME; trx.setExpiration(expiration); trx.setTimestamp(); From c48cfb5442a310ab953bb5ce5f2fb9d3802e8356 Mon Sep 17 00:00:00 2001 From: mikeluxue Date: Tue, 11 Apr 2023 14:55:45 +0800 Subject: [PATCH 4/4] feat(core): change tx expiration time value --- .../main/java/org/tron/trident/core/ApiWrapper.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java b/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java index 02ee100..4864170 100644 --- a/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java +++ b/trident-java/core/src/main/java/org/tron/trident/core/ApiWrapper.java @@ -282,11 +282,13 @@ private TransactionCapsule createTransactionCapsuleWithoutValidate( } //build transaction trx.setTransactionCreate(false); - BlockExtention headBlock = blockingStub.getNowBlock2(EmptyMessage.getDefaultInstance()); - //get head blockId - byte[] blockHash = Utils.getBlockId(headBlock).getBytes(); - trx.setReference(headBlock.getBlockHeader().getRawData().getNumber(), blockHash); + BlockExtention solidHeadBlock = blockingStubSolidity.getNowBlock2(EmptyMessage.getDefaultInstance()); + //get solid head blockId + byte[] blockHash = Utils.getBlockId(solidHeadBlock).getBytes(); + trx.setReference(solidHeadBlock.getBlockHeader().getRawData().getNumber(), blockHash); + //get expiration time from head block timestamp + BlockExtention headBlock = blockingStub.getNowBlock2(EmptyMessage.getDefaultInstance()); long expiration = headBlock.getBlockHeader().getRawData().getTimestamp() + TRANSACTION_DEFAULT_EXPIRATION_TIME; trx.setExpiration(expiration); trx.setTimestamp();