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

Support explicit "to" block for game_sendupdates #8

Merged
merged 4 commits into from
Feb 23, 2023
Merged

Conversation

domob1812
Copy link
Collaborator

This expands the game_sendupdates RPC method exposed by Xaya X to support the optional toblock argument. As long as the toblock is on the main chain, Xaya X will now be able to correctly send ZMQ notifications towards that block, instead of just the chain tip.

This fixes #7, and is a prerequisite for libxayagame's expanded "target block" implementation (xaya/libxayagame#130).

This extends the game_sendupdates method in the RPC server to accept
an optional "toblock" argument.  The argument must be empty for now
(i.e. is not yet actually handled).

libjson-rpc-cpp does not directly support method overloading or optional
arguments, so this by itself (just making the server accept it) is
what this change is about.

This is done by overriding the method handling calls in the RPC server,
and special-casing game_sendupdates.  In addition, by declaring the
method without arguments in the spec file, we turn off argument validation
on the libjson-rpc-cpp side, and do our own validation in the overridden
handler method.
Previously, the internal forkHeight variable set inside the PushZmqBlocks
logic was set to the height of the first block to attach from the main
chain.  Now it is one less, so that it actually is the "fork point" (i.e.
the block on the main chain on which the fork is based, or the from
block itself if it is on the main chain).  We also set explicitly the
forkPoint variable to its block hash.

This makes the code easier and more intuitive, and also simplifies it a
bit later on (by means of the new forkPoint).
This adds actual support for an explicit 'to' block to game_sendupdates,
as long as the target block is on the main chain (but it can be an old
block instead of the tip).  This is useful in combination libxayagame's
upcoming support for general "target blocks", see
xaya/libxayagame#130.

Implements #7.
This updates the integration tests to invoke game_sendupdates with explicit
toblock argument, verifying that it works end-to-end (and in particular,
that the RPC server integration works).
domob1812 added a commit to xaya/libxayagame that referenced this pull request Feb 21, 2023
When an explicit target block is set, request game_sendupdates notifications
from Game with that target set as toblock argument.  This ensures that we
can properly sync to the target block, even if it is e.g. in the past.

For this to work if a GSP is connected to Xaya X rather than Xaya Core,
we need xaya/xayax#8.
@domob1812 domob1812 merged commit 16c86fa into master Feb 23, 2023
domob1812 added a commit that referenced this pull request Feb 23, 2023
Support explicit "to" block for game_sendupdates
@domob1812 domob1812 deleted the to-block branch February 23, 2023 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support explicit "to" block in game_sendupdates
1 participant