Skip to content

Conversation

@ndatta-nethermind
Copy link
Contributor

No description provided.

@ndatta-nethermind ndatta-nethermind linked an issue Oct 30, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.66%. Comparing base (6d50637) to head (5c916b6).

Files with missing lines Patch % Lines
adapters/sn2core/sn2core.go 91.89% 2 Missing and 1 partial ⚠️
p2p/sync/sync.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3225      +/-   ##
==========================================
+ Coverage   76.64%   76.66%   +0.01%     
==========================================
  Files         323      323              
  Lines       31863    31863              
==========================================
+ Hits        24422    24427       +5     
- Misses       5675     5684       +9     
+ Partials     1766     1752      -14     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

func createCompiledClass(cairo1 *class.Cairo1Class) (*core.CasmClass, error) {
// todo should this be a method of class.Cairo1Class
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this todo a leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a requirement:
Add a todo on top which asks: "should this be a method of class.Cairo1Class"

assert.NotNil(t, adaptedResponse.Compiled)
} else {
assert.Nil(t, adaptedResponse.Compiled)
assert.Empty(t, adaptedResponse.Compiled)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change the behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the reason: #3225 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change the behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the requirement: #3204

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is the screenshot of the issue:
image

None of the above is saying that we should set Compiled to &CasmClass{} instead of nil if the declared class is Cairo V0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's asking to return value type instead of reference type in CompileToCasm method into adapters/p2p2core/class.go.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • If Cairo V0: Set Compiled to nil
  • If Cairo V1: Set Compiled to &casmClass

Copy link
Collaborator

Choose a reason for hiding this comment

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

@infrmtcs but if we are adapting Sierra classes, Cairo 0 wouldn't be adapted to it. Where do we adapt Cairo zero and set the Casm to nil?

assert.NotNil(t, actualClass.Compiled)
} else {
assert.Nil(t, actualClass.Compiled)
assert.Empty(t, actualClass.Compiled)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change the behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the reason: #3225 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change the behaviour?

result, err := sn2core.AdaptCompiledClass(nil)
require.NoError(t, err)
assert.Nil(t, result)
assert.Empty(t, result)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change the behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the reason: #3225 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change the behaviour?

if cairo1 == nil {
return nil, nil
//nolint:exhaustruct // intentionally returning an empty CasmClass
return core.CasmClass{}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this is correct because we instantiate a core.CasmClass in the Cairo 0 case, where *class.Cairo1Class is nil.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that now we're only calling this function when compiledClass is non-nil, so we can throw an error here instead.

if compiledClass == nil {
return nil, nil
//nolint:exhaustruct // intentionally returning an empty CasmClass
return core.CasmClass{}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this is correct because we instantiate a core.CasmClass in the Cairo 0 case, where *class.Cairo1Class is nil.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that now we're only calling this function when compiledClass is non-nil, so we can throw an error here instead.

ProgramHash: class.Class.ProgramHash,
SemanticVersion: class.Class.SemanticVersion,
Compiled: casmClass,
Compiled: &casmClass,
Copy link
Contributor

Choose a reason for hiding this comment

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

This means we have a zero core.CasmClass instead of nil in deprecated case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, looks like we should have nil instead

return core.CasmClass{}, nil
}

adapt := func(ep *class.SierraEntryPoint) starknet.SierraEntryPoint {
Copy link
Contributor

Choose a reason for hiding this comment

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

Cant we reuse adaptSierra or adaptSierraEntryPoints here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. adaptSierra return core.SierraEntrypoint.

ProgramHash: class.Class.ProgramHash,
SemanticVersion: class.Class.SemanticVersion,
Compiled: casmClass,
Compiled: &casmClass,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, looks like we should have nil instead

Comment on lines +49 to +50
exhaustruct:
allow-empty-returns: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert

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.

Refactor p2p2core adapters

5 participants