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

feat: remove the need for Sierra on the Blockifier Side #10

Open
rodrigo-pino opened this issue Sep 2, 2024 · 0 comments
Open

feat: remove the need for Sierra on the Blockifier Side #10

rodrigo-pino opened this issue Sep 2, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@rodrigo-pino
Copy link

Feature Request

The use of Sierra inside a Native Contract Class was initially meant as a way to have a fallback to the VM in case of failed Native execution.

We have decided to remove that feature, but still Sierra is used for other things:

  1. Fallback to the VM
  2. Comparison for Partial Equality
  3. Entry point selection

So far, 1 and 2 can be solved in the Blockifier and 3 will be solved on the Cairo Native side.

Proposed Solution

Without removing the Sierra, let's address issues 1 and 2. Let's remove the code from the fallback and find a way to perform partial equility.

Solving 1 should be straightforward, so we will focus on 2.

When comparing two different Native Contract Class we compared the entry points by type and the sierra program since we ideally don't have access to the Sierra we need to find a new way to compare the contracts.

We cannot only compare entry points because they can be two different contracts with the same entry points.

We cannot compare the executors naively, because each one of them represents an address in Memory. Two instances of the same contract will result in they being treated as different, but they are actually the same.

The Idea is to give a unique ID to each Native Contract Class. This unique identifier should be obtained by hashing the Sierra instructions during the creation of Native Contract Class.

This can be solved in different manners, it is important to find the most performant one. That is, the one that requires de least amount of hashes. Haven't thought about it, it might be as well only achieved in Theta(n). The hash to be used must be thought of, it should be cheap to do on standard CPUs.

Other ideas are welcomed, maybe we can compare the executors, or perhaps obtain an identifier much more easily.

@rodrigo-pino rodrigo-pino added the enhancement New feature or request label Sep 2, 2024
@PearsonWhite PearsonWhite self-assigned this Sep 2, 2024
PearsonWhite pushed a commit that referenced this issue Sep 6, 2024
NativeContractClassV1Inner contained full Sierra contract in order to
run the VM code in the event of a NativeUnexpectedError.
Now, this is no longer needed.

Issue: #10
PR: TBA
Testing: TBA
PearsonWhite added a commit that referenced this issue Sep 10, 2024
NativeContractClassV1Inner contained full Sierra contract in order to
run the VM code in the event of a NativeUnexpectedError.
Now, this is no longer needed.

Issue: #10
PR: #13
Testing: crates/blockifier/tests/test_native_contract.rs
PearsonWhite added a commit that referenced this issue Sep 11, 2024
NativeContractClassV1Inner contained full Sierra contract in order to
run the VM code in the event of a NativeUnexpectedError.
Now, this is no longer needed.

Issue: #10
PR: #13
Testing: crates/blockifier/tests/test_native_contract.rs
PearsonWhite added a commit that referenced this issue Sep 11, 2024
NativeContractClassV1Inner contained full Sierra contract in order to
run the VM code in the event of a NativeUnexpectedError.
Now, this is no longer needed.

Issue: #10
PR: #13
Testing: crates/blockifier/tests/test_native_contract.rs
PearsonWhite added a commit that referenced this issue Sep 11, 2024
NativeContractClassV1Inner contained full Sierra contract in order to
run the VM code in the event of a NativeUnexpectedError.
Now, this is no longer needed.

Issue: #10
PR: #13
Testing: crates/blockifier/tests/test_native_contract.rs
PearsonWhite added a commit that referenced this issue Sep 11, 2024
NativeContractClassV1Inner contained full Sierra contract in order to
run the VM code in the event of a NativeUnexpectedError.
Now, this is no longer needed.

Issue: #10
PR: #13
Testing: crates/blockifier/tests/test_native_contract.rs
PearsonWhite added a commit that referenced this issue Sep 16, 2024
NativeContractClassV1Inner contained full Sierra contract in order to
run the VM code in the event of a NativeUnexpectedError.
Now, this is no longer needed.

Issue: #10
PR: #13
Testing: crates/blockifier/tests/test_native_contract.rs
PearsonWhite added a commit that referenced this issue Sep 16, 2024
NativeContractClassV1Inner contained full Sierra contract in order to
run the VM code in the event of a NativeUnexpectedError.
Now, this is no longer needed.

Issue: #10
PR: #13
Testing: crates/blockifier/tests/test_native_contract.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants