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

Modify the gRPC interface to start including streaming block ranges #173

Open
3 tasks
linuskendall opened this issue Oct 17, 2024 · 3 comments
Open
3 tasks
Assignees

Comments

@linuskendall
Copy link
Contributor

  • subscribe on block from block A to block N
  • filter blocks by account mention
  • subscribe to transactions from slot A to slot N
@linuskendall
Copy link
Contributor Author

Lets try to follow as closely as we can to the dragon's mouth API:
https://docs.triton.one/project-yellowstone/dragons-mouth-grpc-subscriptions#subscribe-to-blocks

methods could be:

streamBlocks
streamTransactions (this will need a filter)

@anjor anjor mentioned this issue Oct 22, 2024
@anjor
Copy link
Contributor

anjor commented Nov 6, 2024

if stream blocks looks good i can open similar PR for streamTransactions

@linuskendall
Copy link
Contributor Author

linuskendall commented Nov 7, 2024

streamTransactions:

message SubscribeRequestFilterTransactions {
  optional bool vote = 1;
  optional bool failed = 2;
  repeated string account_include = 3;
  repeated string account_exclude = 4;
  repeated string account_required = 6;
}

For the accounts filters:

For transactions, if all fields are empty, then all transactions are broadcasted. Otherwise, fields work as logical AND, and values in arrays as logical OR. You can include/exclude vote transactions and include/exclude failed transactions.

If account_include is not specified, then iterate through all the blocks and return every transaction that doesn't mention account_exclude and that match vote/failed filter.

If account_include is specified, then lookup in the get-signatures-for-address index to get all the signature+slot combos and then start reading these transactions one by one, applying the other filters account_exclude, account_include.

To be able to do this we need to :


	gsfaIndexes, _ := multi.getGsfaReadersInEpochDescendingOrder(startSlot, endSlot)
	if len(gsfaIndexes) == 0 {
		return &jsonrpc2.Error{
			Code:    jsonrpc2.CodeInternalError,
			Message: "getSignaturesForAddress method is not enabled",
		}, fmt.Errorf("no gsfa indexes found")
	}

	gsfaMulti, err := gsfa.NewGsfaReaderMultiepoch(gsfaIndexes)
	if err != nil {
		return &jsonrpc2.Error{
			Code:    jsonrpc2.CodeInternalError,
			Message: "Internal error",
		}, fmt.Errorf("failed to create gsfa multiepoch reader: %w", err)
	}

      	foundTransactions, err := gsfaMulti.GetSlotRange(
		ctx,
		pk,
		limit,
		startSlot,
		endSlot,
       )

Remember:

  • We will get transactions going backwards

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

3 participants