-
Notifications
You must be signed in to change notification settings - Fork 266
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
Signature cache #1876
Signature cache #1876
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good start 👍🏻 . I guess we could make use the cache in other places too, what do you think?
Yes! there's a couple of places where we should include it too! |
c89ab7b
to
ccef67b
Compare
private static final Logger logger = LoggerFactory.getLogger("minerserver"); | ||
|
||
private final SignatureCache signatureCache; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm.. this is a utility class, so ideally without any state, and all its methods should should be static
@@ -167,7 +172,7 @@ public List<org.ethereum.core.Transaction> getAllTransactions(TransactionPool tr | |||
|
|||
List<Transaction> txs = transactionPool.getPendingTransactions(); | |||
|
|||
return PendingState.sortByPriceTakingIntoAccountSenderAndNonce(txs); | |||
return PendingState.sortByPriceTakingIntoAccountSenderAndNonce(txs, signatureCache); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this method be static?
@@ -177,7 +182,7 @@ public List<org.ethereum.core.Transaction> filterTransactions(List<Transaction> | |||
Keccak256 hash = tx.getHash(); | |||
Coin txValue = tx.getValue(); | |||
BigInteger txNonce = new BigInteger(1, tx.getNonce()); | |||
RskAddress txSender = tx.getSender(); | |||
RskAddress txSender = tx.getSender(signatureCache); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update this as requested. 💪🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
BigInteger blockGasLimit = BigIntegers.fromUnsignedByteArray(executionBlock.getGasLimit()); | ||
Coin minimumGasPrice = executionBlock.getMinimumGasPrice(); | ||
long bestBlockNumber = executionBlock.getNumber(); | ||
long basicTxCost = tx.transactionCost(constants, activationConfig.forBlock(bestBlockNumber)); | ||
|
||
if (state == null && basicTxCost != 0) { | ||
logger.trace("[tx={}, sender={}] account doesn't exist", tx.getHash(), tx.getSender()); | ||
logger.trace("[tx={}, sender={}] account doesn't exist", tx.getHash(), sender); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just an idea.. what about providing signature cache in the ctor and using it here? it's not that obvious that new param - sender - has to be sender of the tx being provided..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds good! if it's clearer let's do it! I thought that maybe it was too much to include this in the ctor just for a log, but you're right, it will look better. Will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
42ab778
to
af2507c
Compare
94f2ed3
to
24f0867
Compare
pipeline:run |
1 similar comment
pipeline:run |
|
||
if (state == null && basicTxCost != 0) { | ||
logger.trace("[tx={}, sender={}] account doesn't exist", tx.getHash(), tx.getSender()); | ||
logger.trace("[tx={}, sender={}] account doesn't exist", tx.getHash(), tx.getSender(signatureCache)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could check logger.isTraceEnabled()
before logging? cause tx.getSender(signatureCache)
is heavy one if not cached
@@ -2666,10 +2670,10 @@ public BigInteger registerFlyoverBtcTransaction( | |||
return BigInteger.valueOf(FlyoverTxResponseCodes.UNPROCESSABLE_TX_NOT_CONTRACT_ERROR.value()); | |||
} | |||
|
|||
if (!rskTx.getSender().equals(lbcAddress)) { | |||
if (!rskTx.getSender(signatureCache).equals(lbcAddress)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we extract rskTx.getSender(signatureCache)
into a local variable and reuse below?
@@ -401,7 +401,7 @@ public TxQuotaChecker getTxQuotaChecker() { | |||
checkIfNotClosed(); | |||
|
|||
if (this.txQuotaChecker == null) { | |||
this.txQuotaChecker = new TxQuotaChecker(System::currentTimeMillis); | |||
this.txQuotaChecker = new TxQuotaChecker(System::currentTimeMillis, getBlockTxSignatureCache()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems this checker is being used by tx pool.. shouldn't it be getReceivedTxSignatureCache()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. This may also need a counterpart pr for powpeg
4f94d6c
to
b1cbe78
Compare
pipeline:run |
8 similar comments
pipeline:run |
pipeline:run |
pipeline:run |
pipeline:run |
pipeline:run |
pipeline:run |
pipeline:run |
pipeline:run |
e6fedb2
to
35dc1bc
Compare
pipeline:run |
3 similar comments
pipeline:run |
pipeline:run |
pipeline:run |
221a47f
to
3ef3d1f
Compare
Kudos, SonarCloud Quality Gate passed! |
pipeline:run |
Description
Extending Signature Cache support
Motivation and Context
#1850
How Has This Been Tested?
Unit Tests
QA
Types of changes
Checklist:
fed:signature-cache