HelixNetwork / pendulum

Pendulum is a distributed messaging protocol that enables globally available tamper proof timestamps :hourglass_flowing_sand:
https://dev.hlx.ai
Other
10 stars 6 forks source link

API.storeAndBroadcast calls runValidation multiple times for same set of tx #225

Open dnck opened 4 years ago

dnck commented 4 years ago

Expected behavior

Is this expected behavior?

Milestone publishing calls the TransactionValidator.runValidation method at least three times on the same set of transactions...

This seems to be accidental.


Trace details

The API.storeAndBroadcast method https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/service/API.java#L1523 calls the API.attachToTangleStatement method https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/service/API.java#L1220 which leads to a call of TransactionValidator.runValidation method https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/TransactionValidator.java#L215 through the tx validator's validateBytes method. https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/service/API.java#L1263 (END FIRST CALL)

After finishing with the above, the API.storeAndBroadcast method calls the API. storeTransactionsStatement method, https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/service/API.java#L1526 which results in the API.addValidTxvmToList method, https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/service/API.java#L592 calling TransactionValidator.runValidation method for the second time. https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/service/API.java#L616-L618 (END SECOND CALL)

Finally, the broadcastTransactionsStatement at the end of the API.storeAndBroadcast method https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/service/API.java#L1527 calls again the API.addValidTxvmToList method https://github.com/HelixNetwork/pendulum/blob/77fbd5844df3d0962679358665508518a656a0bc/src/main/java/net/helix/pendulum/service/API.java#L1096 which results in a final call to TransactionValidator.runValidation for presumably the same set of tx that had already undergone validation twice before. (END THIRD CALL)