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

how to let client side know the fork activity with this framework #22

Closed
crazybits opened this issue Nov 5, 2018 · 6 comments
Closed

Comments

@crazybits
Copy link

when demux detect the fork block, any way to get the required infor?

@chris-allnutt
Copy link

In the specific implementation, Postgres, for instance, you can look at the rollback functionality that occurs when a fork has occurred. Going to mention @flux627 he will know if we store any state data in the event of a fork to reference that it happened.

@crazybits
Copy link
Author

crazybits commented Nov 5, 2018

@chris-allnutt ,thanks ,follow your advice to debug,seems the rollback can only get the fallback block number, can we get the full block, include the producer infor?

@flux627
Copy link
Contributor

flux627 commented Nov 5, 2018

What's the use-case?

@crazybits
Copy link
Author

@flux627 we would like to know which producer cause the fork, this infor could help producer to self-check their bp node.

@fallshuang
Copy link

@flux627 we would like to know which producer cause the fork, this infor could help producer to self-check their bp node.

I got a fork issue just now , this is the output of my demux-eos program :

26101980 - 018e48dc92695aea1705f9321180969759db4dd2b40299a7e6410e97f7dedecf - Fri Nov 09 2018 22:01:04 GMT-0500 (EST)
26101981 - 018e48dd9a1f0ef227a8f3271435718c02d61086dd0d2944a51854f7a0d20efd - Fri Nov 09 2018 22:01:04 GMT-0500 (EST)
26101982 - 018e48de6919beaadce5ca538515f5caeed4ce7914ced2880a7b2cba272b27a5 - Fri Nov 09 2018 22:01:05 GMT-0500 (EST)
26101983 - 018e48df2cb8f354f41598c193cf44f836a4feed2121f3a0f1c169b4b450f0b1 - Fri Nov 09 2018 22:01:05 GMT-0500 (EST)
!! FORK DETECTED !!
MISMATCH:
✓ NEW Block 26101984 previous: 018e48df11abcf1db5213200d798a3081ab298523305dc87c901059d8edc093b
✕ OLD Block 26101983 id: 018e48df2cb8f354f41598c193cf44f836a4feed2121f3a0f1c169b4b450f0b1
Refetching Block 26101983...
MISMATCH:
✓ NEW Block 26101983 previous: 018e48de46439e4341b05c702160be32b6f34d1fd97a7a51e4aa299ad7342ae6
✕ OLD Block 26101982 id: 018e48de6919beaadce5ca538515f5caeed4ce7914ced2880a7b2cba272b27a5
Refetching Block 26101982...
MATCH:
✓ NEW Block 26101982 previous: 018e48dd9a1f0ef227a8f3271435718c02d61086dd0d2944a51854f7a0d20efd
✓ OLD Block 26101981 id: 018e48dd9a1f0ef227a8f3271435718c02d61086dd0d2944a51854f7a0d20efd
!! FORK RESOLVED !!
26101982 - 018e48de46439e4341b05c702160be32b6f34d1fd97a7a51e4aa299ad7342ae6 - Fri Nov 09 2018 22:01:06 GMT-0500 (EST)
Rolling back 2 blocks to block 26101981...
(node:19478) UnhandledPromiseRejectionWarning: TypeError: this.rollbackTo is not a function
at ObjectActionHandler. (/home/falls/work/eos-gserv/node_modules/_demux@2.0.0@demux/dist/AbstractActionHandler.js:34:28)
at Generator.next ()
at /home/falls/work/eos-gserv/node_modules/_demux@2.0.0@demux/dist/AbstractActionHandler.js:7:71
at new Promise ()
at __awaiter (/home/falls/work/eos-gserv/node_modules/_demux@2.0.0@demux/dist/AbstractActionHandler.js:3:12)
at ObjectActionHandler.handleBlock (/home/falls/work/eos-gserv/node_modules/_demux@2.0.0@demux/dist/AbstractActionHandler.js:28:16)
at ObjectActionHandler.handleBlock (/home/falls/work/eos-gserv/ObjectActionHandler.js:21:18)
at BaseActionWatcher. (/home/falls/work/eos-gserv/node_modules/_demux@2.0.0@demux/dist/BaseActionWatcher.js:59:75)
at Generator.next ()
at fulfilled (/home/falls/work/eos-gserv/node_modules/_demux@2.0.0@demux/dist/BaseActionWatcher.js:4:58)
(node:19478) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:19478) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@flux627
Copy link
Contributor

flux627 commented Dec 4, 2018

@crazybits Sorry on the delayed reply. I think this functionality might be outside the scope of what Demux is made for- accumulating state based on blockchain events. Forks are not really events. Forks change what the events are (from the perspective of Demux), but are not events themselves.

That said, you could do this via Effects. Create a new ActionReader that emits a newblock action at the beginning of every block that contains your required information, and subscribe an effect that saves this information somewhere. If you ever get repeat blocks, you know there was a rollback and can analyze accordingly.

Closing this, but feel free to continue the conversation with any followup questions.

@flux627 flux627 closed this as completed Dec 4, 2018
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

No branches or pull requests

4 participants