Skip to content

Fake EVM - check if log filters match#21771

Merged
ibrajer merged 6 commits intodevelopfrom
fake-evm/log-triggers
Mar 31, 2026
Merged

Fake EVM - check if log filters match#21771
ibrajer merged 6 commits intodevelopfrom
fake-evm/log-triggers

Conversation

@tarcisiozf
Copy link
Copy Markdown
Contributor

@tarcisiozf tarcisiozf commented Mar 30, 2026

DEVSVCS-2932

This pull request enhances the FakeEVMChain in the testing fakes for EVM capabilities by adding support for log trigger filters that closely mirror production log filtering semantics. The main improvements ensure that manual log triggers are only processed if they match the registered filter, providing more realistic and robust test behavior.

@tarcisiozf tarcisiozf requested review from a team as code owners March 30, 2026 12:03
Copilot AI review requested due to automatic review settings March 30, 2026 12:03
@github-actions
Copy link
Copy Markdown
Contributor

👋 tarcisiozf, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 30, 2026

✅ No conflicts with other open PRs targeting develop

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Risk Rating: MEDIUM (test-fake behavior change + potential concurrency hazards around trigger registration/unregistration)

Enhances FakeEVMChain’s manual log trigger behavior so that emitted logs are only delivered to consumers when they match the filter registered for the trigger, aligning test semantics more closely with production log filtering.

Changes:

  • Store the FilterLogTriggerRequest used at RegisterLogTrigger time and consult it during ManualTrigger.
  • Add fakeEVMLogMatchesFilter to apply address/topic matching semantics before emitting a manual trigger.
  • Delete stored trigger state on UnregisterLogTrigger.
Comments suppressed due to low confidence (1)

core/capabilities/fakes/evm_chain.go:264

  • ManualTrigger sends on fc.callbackCh[triggerID] without checking that a trigger was registered (or that it hasn’t been unregistered). If the key is missing, the lookup yields a nil channel and the goroutine will block forever; if Unregister deletes concurrently it can also race/panic. Fetch the channel (and filter) once (ideally under the same lock as Register/Unregister), return an error when triggerID is unknown, and use the captured channel inside the goroutine.
func (fc *FakeEVMChain) ManualTrigger(ctx context.Context, triggerID string, log *evmcappb.Log) error {
	fc.eng.Debugf("ManualTrigger: %s", log.String())

	if filter, ok := fc.logTriggerFilters[triggerID]; ok && filter != nil {
		if !fakeEVMLogMatchesFilter(log, filter) {
			return fmt.Errorf("log does not match registered filter for trigger %s: address or topic mismatch", triggerID)
		}
	}

	go func() {
		select {
		case fc.callbackCh[triggerID] <- fc.createManualTriggerEvent(log):
			// Successfully sent trigger response

Comment thread core/capabilities/fakes/evm_chain.go
Comment thread core/capabilities/fakes/evm_chain.go
@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Mar 30, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@tarcisiozf tarcisiozf requested review from a team as code owners March 30, 2026 14:16
ibrajer
ibrajer previously approved these changes Mar 31, 2026
Comment thread core/capabilities/fakes/evm_chain.go Outdated
Comment thread core/capabilities/fakes/evm_chain.go Outdated
@tarcisiozf tarcisiozf force-pushed the fake-evm/log-triggers branch from ceb98bc to cbdf764 Compare March 31, 2026 16:02
@cl-sonarqube-production
Copy link
Copy Markdown

@ibrajer ibrajer added this pull request to the merge queue Mar 31, 2026
Merged via the queue into develop with commit 9a1136d Mar 31, 2026
289 of 293 checks passed
@ibrajer ibrajer deleted the fake-evm/log-triggers branch March 31, 2026 19:19
@Galaxysurfer2034
Copy link
Copy Markdown

Galaxysurfer2034 commented Mar 31, 2026 via email

prashantkumar1982 pushed a commit that referenced this pull request Apr 2, 2026
* check if log filters match

* changeset

* use errors instead of bools

* check topic0

* add test cases

* fix lint
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.

5 participants