-
Notifications
You must be signed in to change notification settings - Fork 143
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
refactor: system transactions #17406
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
…5-system-transaction-refactoring # Conflicts: # platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/eventhandling/DefaultTransactionPrehandler.java # platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/SwirldStateManager.java # platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/state/TransactionHandler.java
Signed-off-by: Mustafa Uzun <[email protected]>
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
@@ -91,6 +91,8 @@ public DefaultTransactionPrehandler( | |||
public List<ScopedSystemTransaction<StateSignatureTransaction>> prehandleApplicationTransactions( | |||
@NonNull final PlatformEvent event) { | |||
final long startTime = time.nanoTime(); | |||
final List<ScopedSystemTransaction<StateSignatureTransaction>> scopedSystemTransactions = new ArrayList<>(); | |||
Consumer<ScopedSystemTransaction<StateSignatureTransaction>> consumer = scopedSystemTransactions::add; |
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 think this field can be final
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.
Refactored
@@ -47,8 +45,8 @@ public DefaultTransactionPool(@NonNull final TransactionPoolNexus transactionPoo | |||
@Override | |||
public void submitSystemTransaction(@NonNull final StateSignatureTransaction payload) { | |||
Objects.requireNonNull(payload); | |||
transactionPoolNexus.submitTransaction( | |||
new EventTransaction(new OneOf<>(TransactionOneOfType.STATE_SIGNATURE_TRANSACTION, payload)), true); | |||
Bytes payloadBytes = StateSignatureTransaction.PROTOBUF.toBytes(payload); |
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.
This should be final
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.
Refactored
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Node: HAPI Test (Token) Results 28 files 2 errors 26 suites 15s ⏱️ For more details on these parsing errors and failures, see this check. Results for commit a754bcb. ♻️ This comment has been updated with latest results. |
Signed-off-by: Mustafa Uzun <[email protected]>
…ring' into 16665-system-transaction-refactoring
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Node: HAPI Test (Smart Contract) Results 117 files 2 errors 115 suites 36m 3s ⏱️ For more details on these parsing errors, see this check. Results for commit b64fc96. ♻️ This comment has been updated with latest results. |
Signed-off-by: Ivan Kavaldzhiev <[email protected]>
…ring' into 16665-system-transaction-refactoring
/** The hash of the transaction */ | ||
private Bytes hash; | ||
/** The bytes of the transaction */ | ||
private Bytes transaction; |
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.
This field should be removed and the Bytes put inside EventTransaction
this.payload = EventTransaction.newBuilder() | ||
.applicationTransaction(payloadBytes) | ||
.build(); | ||
this.transaction = payloadBytes; |
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 think we should revert this change
Signed-off-by: Ivan Kavaldzhiev <[email protected]>
… transaction format Signed-off-by: Ivan Kavaldzhiev <[email protected]>
Node: HAPI Test (Time Consuming) Results 4 files 1 errors 3 suites 22m 7s ⏱️ For more details on these parsing errors, see this check. Results for commit 50733eb. |
Signed-off-by: Ivan Kavaldzhiev <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Node: HAPI Test (Restart) Results5 files 1 errors 4 suites 0s ⏱️ For more details on these parsing errors and failures, see this check. Results for commit dcaeb9c. |
Node: HAPI Test (Node Death Reconnect) Results2 tests 0 ✅ 0s ⏱️ For more details on these parsing errors and failures, see this check. Results for commit dcaeb9c. |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
Signed-off-by: Mustafa Uzun <[email protected]>
@@ -1030,7 +1030,7 @@ public PlatformComponentBuilder withTransactionPool(@NonNull final TransactionPo | |||
@NonNull | |||
public TransactionPool buildTransactionPool() { | |||
if (transactionPool == null) { | |||
transactionPool = new DefaultTransactionPool(blocks.transactionPoolNexus()); | |||
transactionPool = new DefaultTransactionPool(blocks.transactionPoolNexus(), blocks.stateLifecycles()); |
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.
this dependency should be removed
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.
Fixed
if (transaction.isSystem()) { | ||
numSysTrans++; | ||
sysSize += transaction.getSize(); | ||
avgBytesPerTransactionSys.update(transaction.getSize()); | ||
} else { | ||
// TODO: how to know if a transaction is a system transaction? | ||
if (isNewFormat) { | ||
numAppTrans++; | ||
appSize += transaction.getSize(); | ||
avgBytesPerTransaction.update(transaction.getSize()); | ||
appSize += transaction.getBytesSize(); | ||
avgBytesPerTransaction.update(transaction.getBytesSize()); | ||
} else { | ||
if (transaction.isSystem()) { | ||
numSysTrans++; | ||
sysSize += transaction.getSize(); | ||
avgBytesPerTransactionSys.update(transaction.getSize()); | ||
} else { | ||
numAppTrans++; | ||
appSize += transaction.getSize(); | ||
avgBytesPerTransaction.update(transaction.getSize()); | ||
} |
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.
simplify to just track all transactions equally, remove metric for system ones
transactionPoolNexus.submitTransaction( | ||
new EventTransaction(new OneOf<>(TransactionOneOfType.STATE_SIGNATURE_TRANSACTION, payload)), true); | ||
final Bytes payloadBytes = stateLifecycles.encodeSystemTransaction(payload); | ||
transactionPoolNexus.submitTransaction(payloadBytes, true, true); |
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.
this transformation should be done by a wiring transformer
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.
Fixed
public synchronized boolean submitTransaction( | ||
@NonNull final Bytes transaction, final boolean priority, final boolean isSystem) { |
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.
priority & isSystem are always equal, can be simplified
if (TransactionUtils.getLegacyTransactionSize(transaction) > maximumTransactionSize) { | ||
if (TransactionUtils.getLegacyTransactionSize(appTransaction) > maximumTransactionSize) { |
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.
@lpetrovic05 create a ticket for this cleanup
default Bytes encodeSystemTransaction(@NonNull final StateSignatureTransaction transaction) { | ||
throw new IllegalStateException("Invoke the method on the appropriate SwirldMain implementation!"); | ||
} |
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.
should be removed
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.
Fixed
Bytes getTransactionBytes(); | ||
|
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.
there should be a single method call to get the transaction
@@ -39,14 +39,18 @@ public sealed interface Transaction permits ConsensusTransaction { | |||
@Deprecated | |||
EventTransaction getTransaction(); |
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 we dont need this method anymore
int getBytesSize(); | ||
|
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.
there should be a single size method
/** | ||
* Check if a transaction is a system transaction.<br> | ||
* This is a convenience method that delegates to {@link #isSystemTransaction(OneOf)}. | ||
* | ||
* @param transaction the transaction to check | ||
* @return {@code true} if the transaction is a system transaction, {@code false} otherwise | ||
*/ | ||
public static boolean isSystemTransaction(@NonNull final EventTransaction transaction) { | ||
return isSystemTransaction(transaction.transaction()); | ||
// TODO: Refactor this method to work properly |
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.
todo
* <p> | ||
* If set to true, transactions will be encoded in the new format of Bytes. If set to false, the deprecated OneOf format will be used. | ||
*/ | ||
private boolean useNewTransactionFormat = false; |
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.
this should be reverted
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Mustafa Uzun <[email protected]>
Signed-off-by: Ivan Kavaldzhiev <[email protected]>
…ring' into 16665-system-transaction-refactoring
…ing them to TransactionPool Signed-off-by: Ivan Kavaldzhiev <[email protected]>
Signed-off-by: Ivan Kavaldzhiev <[email protected]>
Description:
The final PR to support the new format of GossipEvent where transactions will be passed as
repeated bytes
Related issue(s):
Fixes #16665
Notes for reviewer:
Checklist