Skip to content

Conversation

@fbac
Copy link
Collaborator

@fbac fbac commented Jul 29, 2025

Add batch publishing methods BootstrapGroupMessages and BootstrapIdentityUpdates to BlockchainPublisher for publishing multiple messages in single transactions

  • Adds BootstrapGroupMessages and BootstrapIdentityUpdates methods to BlockchainPublisher enabling batch publishing of multiple group messages or identity updates in single blockchain transactions
  • Replaces findLog function with findLogs function that returns multiple logs and validates expected event counts with new ErrNoLogsFound error handling
  • Modifies existing PublishGroupMessage and PublishIdentityUpdate methods to use the new findLogs function and updates callback return types in withNonce to support slices
  • Adds comprehensive test coverage for new batch operations in blockchainPublisher_test.go with error handling validation for various scenarios

📍Where to Start

Start with the new BootstrapGroupMessages and BootstrapIdentityUpdates methods in blockchainPublisher.go to understand the batch publishing functionality.

Changes since #998 opened

  • Relocated log count validation from findLogs function to individual publisher methods [a481e8f]
  • Added capacity hint to slice initialization in findLogs function [a481e8f]

Macroscope summarized a481e8f.

@fbac fbac requested a review from a team as a code owner July 29, 2025 10:16
@graphite-app
Copy link

graphite-app bot commented Jul 29, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • Queue - adds this PR to the back of the merge queue
  • Hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

return logs[0], nil
}

func (m *BlockchainPublisher) BootstrapGroupMessages(
Copy link
Contributor

Choose a reason for hiding this comment

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

With multiple messages it becomes easier for us to exceed the limits on a single tx. Are we planning some mechanism to break up multiple payloads into smaller chunks if we get errors there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I plan to use this function to bootstrap one message at a time. Initially I don't think we need to batch anything and risk reverting tx's.

The amount of messages to backfill can be easily migrated in a few days, and then the migrator would continue pulling these on the fly.

If down the road we're confident this can be used with batches then I'll modify it to guarantee the data published in the batch is not bigger than the max data a tx can hold.

Copy link
Contributor

Choose a reason for hiding this comment

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

Glad I asked. That makes sense

return nil, err
}

return logs[0], nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

make sure the size is at least 1. Otherwise this will segfault. if len(logs) != 1

parseFunc func(types.Log) (*T, error),
expectedEventCount int,
) ([]*T, error) {
events := make([]*T, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

pre-allocate the right size here?

return nil, err
}

return logs[0], nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

same. Make sure to check the array size before accessing by index.

@fbac fbac merged commit 9713b86 into main Jul 31, 2025
10 checks passed
@fbac fbac deleted the 07-29-blockchain_publisher_bootstrapper branch July 31, 2025 08:08
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.

4 participants