Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recovery of cairo0 hash logic #1470

Merged
merged 14 commits into from
Dec 4, 2023
Merged

Conversation

kirugan
Copy link
Contributor

@kirugan kirugan commented Nov 27, 2023

No description provided.

@kirugan kirugan force-pushed the kirugan/revert-cairo0-hash-logic branch from df9f0ad to d84b5b5 Compare November 27, 2023 12:16
@omerfirmak
Copy link
Contributor

To sanity check the changes here, can you enable Cairo0 class verification in syncing and start a fresh sync? You need to modify VerifyClassHashes

func VerifyClassHashes(classes map[felt.Felt]Class) error {
	for hash, class := range classes {
		cairo1Class, ok := class.(*Cairo1Class)
		// cairo0 classes are deprecated and hard to verify their hash, just ignore them
		if !ok {
			return nil
		}

		cHash := cairo1Class.Hash()
		if !cHash.Equal(&hash) {
			return fmt.Errorf("cannot verify class hash: calculated hash %v, received hash %v", cHash.String(), hash.String())
		}
	}
	return nil
}

@omerfirmak
Copy link
Contributor

oh, that return nil below was a mistake :/ It should've been a continue

		cairo1Class, ok := class.(*Cairo1Class)
		// cairo0 classes are deprecated and hard to verify their hash, just ignore them
		if !ok {
			return nil
		}

@kirugan kirugan force-pushed the kirugan/revert-cairo0-hash-logic branch 3 times, most recently from 17acf73 to d129990 Compare November 30, 2023 10:19
core/class.go Outdated Show resolved Hide resolved
@kirugan kirugan force-pushed the kirugan/revert-cairo0-hash-logic branch 2 times, most recently from 39e4349 to 57983fe Compare December 4, 2023 08:55
@kirugan kirugan force-pushed the kirugan/revert-cairo0-hash-logic branch from fe71731 to 1c53cc1 Compare December 4, 2023 13:48
Copy link
Contributor

@IronGauntlets IronGauntlets left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (8c47775) 72.38% compared to head (c764e07) 72.89%.

Files Patch % Lines
p2p/starknet/block_bodies.go 0.00% 9 Missing ⚠️
adapters/core2sn/class.go 0.00% 5 Missing ⚠️
rpc/transaction.go 0.00% 3 Missing ⚠️
utils/zero_value.go 40.00% 2 Missing and 1 partial ⚠️
core/class.go 80.00% 1 Missing and 1 partial ⚠️
core/class_hash.go 83.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1470      +/-   ##
==========================================
+ Coverage   72.38%   72.89%   +0.51%     
==========================================
  Files          94       96       +2     
  Lines        9939     9943       +4     
==========================================
+ Hits         7194     7248      +54     
+ Misses       2208     2157      -51     
- Partials      537      538       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@IronGauntlets IronGauntlets merged commit e1125b6 into main Dec 4, 2023
8 of 10 checks passed
@IronGauntlets IronGauntlets deleted the kirugan/revert-cairo0-hash-logic branch December 4, 2023 14:34
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