Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
a276412
Implement the RPCBlockHeaderSubscriber for indexing finalized results
m-Peter Jan 21, 2025
7d36012
Rename RPCBlockHeaderSubscriber to RPCBlockTrackingSubscriber
m-Peter Jan 23, 2025
75a1d18
Remove redundant fetching of block header prior to SubscribeBlockHead…
m-Peter Jan 23, 2025
ce83ebb
Improve error handling in RPCBlockTrackingSubscriber subscription
m-Peter Jan 23, 2025
d159467
Simplify RPCBlockTrackingSubscriber by embedding RPCEventSubscriber f…
m-Peter Jan 23, 2025
5e8f388
Optimize RPCBlockTrackingSubscriber to avoid fetch EVM tx events for …
m-Peter Jan 24, 2025
bfe6188
Improve length checks for EVM related events
m-Peter Jan 27, 2025
037c234
Close events channel in RPCBlockTrackingSubscriber
m-Peter Jan 27, 2025
6afde4d
Improve error handling to use the gRPC status code instead of strings
m-Peter Jan 27, 2025
ff927f7
Simplify constructor of RPCBlockTrackingSubscriber
m-Peter Jan 27, 2025
4555263
Remove redundant fields from RPCBlockTrackingSubscriber
m-Peter Jan 27, 2025
34dbde5
Make us of GetEventsForBlockIDs method instead of GetEventsForHeightR…
m-Peter Jan 27, 2025
bf4626c
Add description on RPCBlockTrackingSubscriber type
m-Peter Jan 27, 2025
1f084be
Refactor function for fetching EVM events on a given block header
m-Peter Jan 27, 2025
a8329e4
Make PoC configurable
peterargue Jan 28, 2025
fa39603
fix enabled conditional
peterargue Jan 28, 2025
d68f2ba
Merge pull request #737 from onflow/petera/making-poc-configurable
peterargue Jan 28, 2025
823e965
improve error reconnection handling
peterargue Jan 29, 2025
91b1ec0
Remove redundant start-testnet & start-mainnet make recipes
m-Peter Jan 30, 2025
2ddd052
Merge branch 'main' into mpeter/poc-index-finalized-block-results
peterargue Jan 30, 2025
97f5f93
Merge branch 'main' into mpeter/poc-index-finalized-block-results
peterargue Jan 30, 2025
1e977a9
retry getting events on NotFound and ResourceExhausted
peterargue Feb 3, 2025
f978871
Merge branch 'main' into mpeter/poc-index-finalized-block-results
peterargue Feb 13, 2025
23b4c87
add system to verify soft finality events were eventually sealed
peterargue Feb 15, 2025
d98d8c5
handle case when sealed stream is ahead
peterargue Feb 18, 2025
2f12447
make verification configurable
peterargue Feb 21, 2025
a4766eb
review feedback
peterargue Feb 21, 2025
44aa626
Merge pull request #757 from onflow/petera/add-sealed-data-verification
peterargue Feb 21, 2025
6711c92
Merge branch 'main' into mpeter/poc-index-finalized-block-results
peterargue Feb 21, 2025
219d720
handle verifier reconnects after AN reboot
peterargue Feb 21, 2025
0e90079
Merge branch 'main' into mpeter/poc-index-finalized-block-results
peterargue Mar 5, 2025
fc4ead5
fix whitespace issue from resolving conflicts
peterargue Mar 5, 2025
5d95d07
Check system tx if block is missing EVM block events
peterargue Mar 5, 2025
4b59bcb
update from review feedback
peterargue Mar 5, 2025
d736faf
tidy
peterargue Mar 5, 2025
70674b9
tidy tests
peterargue Mar 5, 2025
7318ee3
Merge branch 'main' into mpeter/poc-index-finalized-block-results
peterargue Mar 7, 2025
f4b1c5f
Merge branch 'mpeter/poc-index-finalized-block-results' into peter/po…
peterargue Mar 7, 2025
ace558d
Updates for new keystore
peterargue Mar 7, 2025
d728f14
add block height to error
peterargue Mar 7, 2025
62f6916
updates to handle system tx failure correctly
peterargue Mar 7, 2025
a4a807f
updates for verifying these blocks
peterargue Mar 7, 2025
e10fbf7
add logging
peterargue Mar 7, 2025
8e04341
make verifier wait for reexecuting data when force-start-height is used
peterargue Mar 7, 2025
1b20a6b
use correct unsealed start height
peterargue Mar 7, 2025
7226a6b
also check sealed heights
peterargue Mar 7, 2025
05b38f2
update to fixed version of sdk
peterargue Mar 8, 2025
7ea340a
fix tidy check
peterargue Mar 8, 2025
fd55071
reduce logging
peterargue Mar 8, 2025
1457b3e
re-add verifier start block
peterargue Mar 12, 2025
0071e40
update to sdk v1.4.0
peterargue Mar 12, 2025
5f04f5e
Merge branch 'main' into mpeter/poc-index-finalized-block-results
peterargue Mar 13, 2025
08373b3
Merge branch 'mpeter/poc-index-finalized-block-results' into peter/po…
peterargue Mar 13, 2025
4bd108e
Merge pull request #771 from onflow/peter/poc-handle-failing-system-tx
peterargue Mar 13, 2025
6826497
Merge branch 'main' into mpeter/poc-index-finalized-block-results
peterargue Mar 13, 2025
1e2a0fd
fix crash when starting ahead of access node
peterargue Mar 13, 2025
f3a5b7f
Update eth_syncing to return false for currentBlock >= highestBlock
peterargue Apr 17, 2025
3ec09b9
Fix panic in debug_traceBlockByNumber when tracer is not set
peterargue Apr 22, 2025
7b1c6f1
Add flag to disable enforcing the minimum gas price
peterargue May 5, 2025
b8c6187
add docs for flag to readme
peterargue May 5, 2025
f8a3eb1
add EnforceGasPrice in testing configs
peterargue May 5, 2025
3d6f09b
Merge pull request #811 from onflow/peter/add-flag-enforce-gas-price-…
peterargue May 6, 2025
c00b0f7
Merge branch 'main' into mpeter/poc-index-finalized-block-results
m-Peter May 7, 2025
b7e6803
Bump flow-go-sdk version to v1.4.0
m-Peter May 8, 2025
f7dc819
Merge branch 'mpeter/poc-index-finalized-block-results' into feature/…
m-Peter May 8, 2025
2fa4139
Merge pull request #816 from onflow/feature/pectra-upgrade-soft-final…
j1010001 May 8, 2025
3400afc
Create ValidationOptions for each tx submission
m-Peter May 8, 2025
f39360d
Merge pull request #819 from onflow/mpeter/fix-pectra-rules-tx-valida…
j1010001 May 8, 2025
a2914c1
Return authorization list for SetCodeTx type
m-Peter May 9, 2025
4398ef5
Add comments to describe the tx type checks in NewTransaction
m-Peter May 12, 2025
092753c
Merge pull request #822 from onflow/mpeter/display-set-code-tx-auth-l…
j1010001 May 12, 2025
5a07802
Merge branch 'mpeter/poc-index-finalized-block-results' into mpeter/b…
m-Peter Jun 23, 2025
644f359
Update to Cadence v1.6.2 & latest flow-go
m-Peter Jun 25, 2025
9364624
Merge pull request #833 from onflow/mpeter/batch-run-transactions-bac…
m-Peter Jun 25, 2025
34f6efd
Merge pull request #843 from onflow/mpeter/soft-finality-sync-with-main
m-Peter Jul 14, 2025
d36af20
Merge remote-tracking branch 'origin/main' into mpeter/soft-finality-…
m-Peter Jul 18, 2025
71e1ce8
Update RPCBlockTrackingSubscriber to use the new API for NotifyBlock
m-Peter Jul 18, 2025
e4cd73c
Merge remote-tracking branch 'origin/main' into mpeter/soft-finality-…
m-Peter Jul 21, 2025
88e6d7e
Merge pull request #848 from onflow/mpeter/soft-finality-sync-with-main
peterargue Jul 21, 2025
cfa6656
Give blocks a chance to become sealed before calling NotifyBlock
m-Peter Jul 23, 2025
7575806
Merge pull request #850 from onflow/mpeter/update-notify-block-logic
m-Peter Jul 23, 2025
8b80fd0
Give blocks a better chance to become sealed before calling NotifyBlock
m-Peter Jul 24, 2025
6f5b3c9
Merge pull request #853 from onflow/mpeter/update-notify-block-logic
m-Peter Jul 25, 2025
a93abf0
Merge remote-tracking branch 'origin/main' into mpeter/soft-finality-…
m-Peter Jul 25, 2025
bcb027f
Merge pull request #854 from onflow/mpeter/soft-finality-sync-with-main
peterargue Jul 25, 2025
ed3f17b
Merge remote-tracking branch 'origin/main' into mpeter/sync-soft-fina…
m-Peter Aug 21, 2025
f51de72
Replace onflow/go-ethereum with ethereum/go-ethereum
m-Peter Aug 21, 2025
965b10b
Merge remote-tracking branch 'origin/main' into mpeter/sync-soft-fina…
m-Peter Aug 22, 2025
fed891a
Merge pull request #869 from onflow/mpeter/sync-soft-finality-with-main
m-Peter Aug 25, 2025
a8f7437
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Sep 11, 2025
eab1a53
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Sep 11, 2025
e3d06a2
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Sep 12, 2025
108e232
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Sep 17, 2025
efd12b0
Merge pull request #882 from onflow/mpeter/bump-flow-go-version-soft-…
m-Peter Sep 17, 2025
a404eab
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Sep 22, 2025
733be55
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Sep 22, 2025
fffd7f8
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Oct 1, 2025
6552a69
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Oct 20, 2025
e302a12
Merge pull request #905 from onflow/mpeter/soft-finality-update-flow-go
m-Peter Oct 20, 2025
60caf94
Handle missing evm block in spork root block
peterargue Oct 20, 2025
c754eb7
verify events even for spork root block
peterargue Oct 20, 2025
ec1385e
add support for backfilling past spork blocks in sealing verifier
peterargue Oct 21, 2025
cb7f210
verify backfilled blocks
peterargue Oct 21, 2025
5e17b0b
delete stored hashes during force start height
peterargue Oct 21, 2025
5c97d88
Merge pull request #908 from onflow/peter/fix-spork-root-sf
peterargue Oct 22, 2025
2862171
Merge remote-tracking branch 'origin/main' into mpeter/poc-index-fina…
m-Peter Oct 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ e2e-test:

