-
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
Abort ScheduleSignTransitionLogic if schedule is resolved #1303
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1303 +/- ##
=========================================
Coverage 87.89% 87.90%
- Complexity 5672 5677 +5
=========================================
Files 450 450
Lines 16839 16858 +19
Branches 1757 1760 +3
=========================================
+ Hits 14801 14819 +18
- Misses 1567 1568 +1
Partials 471 471
Continue to review full report at Codecov.
|
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!
public abstract class ScheduleReadyForExecution { | ||
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK; | ||
|
||
public class ScheduleReadyForExecution { |
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.
Let's add some class level documentation to explain what this class is and how it fits into the system
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.
Added class level documentation here.
@@ -37,16 +39,19 @@ | |||
} | |||
|
|||
ResponseCodeEnum processExecution(ScheduleID id) throws InvalidProtocolBufferException { | |||
var executionStatus = store.markAsExecuted(id); |
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 prefer to see "final" in situations like this. It makes reading the code easier, because as I read the code (from top to bottom) I can tell just from this line that executionStatus
isn't going to be modified anywhere further down. As it is, I'm not sure, so I have to read the rest of the code in the block scope to verify that it is "effectively 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.
Made the changes.
dd914ee
to
1f12ec2
Compare
/** | ||
* Defines a class to handle scheduled transaction execution | ||
* once the scheduled transaction is signed by the required | ||
* number of parties. | ||
* | ||
* @author Michael Tinker | ||
* @author Abhishek Pandey | ||
*/ | ||
public class ScheduleReadyForExecution { |
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.
Thanks for adding some documentation.
I see that the class is non-final, yet the documentation doesn't give me any idea as to whether this is intentional or not. I don't want to see a comment that says something like "This class is non-final so it can be extended", but rather something like "This base class does X. Subclasses should override X, Y, and Z to implement ABC". Something with more meat to it. Or, if the class is not meant to be extended, lets forbid it by making the class final.
Another thought is that you can probably run the comment out to 80 chars instead of breaking at 60 or so.
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 believe it could be made final and ScheduleCreateTransitionLogic
, ScheduleSignTransitionLogic
which extend from this class could use the base class instance as a member variable. Refactoring has introduced some unit tests failures for now which would be fixed with the help of @tinker-michaelj
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 to use the new final class ScheduleExecutor
, and modified the documentation comments to be around 80 chars.
* @param id The id of the scheduled transaction. | ||
* | ||
* @return the response code from executing the inner scheduled 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.
I'd like us to document the expected state and conditions for the param and the return value. I see that id
is an object, which means it might be null. Is null a valid input? How does it behave if we do pass a null? (Is there a test for this?).
The method documentation suggests that this method checks if the underlying transaction is already executed/deleted. Based on this wording, I would expect the method to return a boolean. But actually, I think this method does more, it just happens to perform this check in addition to other stuff? The method description doesn't seem to align with the method signature.
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.
Thanks for reviewing it, I have changed the method documentation, added tests for not null checks. The inputs now have a @NotNull annotation. The return value would always be a proper ResponseEnumCode.
e183d07
to
d261578
Compare
/** | ||
* Given a {@link ScheduleID}, {@link ScheduleStore}, {@link TransactionContext} it first checks if the underlying | ||
* transaction is already executed/deleted before attempting to execute and then returns response code after | ||
* triggering the underlying transaction. A ResponseEnumCode of OK is returned upon successful trigger of the | ||
* inner transaction. | ||
* | ||
* @param id The id of the scheduled transaction. | ||
* @param store Object to handle scheduled entity type. | ||
* @param context Object to handle inner transaction specific context on a node. | ||
* @return the response code {@link ResponseCodeEnum} from executing the inner scheduled transaction | ||
*/ | ||
ResponseCodeEnum processExecution(ScheduleID id, ScheduleStore store, TransactionContext context) throws |
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.
Thanks for this documentation, it is much better! Please also add some indication as to whether the various args and return value can be null. Are we able to use the @NotNull annotation? That might make static code analysis able to interpret the semantics, and not just have it defined in the documentation.
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.
That sounds great. Modified it to have @NotNull annotation.
Signed-off-by: tinker-michaelj <[email protected]>
Signed-off-by: tinker-michaelj <[email protected]>
Signed-off-by: tinker-michaelj <[email protected]>
Signed-off-by: tinker-michaelj <[email protected]>
Signed-off-by: tinker-michaelj <[email protected]>
Signed-off-by: tinker-michaelj <[email protected]>
Signed-off-by: tinker-michaelj <[email protected]>
Signed-off-by: tinker-michaelj <[email protected]>
Signed-off-by: abhishek-hedera <[email protected]>
Signed-off-by: abhishek-hedera <[email protected]>
Signed-off-by: abhishek-hedera <[email protected]>
Signed-off-by: abhishek-hedera <[email protected]>
Signed-off-by: abhishek-hedera <[email protected]>
e0132a5
to
6722609
Compare
Summary of the change:
ScheduleSignTransitionLogic
if the target schedule is already resolved (either executed or deleted).ScheduleReadyForExecution
gate the call totxnCtx.trigger
by confirming the schedule was successfully marked as executed.Also create tests that assert both response codes and state changes (including charged service fees for non-
SUCCESS
ful transactions) are as expected when we:UNRESOLVABLE_REQUIRED_SIGNERS
)UNRESOLVABLE_REQUIRED_SIGNERS
)