Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Add new constructor declare v2 #823

Merged
merged 16 commits into from
Jul 17, 2023
Merged

Conversation

SantiagoPittella
Copy link
Collaborator

@SantiagoPittella SantiagoPittella commented Jul 14, 2023

Description

Adds the CasmContractClass as optional.
If already exist, we do not compile de sierra to casm.
If not, we use the usual path and compile the sierra to casm.

In both cases we check the CASM class hashes.

closes #822
Made on top of #819

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2023

Codecov Report

Merging #823 (2f73f71) into main (ae06254) will increase coverage by 0.08%.
The diff coverage is 97.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #823      +/-   ##
==========================================
+ Coverage   91.74%   91.82%   +0.08%     
==========================================
  Files          54       54              
  Lines       12530    12728     +198     
==========================================
+ Hits        11496    11688     +192     
- Misses       1034     1040       +6     
Impacted Files Coverage Δ
src/transaction/error.rs 100.00% <ø> (ø)
src/transaction/declare_v2.rs 84.15% <96.98%> (+5.79%) ⬆️
src/lib.rs 98.72% <100.00%> (+0.01%) ⬆️

Copy link
Contributor

@xqft xqft left a comment

Choose a reason for hiding this comment

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

Unsignificant nits

src/lib.rs Outdated
@@ -836,7 +836,7 @@ mod test {
tx_type: TransactionType::Declare,
validate_entry_point_selector: VALIDATE_DECLARE_ENTRY_POINT_SELECTOR.clone(),
version: 1.into(),
max_fee: 2,
max_fee: 100_000_000,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
max_fee: 100_000_000,
max_fee: INITIAL_GAS_COST,

src/lib.rs Outdated
let declare_tx = Transaction::DeclareV2(Box::new(declare_v2));

let err = declare_tx
.execute(&mut state, &block_context, 100_000_000)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.execute(&mut state, &block_context, 100_000_000)
.execute(&mut state, &block_context, INITIAL_GAS_COST)

SantiagoPittella and others added 6 commits July 17, 2023 11:04
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Co-authored-by: Estéfano Bargas <estefano.bargas@fing.edu.uy>
Copy link
Contributor

@pefontana pefontana left a comment

Choose a reason for hiding this comment

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

Nice one @SantiagoPittella !
I think it would be good to add a test checking the DeclareV2.casm_class = None case.
If we already tested that case please correct me!

@@ -466,7 +485,7 @@ mod tests {
use num_traits::{One, Zero};

#[test]
fn create_declare_v2_test() {
fn create_declare_v2_without_casm_contract_class_test() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a test with a none DeclareV2.casm_class to check that everything is working OK

@SantiagoPittella SantiagoPittella added this pull request to the merge queue Jul 17, 2023
Merged via the queue into main with commit a66205b Jul 17, 2023
@juanbono juanbono deleted the add-new-constructor-declare-v2 branch July 31, 2023 23:37
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new constructor for DeclareV2
6 participants