Skip to content
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

Lay groundwork for ignoring app transactions during pces replay. #6442

Merged
merged 2 commits into from May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

This file was deleted.

This file was deleted.

Expand Up @@ -24,11 +24,21 @@
*/
public enum PlatformStatus implements UniqueId {
/**
* The Platform is still starting up. This is the default state before ACTIVE
* The Platform is starting up.
*/
STARTING_UP(1),
/**
* All is normal: the Platform is running, connected, and syncing properly
* The platform is replaying events from the preconsensus event stream.
* (Not yet in use)
*/
REPLAYING_EVENTS(7),
cody-littley marked this conversation as resolved.
Show resolved Hide resolved
/**
* The platform has starting up or has finished reconnecting, and is now ready to rejoin the network.
* (Not yet in use)
*/
READY(8),
/**
* All is normal: the Platform is running, connected, and gossiping.
*/
ACTIVE(2),
/**
Expand Down
Expand Up @@ -16,26 +16,37 @@

package com.swirlds.common.system;

import edu.umd.cs.findbugs.annotations.NonNull;

/**
* An object that can be used to submit transactions.
*/
public interface TransactionSubmitter {

/**
* The SwirldMain object calls this method when it wants to create a new transaction. The newly-created
* transaction is then embedded inside a newly-created event, and sent to all the other members of the
* community during syncs. It is also sent to the swirldState object.
* This method can be called to create a new transaction. If accepted by this method, the newly-created transaction
* will eventually be embedded inside a newly-created event as long as the node does not shut down before getting
* around to it. As long as this node is healthy, with high probability the transaction will reach consensus, but
* this is not a hard guarantee.
* <p>
* If transactions are being created faster than they can be handled, then eventually a large backlog
* will build up. At that point, a call to createTransaction will return false, and will not actually
* create a transaction.
* This method will sometimes reject new transactions. Some (but not necessarily all) causes for a transaction to be
* rejected by this method:
*
* <ul>
* <li>the node is starting up</li>
* <li>the node is performing a reconnect</li>
* <li>the node is preparing for an upgrade</li>
* <li>the node is unable to submit transactions fast enough and has built up a backlog</li>
* <li>the node is having health problems</li>
* </ul>
*
* <p>
* A transaction can be at most 1024 bytes. If trans.length &gt; 1024, then this will return false, and
* will not actually create a transaction.
* Transactions have a maximum size defined by the setting "transactionMaxBytes". If a transaction larger than
* this is submitted, this method will always reject it.
*
* @param trans
* the transaction to handle, encoded any way the swirld author chooses
* @return true if successful
* @param transaction the transaction to handle in binary format (format used is up to the application)
* @return true if the transaction is accepted, false if it is rejected. Being accepted does not guarantee that the
* transaction will ever reach consensus, only that this node will make a best-effort attempt to make that happen.
*/
boolean createTransaction(byte[] trans);
boolean createTransaction(@NonNull byte[] transaction);
}
Expand Up @@ -1363,6 +1363,11 @@ public void run() {
PAUSE_ALERT_INTERVAL / 2);
}

// FUTURE WORK: set platform status REPLAYING_EVENTS
// FUTURE WORK: replay events
// FUTURE WORK: validate that status is still REPLAYING_EVENTS (holdover until we refactor platform status)
// FUTURE WORK: set platform status READY

// in case of a single node network, the platform status update will not be triggered by connections, so it
// needs to be triggered now
checkPlatformStatus();
Expand Down Expand Up @@ -1930,8 +1935,8 @@ public PreConsensusEventHandler getPreConsensusHandler() {

/** {@inheritDoc} */
@Override
public boolean createTransaction(final byte[] trans) {
return transactionSubmitter.submitTransaction(new SwirldTransaction(trans));
public boolean createTransaction(@NonNull final byte[] transaction) {
return transactionSubmitter.submitTransaction(new SwirldTransaction(transaction));
}

/**
Expand Down
Expand Up @@ -184,7 +184,7 @@ public <T extends SwirldState> AutoCloseableWrapper<T> getLatestSignedState(@Non
* {@inheritDoc}
*/
@Override
public boolean createTransaction(final byte[] trans) {
public boolean createTransaction(@NonNull final byte[] transaction) {
// Transaction creation always fails
return false;
}
Expand Down