-
Notifications
You must be signed in to change notification settings - Fork 220
Refactor: Refactored p2p2core adapater #3225
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
base: main
Are you sure you want to change the base?
Refactor: Refactored p2p2core adapater #3225
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
adapters/p2p2core/class.go
Outdated
| } | ||
|
|
||
| func createCompiledClass(cairo1 *class.Cairo1Class) (*core.CasmClass, error) { | ||
| // todo should this be a method of class.Cairo1Class |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If Cairo V0: Set
Compiledtonil - If Cairo V1: Set
Compiledto&casmClass
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
adapters/p2p2core/class.go
Outdated
| if cairo1 == nil { | ||
| return nil, nil | ||
| //nolint:exhaustruct // intentionally returning an empty CasmClass | ||
| return core.CasmClass{}, nil |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
Co-authored-by: Dat Duong <[email protected]> Signed-off-by: ndatta-nethermind <[email protected]>
| exhaustruct: | ||
| allow-empty-returns: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert

No description provided.