Revert "Use onlineAccountTimestamp for all mempow hard fork related code in OnlineAccountsManager too."

This reverts commit 23423102e7.
This commit is contained in:
CalDescent 2022-09-10 17:23:34 +01:00
parent 0e42e7b05a
commit 03e3619817
2 changed files with 8 additions and 8 deletions

View File

@ -1079,7 +1079,7 @@ public class Block {
// Validate the rest // Validate the rest
for (OnlineAccountData onlineAccount : onlineAccounts) for (OnlineAccountData onlineAccount : onlineAccounts)
if (!OnlineAccountsManager.getInstance().verifyMemoryPoW(onlineAccount)) if (!OnlineAccountsManager.getInstance().verifyMemoryPoW(onlineAccount, this.blockData.getTimestamp()))
return ValidationResult.ONLINE_ACCOUNT_NONCE_INCORRECT; return ValidationResult.ONLINE_ACCOUNT_NONCE_INCORRECT;
} }

View File

@ -305,8 +305,8 @@ public class OnlineAccountsManager {
} }
// Validate mempow if feature trigger is active // Validate mempow if feature trigger is active
if (onlineAccountTimestamp >= BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp()) { if (now >= BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp()) {
if (!getInstance().verifyMemoryPoW(onlineAccountData)) { if (!getInstance().verifyMemoryPoW(onlineAccountData, now)) {
LOGGER.trace(() -> String.format("Rejecting online reward-share for account %s due to invalid PoW nonce", mintingAccount.getAddress())); LOGGER.trace(() -> String.format("Rejecting online reward-share for account %s due to invalid PoW nonce", mintingAccount.getAddress()));
return false; return false;
} }
@ -544,7 +544,7 @@ public class OnlineAccountsManager {
// Compute nonce // Compute nonce
Integer nonce; Integer nonce;
if (isMemoryPoWActive(onlineAccountsTimestamp)) { if (isMemoryPoWActive(NTP.getTime())) {
try { try {
nonce = this.computeMemoryPoW(mempowBytes, publicKey, onlineAccountsTimestamp); nonce = this.computeMemoryPoW(mempowBytes, publicKey, onlineAccountsTimestamp);
if (nonce == null) { if (nonce == null) {
@ -567,7 +567,7 @@ public class OnlineAccountsManager {
OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey, nonce); OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey, nonce);
// Make sure to verify before adding // Make sure to verify before adding
if (verifyMemoryPoW(ourOnlineAccountData)) { if (verifyMemoryPoW(ourOnlineAccountData, NTP.getTime())) {
ourOnlineAccounts.add(ourOnlineAccountData); ourOnlineAccounts.add(ourOnlineAccountData);
} }
} }
@ -617,7 +617,7 @@ public class OnlineAccountsManager {
} }
private Integer computeMemoryPoW(byte[] bytes, byte[] publicKey, long onlineAccountsTimestamp) throws TimeoutException { private Integer computeMemoryPoW(byte[] bytes, byte[] publicKey, long onlineAccountsTimestamp) throws TimeoutException {
if (!isMemoryPoWActive(onlineAccountsTimestamp)) { if (!isMemoryPoWActive(NTP.getTime())) {
LOGGER.info("Mempow start timestamp not yet reached, and onlineAccountsMemPoWEnabled not enabled in settings"); LOGGER.info("Mempow start timestamp not yet reached, and onlineAccountsMemPoWEnabled not enabled in settings");
return null; return null;
} }
@ -643,8 +643,8 @@ public class OnlineAccountsManager {
return nonce; return nonce;
} }
public boolean verifyMemoryPoW(OnlineAccountData onlineAccountData) { public boolean verifyMemoryPoW(OnlineAccountData onlineAccountData, Long timestamp) {
if (!isMemoryPoWActive(onlineAccountData.getTimestamp())) { if (!isMemoryPoWActive(timestamp)) {
// Not active yet, so treat it as valid // Not active yet, so treat it as valid
return true; return true;
} }