Skip to content

Adding Event Index Sequence checking to UTs#3386

Merged
bors[bot] merged 3 commits intomasterfrom
tonyz/add_ut_event_index
Oct 17, 2022
Merged

Adding Event Index Sequence checking to UTs#3386
bors[bot] merged 3 commits intomasterfrom
tonyz/add_ut_event_index

Conversation

@Tonix517
Copy link
Contributor

@Tonix517 Tonix517 commented Oct 13, 2022

Adding new checking in UT cases to make sure numbers in event index sequence are unique and increasing. As a follow-up to #3371 (review)

changes to FVM and execution computer UT are split into separate commits.

for _, event := range events {
require.Equal(t, expectedEventIndex, event.EventIndex)
if testutil.IsServiceEvent(event, chainID) {
expectedEventIndex += 2
Copy link
Contributor Author

@Tonix517 Tonix517 Oct 13, 2022

Choose a reason for hiding this comment

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

In our code at https://github.com/onflow/flow-go/blob/master/fvm/environment/event_emitter.go#L154-L155, for service events we do double counting (original behavior), so the event after one service event will have index as +2.
However if AppendServiceEvent() fails and AppendEvent() is skipped, then if EmitEvent() is called again, we can continue to have unique index values. If this use case can happen, we may want to keep the existing extra counting for service events.

Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a bug. Can you open an issue for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filed #3393

@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2022

FVM Benchstat comparison

This branch with compared with the base branch onflow:master commit bba471c

The command (for i in {1..10}; do go test ./fvm ./engine/execution/computation --bench . --tags relic -shuffle=on --benchmem --run ^$; done) was used.

Collapsed results for better readability

old.txtnew.txt
time/opdelta
ComputeBlock/16/cols/128/txes-24.53s ± 0%4.68s ± 0%~(p=1.000 n=1+1)
 
us/txdelta
ComputeBlock/16/cols/128/txes-22.21k ± 0%2.28k ± 0%~(p=1.000 n=1+1)
 
alloc/opdelta
ComputeBlock/16/cols/128/txes-21.27GB ± 0%1.29GB ± 0%~(p=1.000 n=1+1)
 
allocs/opdelta
ComputeBlock/16/cols/128/txes-219.9M ± 0%19.9M ± 0%~(p=1.000 n=1+1)
 

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2022

Codecov Report

Merging #3386 (d2b46d5) into master (ed91c80) will decrease coverage by 6.81%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3386      +/-   ##
==========================================
- Coverage   55.45%   48.64%   -6.82%     
==========================================
  Files         746      163     -583     
  Lines       67984    14297   -53687     
==========================================
- Hits        37703     6955   -30748     
+ Misses      27222     6907   -20315     
+ Partials     3059      435    -2624     
Flag Coverage Δ
unittests 48.64% <ø> (-6.82%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
fvm/transactionInvoker.go 56.52% <0.00%> (-4.23%) ⬇️
...s/hotstuff/votecollector/staking_vote_processor.go 83.87% <0.00%> (-3.23%) ⬇️
consensus/hotstuff/eventloop/event_loop.go 73.46% <0.00%> (-1.37%) ⬇️
fvm/environment/env.go 100.00% <0.00%> (ø)
admin/commands/storage/helper.go 78.00% <0.00%> (ø)
storage/badger/headers.go
network/channels/channel.go
ledger/complete/ledger.go
cmd/verification_builder.go
storage/badger/seals.go
... and 586 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@janezpodhostnik janezpodhostnik left a comment

Choose a reason for hiding this comment

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

Nice!

for _, event := range events {
require.Equal(t, expectedEventIndex, event.EventIndex)
if testutil.IsServiceEvent(event, chainID) {
expectedEventIndex += 2
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a bug. Can you open an issue for it?

}
}

func ensureEventsIndexSeq(t *testing.T, events []flow.Event, chainID flow.ChainID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you're duplicating these two functions. maybe add it to a shared testutil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed.

Copy link
Contributor

@pattyshack pattyshack left a comment

Choose a reason for hiding this comment

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

see my duplicated code comment, but otherwise i don't have issues with this

@Tonix517 Tonix517 force-pushed the tonyz/add_ut_event_index branch from d2b46d5 to 2388999 Compare October 17, 2022 17:01
@Tonix517 Tonix517 force-pushed the tonyz/add_ut_event_index branch from 2388999 to f21e39a Compare October 17, 2022 17:23
@Tonix517
Copy link
Contributor Author

bors merge

@Tonix517
Copy link
Contributor Author

will merge it first and treat #3393 as a separate fix in future PR

@bors bors bot merged commit 1bc1cb0 into master Oct 17, 2022
@bors bors bot deleted the tonyz/add_ut_event_index branch October 17, 2022 17:58
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