NethermindEth / juno

Starknet client implementation.
https://juno.nethermind.io
Apache License 2.0
404 stars 170 forks source link

Add starknet_getCompiledCasm #2204

Closed kirugan closed 3 weeks ago

kirugan commented 1 month ago

Here are several class hashes that I used to test this PR:

  1. cairo0 (0x5f18f9cdc05da87f04e8e7685bd346fc029f977167d5b1b2b59f69a7dacbfc8)
  2. cairo1 (0x0631509cbd3a29d2ab5fe39e26b9fdbb7eac2db19d01ffb9582a444ddc072ba8)

Test script to check cairo0 classes:

func TestMe(t *testing.T) {
    fd, err := os.Open("") // path to list of cairo0 class hashes (each line - class hash)
    require.NoError(t, err)

    sc := bufio.NewScanner(fd)

    var classHashes []*felt.Felt
    for sc.Scan() {
        classHash, err := new(felt.Felt).SetString(sc.Text())
        require.NoError(t, err)

        classHashes = append(classHashes, classHash)
    }
    require.NoError(t, sc.Err())

    db, err := pebble.New("") // path to your db
    require.NoError(t, err)

    chain := blockchain.New(db, &utils.Sepolia)
    st, closer, err := chain.HeadState()
    require.NoError(t, err)
    defer closer()

    for _, classHash := range classHashes {
        declaredClass, err := st.Class(classHash)
        require.NoError(t, err)

        cairo0 := declaredClass.Class.(*core.Cairo0Class)
        _, err = adaptCairo0Class(cairo0)
        if err == nil {
            fmt.Println("Seems good", classHash)
        } else {
            fmt.Println("Seems bad", classHash, err)
        }
    }
}
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 55.28455% with 55 lines in your changes missing coverage. Please review.

Project coverage is 75.40%. Comparing base (3093ca8) to head (3ad1501). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
rpc/compiled_casm.go 49.01% 46 Missing and 6 partials :warning:
utils/maps.go 72.72% 2 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2204 +/- ## ========================================== - Coverage 75.63% 75.40% -0.23% ========================================== Files 104 106 +2 Lines 11102 11222 +120 ========================================== + Hits 8397 8462 +65 - Misses 2073 2121 +48 - Partials 632 639 +7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.