.PHONY: check-tidy
check-tidy:
go mod tidy
git diff --exit-code
cd tests
go mod tidy
go mod tidy -v
cd tests; go mod tidy -v
git diff --exit-code

.PHONY: build
Expand Down
57 changes: 48 additions & 9 deletions bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Storages struct {
Transactions storage.TransactionIndexer
Receipts storage.ReceiptIndexer
Traces storage.TraceIndexer
EventsHash *pebble.EventsHash
}

type Publishers struct {
Expand Down Expand Up @@ -159,14 +160,37 @@ func (b *Bootstrap) StartEventIngestion(ctx context.Context) error {
nextCadenceHeight -= 1
}

// create EVM event subscriber
subscriber := ingestion.NewRPCEventSubscriber(
b.logger,
b.client,
chainID,
b.keystore,
nextCadenceHeight,
)
// create event subscriber
var subscriber ingestion.EventSubscriber
if b.config.ExperimentalSoftFinalityEnabled {
var verifier *ingestion.SealingVerifier
if b.config.ExperimentalSealingVerificationEnabled {
verifier = ingestion.NewSealingVerifier(
b.logger,
b.client,
chainID,
b.storages.EventsHash,
nextCadenceHeight,
)
}

subscriber = ingestion.NewRPCBlockTrackingSubscriber(
b.logger,
b.client,
chainID,
b.keystore,
nextCadenceHeight,
verifier,
)
} else {
subscriber = ingestion.NewRPCEventSubscriber(
b.logger,
b.client,
chainID,
b.keystore,
nextCadenceHeight,
)
}

callTracerCollector, err := replayer.NewCallTracerCollector(
b.config.EVMNetworkID,
Expand Down Expand Up @@ -586,6 +610,7 @@ func setupStorage(
blocks := pebble.NewBlocks(store, config.FlowNetworkID)
storageAddress := evm.StorageAccountAddress(config.FlowNetworkID)
registerStore := pebble.NewRegisterStorage(store, storageAddress)
eventsHash := pebble.NewEventsHash(store)

batch := store.NewBatch()
defer func() {
Expand All @@ -600,7 +625,20 @@ func setupStorage(
if config.ForceStartCadenceHeight != 0 {
logger.Warn().Uint64("height", config.ForceStartCadenceHeight).Msg("force setting starting Cadence height!!!")
if err := blocks.SetLatestCadenceHeight(config.ForceStartCadenceHeight, batch); err != nil {
return nil, nil, err
return nil, nil, fmt.Errorf("failed to set latest cadence height: %w", err)
}

verifiedHeight, err := eventsHash.ProcessedSealedHeight()
if err != nil && !errors.Is(err, errs.ErrStorageNotInitialized) {
return nil, nil, fmt.Errorf("failed to get latest verified sealed height: %w", err)
}
if verifiedHeight > config.ForceStartCadenceHeight {
if err := eventsHash.BatchSetProcessedSealedHeight(config.ForceStartCadenceHeight, batch); err != nil {
return nil, nil, fmt.Errorf("failed to set latest verified sealed height: %w", err)
}
}
if err := eventsHash.BatchRemoveAboveHeight(config.ForceStartCadenceHeight, batch); err != nil {
return nil, nil, fmt.Errorf("failed to reset events hash above height: %w", err)
}
}

Expand Down Expand Up @@ -665,6 +703,7 @@ func setupStorage(
Transactions: pebble.NewTransactions(store),
Receipts: pebble.NewReceipts(store),
Traces: pebble.NewTraces(store),
EventsHash: eventsHash,
}, nil
}

Expand Down
8 changes: 8 additions & 0 deletions cmd/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ func parseConfigFromFlags() error {
return fmt.Errorf("tx-batch-mode should be enabled with tx-state-validation=local-index")
}

cfg.ExperimentalSoftFinalityEnabled = experimentalSoftFinalityEnabled
cfg.ExperimentalSealingVerificationEnabled = experimentalSealingVerificationEnabled

return nil
}

Expand All @@ -250,6 +253,9 @@ var (
txStateValidation string
initHeight,
forceStartHeight uint64

experimentalSoftFinalityEnabled,
experimentalSealingVerificationEnabled bool
)

func init() {
Expand Down Expand Up @@ -290,6 +296,8 @@ func init() {
Cmd.Flags().DurationVar(&cfg.TxRequestLimitDuration, "tx-request-limit-duration", time.Second*3, "Time interval upon which to enforce transaction submission rate limiting.")
Cmd.Flags().BoolVar(&cfg.TxBatchMode, "tx-batch-mode", false, "Enable batch transaction submission, to avoid nonce mismatch issues for high-volume EOAs.")
Cmd.Flags().DurationVar(&cfg.TxBatchInterval, "tx-batch-interval", time.Millisecond*1200, "Time interval upon which to submit the transaction batches to the Flow network.")
Cmd.Flags().BoolVar(&experimentalSoftFinalityEnabled, "experimental-soft-finality-enabled", false, "Sets whether the gateway should use the experimental soft finality feature. WARNING: This may result in incorrect results being returned in certain circumstances. Use only if you know what you are doing.")
Cmd.Flags().BoolVar(&experimentalSealingVerificationEnabled, "experimental-sealing-verification-enabled", true, "Sets whether the gateway should use the experimental soft finality sealing verification feature. WARNING: This may result in indexing halts if events do not match. Use only if you know what you are doing.")
Comment on lines +299 to +300
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Consider adjusting the default value for the sealing verification flag.

The experimentalSealingVerificationEnabled flag is set to true by default, but the warning indicates it may result in indexing halts if events don't match. For experimental features with potential operational impacts, it's generally safer to default to the more conservative option (false) and require users to explicitly opt-in.

This is especially important since the PR is implementing a new subscriber for indexing finalized results, and unexpected halts could impact service reliability.

-Cmd.Flags().BoolVar(&experimentalSealingVerificationEnabled, "experimental-sealing-verification-enabled", true, "Sets whether the gateway should use the experimental soft finality sealing verification feature. WARNING: This may result in indexing halts if events do not match. Use only if you know what you are doing.")
+Cmd.Flags().BoolVar(&experimentalSealingVerificationEnabled, "experimental-sealing-verification-enabled", false, "Sets whether the gateway should use the experimental soft finality sealing verification feature. WARNING: This may result in indexing halts if events do not match. Use only if you know what you are doing.")

🏁 Script executed:

#!/bin/bash
# Check how these flags are used in the bootstrap code

echo "Checking how experimental flags are used in bootstrap code"
cd ..
rg -A 10 "ExperimentalSoftFinalityEnabled" bootstrap/ || echo "No direct usage found in bootstrap directory"

Length of output: 338


Action: Change the default for experimentalSealingVerificationEnabled to false to avoid unintended indexing halts.

The current default value of true (in cmd/run/cmd.go:292-293) risks triggering indexing halts if events don’t match. Since our check in the bootstrap directory didn’t reveal any special handling for this flag, it makes sense to default to the more conservative option. This change ensures that users must explicitly enable the experimental sealing verification feature—and thus accept its potential operational impacts—rather than inadvertently opting into a risky behavior with production consequences.

  • Location: cmd/run/cmd.go (Lines 292-293)
  • Suggested Diff:
    -Cmd.Flags().BoolVar(&experimentalSealingVerificationEnabled, "experimental-sealing-verification-enabled", true, "Sets whether the gateway should use the experimental soft finality sealing verification feature. WARNING: This may result in indexing halts if events do not match. Use only if you know what you are doing.")
    +Cmd.Flags().BoolVar(&experimentalSealingVerificationEnabled, "experimental-sealing-verification-enabled", false, "Sets whether the gateway should use the experimental soft finality sealing verification feature. WARNING: This may result in indexing halts if events do not match. Use only if you know what you are doing.")

Please update the default flag accordingly to improve operational safety when the new subscriber for indexing finalized results is active.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Cmd.Flags().BoolVar(&experimentalSoftFinalityEnabled, "experimental-soft-finality-enabled", false, "Sets whether the gateway should use the experimental soft finality feature. WARNING: This may result in incorrect results being returned in certain circumstances. Use only if you know what you are doing.")
Cmd.Flags().BoolVar(&experimentalSealingVerificationEnabled, "experimental-sealing-verification-enabled", true, "Sets whether the gateway should use the experimental soft finality sealing verification feature. WARNING: This may result in indexing halts if events do not match. Use only if you know what you are doing.")
Cmd.Flags().BoolVar(&experimentalSoftFinalityEnabled, "experimental-soft-finality-enabled", false, "Sets whether the gateway should use the experimental soft finality feature. WARNING: This may result in incorrect results being returned in certain circumstances. Use only if you know what you are doing.")
Cmd.Flags().BoolVar(&experimentalSealingVerificationEnabled, "experimental-sealing-verification-enabled", false, "Sets whether the gateway should use the experimental soft finality sealing verification feature. WARNING: This may result in indexing halts if events do not match. Use only if you know what you are doing.")

Cmd.Flags().DurationVar(&cfg.EOAActivityCacheTTL, "eoa-activity-cache-ttl", time.Second*10, "Time interval used to track EOA activity. Tx send more frequently than this interval will be batched. Useful only when batch transaction submission is enabled.")

err := Cmd.Flags().MarkDeprecated("init-cadence-height", "This flag is no longer necessary and will be removed in future version. The initial Cadence height is known for testnet/mainnet and this was only required for fresh deployments of EVM Gateway. Once the DB has been initialized, the latest index Cadence height will be used upon start-up.")
Expand Down
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ type Config struct {
// TxBatchInterval is the time interval upon which to submit the transaction batches to the
// Flow network.
TxBatchInterval time.Duration
// ExperimentalSoftFinalityEnabled enables the experimental soft finality feature which syncs
// EVM block and transaction data from the upstream Access node before the block is sealed.
// CAUTION: This feature is experimental and may return incorrect data in certain circumstances.
ExperimentalSoftFinalityEnabled bool
// ExperimentalSealingVerificationEnabled enables the experimental sealing verification feature
// which verifies the hash of the EVM events ingested by the requester engine match the hash
// of the events from the sealed block in the Flow network.
// CAUTION: This feature is experimental and will cause the node to halt if the events don't match.
ExperimentalSealingVerificationEnabled bool
// EOAActivityCacheTTL is the time interval used to track EOA activity. Tx send more
// frequently than this interval will be batched.
// Useful only when batch transaction submission is enabled.
Expand Down
5 changes: 5 additions & 0 deletions models/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ func decodeCadenceEvents(events flow.BlockEvents) (*CadenceEvents, error) {
return e, nil
}

// BlockEvents returns the Flow block events.
func (c *CadenceEvents) BlockEvents() flow.BlockEvents {
return c.events
}

// Block evm block. If event doesn't contain EVM block the return value is nil.
func (c *CadenceEvents) Block() *Block {
return c.block
Expand Down
Loading