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

feat: ADR-038: State change indexing with Kafka #2

Closed
wants to merge 29 commits into from
Closed

feat: ADR-038: State change indexing with Kafka #2

wants to merge 29 commits into from

Conversation

egaxhaj
Copy link

@egaxhaj egaxhaj commented Nov 1, 2021

Description

closes: #XXXX

Description

closes: #XXXX

This PR introduces the plugin architecture and an implementation of the StreamingService interface that writes out to Kafka. This work is part of ADR-038

The current implementation writes data out to a single topic with only one partition. This is so we can maintain order of messages. Each message is accompanied by a key that indicates the block number and the type of message.

  • BeginBlock
    • block-{n}-begin-req
    • block-{n}-begin-state-change-{i}
    • block-{n}-begin-res
  • DeliverTx
    • block-{n}-tx-{i}-req
    • block-{n}-tx-{i}-state-change-{i}
    • block-{n}-tx-{i}-res
  • EndBlock
    • block-{n}-end-req
    • block-{n}-end-state-change-{i}
    • block-{n}-end-res

How data is saved to a topic:

partition	offset	key		                value
		
0		0	"block-1-begin-req"		"\u0002\u0012\u0000"
0		1	"block-1-begin-state-change-0" 	"\u0002\u0012\u0000"
0		2	"block-1-begin-state-change-1" 	"\u0002\u0012\u0000"
0		3	"block-1-begin-state-change-2" 	"\u0002\u0012\u0000"
0		4	"block-1-begin-res" 		"\u0002\u0012\u0000"
0		5	"block-1-tx-0-req" 		"\u0002\u0012\u0000"
0		6	"block-1-tx-0-state-change-0" 	"\u0002\u0012\u0000"
0		7	"block-1-tx-0-state-change-1" 	"\u0002\u0012\u0000"
0		8	"block-1-tx-0-res" 		"\u0002\u0012\u0000"
0		9	"block-1-tx-1-req" 		"\u0002\u0012\u0000"
0		10	"block-1-tx-1-state-change-0" 	"\u0002\u0012\u0000"
0		11	"block-1-tx-1-state-change-1" 	"\u0002\u0012\u0000"
0		12	"block-1-tx-1-state-change-2" 	"\u0002\u0012\u0000"
0		13	"block-1-tx-1-state-change-3" 	"\u0002\u0012\u0000"
0		14	"block-1-tx-1-res" 		"\u0002\u0012\u0000"
0		15	"block-1-end-req" 		"\u0002\u0012\u0000"
0		16	"block-1-end-state-change-0" 	"\u0002\u0012\u0000"
0		17	"block-1-end-state-change-1" 	"\u0002\u0012\u0000"
0		18	"block-1-end-res" 		"\u0002\u0012\u0000"

Current Limitations:

ADR-038 - State listening occurs in real time. This push (fire-and-forget) may lead to a degradation in performance when listeners are unable to keep up with events and start to fall behind. In addition, listeners will missed state change events in the following two scenarios:

  • Network failures - Listeners are unable to write state change events when network failures occur.
  • Scheduled downtime.

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

Copy link

@iramiller iramiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good ... one question I have is should the kafka plugin be a default case for these examples or not. A smaller and simplified logger output that goes to trace might be the best for a default case with the file and kafka configurations provided as "commented out alternates" in order to streamline size/complexity...

baseapp/abci.go Show resolved Hide resolved
@@ -276,6 +276,10 @@ func (fss *FileStreamingService) Close() error {
return nil
}

func (fss *FileStreamingService) ListenSuccess() <-chan bool {
panic("implement me")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!!!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making the compiler happy.

@egaxhaj
Copy link
Author

egaxhaj commented Jan 11, 2022

Overall this looks good ... one question I have is should the kafka plugin be a default case for these examples or not. A smaller and simplified logger output that goes to trace might be the best for a default case with the file and kafka configurations provided as "commented out alternates" in order to streamline size/complexity...

That makes sense. I'll work on a plugin that sends it to trace.

@egaxhaj
Copy link
Author

egaxhaj commented Jan 13, 2022

@iramiller Added a trace plugin as the default that logs to stdout. Take a look.

@iramiller
Copy link

That trace listener looks like a great default case for users. The simplest possible test case.

@egaxhaj egaxhaj closed this Mar 31, 2023
@egaxhaj egaxhaj deleted the egaxhaj-figure/kafka branch March 31, 2023 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants