Skip to content

Conversation

@winder
Copy link
Collaborator

@winder winder commented Oct 7, 2025

The go-ethereum hash function we need is a trivial wrapper around standard go libraries. Use them directly rather than calling into go-ethereum.

@winder winder force-pushed the will/no-evm-hasher branch 2 times, most recently from b194d49 to 3e87205 Compare October 7, 2025 17:36
h.Write(data) //nolint:revive // keccak256 never returns an error
var out [32]byte
copy(out[:], h.Sum(nil))
h.Reset()
Copy link
Contributor

@0xAustinWang 0xAustinWang Oct 9, 2025

Choose a reason for hiding this comment

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

is this h.reset necessary? We already reset right before usage on line 24

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point. The pool is private, so there's no benefit to the extra caution.

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

Metric will/no-evm-hasher main
aggregator Coverage 47.1% 47.1%

@0xAustinWang
Copy link
Contributor

CI failing, but will approve after

Comment on lines +10 to +14
var hasherPool = sync.Pool{
New: func() any {
return sha3.NewLegacyKeccak256()
},
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It lets you reuse the keccak objects instead of reallocating them every time. I'll add a benchmark, now I'm curious how impactful it is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looks like object pooling improves things from 378ns -> 251.2ns. I tested with different inputs, and it seems to be a fixed ~100ns overhead for object allocation with the total duration going up based on the input data size.

goos: linux
goarch: amd64
pkg: github.com/smartcontractkit/chainlink-ccv/protocol
cpu: 13th Gen Intel(R) Core(TM) i9-13900HX
BenchmarkHashing
BenchmarkHashing-32            	 4575128	       251.2 ns/op
BenchmarkHashinbBaseline
BenchmarkHashinbBaseline-32    	 2765898	       378.0 ns/op
PASS

@winder winder force-pushed the will/no-evm-hasher branch from fdffd2c to 085ba4d Compare October 22, 2025 16:06
@github-actions
Copy link

E2E Smoke Test Results

Test Case Status Duration
TestE2ESmoke/test_extra_args_v2_messages/src->dst_msg_execution_eoa_receiver pass 9.22s
TestE2ESmoke/test_extra_args_v2_messages/dst->src_msg_execution_eoa_receiver pass 9.72s
TestE2ESmoke/test_extra_args_v2_messages/1337->3337_msg_execution_mock_receiver pass 9.72s
TestE2ESmoke/test_extra_args_v2_messages pass 28.65s
TestE2ESmoke/test_extra_args_v3_messages/src_dst_msg_execution_with_EOA_receiver pass 10.22s
TestE2ESmoke/test_extra_args_v3_messages/dst_src_msg_execution_with_EOA_receiver pass 9.72s
TestE2ESmoke/test_extra_args_v3_messages/1337->3337_msg_execution_with_EOA_receiver pass 11.22s
TestE2ESmoke/test_extra_args_v3_messages/src_dst_msg_execution_with_mock_receiver pass 9.72s
TestE2ESmoke/test_extra_args_v3_messages/dst_src_msg_execution_with_mock_receiver pass 10.22s
TestE2ESmoke/test_extra_args_v3_messages/src_dst_msg_execution_with_EOA_receiver_and_token_transfer pass 9.72s
TestE2ESmoke/test_extra_args_v3_messages pass 60.81s
TestE2ESmoke pass 89.65s

Full logs are available in the workflow artifacts.

@github-actions
Copy link

Code coverage report:

Package main will/no-evm-hasher
aggregator 49.61% 49.61%
cciptestinterfaces 100.00% 100.00%
ccv-evm 0.00% 0.00%
cmd 0.00% 0.00%
executor 34.46% 34.46%
indexer 25.39% 33.56%
integration 4.63% 4.63%
protocol 45.50% 45.88%
verifier 41.72% 41.72%

@winder winder marked this pull request as ready for review October 22, 2025 16:32
@winder winder requested review from a team and skudasov as code owners October 22, 2025 16:32
@winder winder enabled auto-merge (squash) October 22, 2025 16:33
@winder winder disabled auto-merge October 22, 2025 16:33
@winder winder enabled auto-merge (squash) October 22, 2025 16:33
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.

3 participants