Skip to content
This repository was archived by the owner on Jan 9, 2025. It is now read-only.

feat: use Cairo1Helpers in AccountContract #1107

Merged
merged 11 commits into from
Apr 18, 2024

Conversation

enitrat
Copy link
Collaborator

@enitrat enitrat commented Apr 17, 2024

Time spent on this PR: 0.7d

Improvement metrics

Full Cairo Zero validation
Transaction resource usage: Steps: 369606 | Bitwise: 3169 | L1 Gas: 5748 | Pedersen: 165 | Range Checks: 22658



Using Cairo1_helpers's "keccak" and "verify_eth_signature" in validation
Transaction resource usage: Steps: 326384 | Bitwise: 44 | Keccak: 2 | L1 Gas: 5748 | Pedersen: 165 | Range Checks: 20971


which is a reduction of 43000 steps per tx :)

Method:

Call counter.inc() before and after.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Resolves #

What is the new behavior?

  • Use Cairo1Helpers in Account contract for keccak and sig verification
  • Implement upgradeability mechanism

This change is Reviewable

@enitrat enitrat force-pushed the feat/verify-signature-cairo1-helpers branch from 16d4b71 to 9916379 Compare April 17, 2024 09:44
@enitrat enitrat force-pushed the feat/verify-signature-cairo1-helpers branch from 42c84ef to 9f8c794 Compare April 17, 2024 12:40
@enitrat enitrat mentioned this pull request Apr 17, 2024
7 tasks
Comment on lines 127 to 130
let (latest_account_class, latest_cairo1helpers_class) = AccountContract.get_latest_classes();
let (this_helpers_class) = Account_cairo1_helpers_class_hash.read();
if (latest_cairo1helpers_class != this_helpers_class) {
Account_cairo1_helpers_class_hash.write(latest_cairo1helpers_class);
Copy link
Member

Choose a reason for hiding this comment

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

let's use this_helpers_class, latest_helpers_class and Account_helpers_class and remove everywhere the cairo1 thing (wen cairo2)

Copy link
Member

Choose a reason for hiding this comment

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

also, is _class or _class_hash the best prefix? no strong opinion but let's just choose one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

using _class

Comment on lines +115 to +117
let (helpers_class) = Kakarot_cairo1_helpers_class_hash.read();
let (point_hash) = ICairo1Helpers.library_call_keccak(
class_hash=implementation,
class_hash=helpers_class,
Copy link
Member

Choose a reason for hiding this comment

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

let's just decide whether it's _class or _class_hash

@enitrat enitrat merged commit 740b616 into main Apr 18, 2024
3 of 4 checks passed
@enitrat enitrat deleted the feat/verify-signature-cairo1-helpers branch April 18, 2024 15:39
matthieuauger pushed a commit to matthieuauger/kakarot that referenced this pull request Nov 9, 2024
* fix deployer tag

* cargo toml version
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants