Skip to content

Commit

Permalink
Merge pull request #625 from NethermindEth/thiagodeev/upgrade-juno-an…
Browse files Browse the repository at this point in the history
…d-go-version

Upgrades Juno and Go version
  • Loading branch information
thiagodeev authored Sep 26, 2024
2 parents 7a46573 + 2bf9f35 commit 182a073
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.56.2
version: v1.61
4 changes: 2 additions & 2 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,7 @@ func TestAddDeclareTxn(t *testing.T) {
var class rpc.ContractClass
err = json.Unmarshal(content, &class)
require.NoError(t, err)
classHash, err := hash.ClassHash(class)
require.NoError(t, err)
classHash := hash.ClassHash(class)

// Compiled Class Hash
content2, err := os.ReadFile("./tests/hello_world_compiled.casm.json")
Expand Down Expand Up @@ -1195,6 +1194,7 @@ func TestAddDeclareTxn(t *testing.T) {
// - []devnet.TestAccount: a slice of test accounts
// - error: an error, if any
func newDevnet(t *testing.T, url string) (*devnet.DevNet, []devnet.TestAccount, error) {
t.Helper()
devnet := devnet.NewDevNet(url)
acnts, err := devnet.Accounts()
return devnet, acnts, err
Expand Down
2 changes: 1 addition & 1 deletion curve/curve.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ func (sc StarkCurve) PoseidonArray(felts ...*felt.Felt) *felt.Felt {
// Returns:
// - *felt.Felt: pointer to a felt.Felt
// - error: An error if any
func (sc StarkCurve) StarknetKeccak(b []byte) (*felt.Felt, error) {
func (sc StarkCurve) StarknetKeccak(b []byte) *felt.Felt {
return junoCrypto.StarknetKeccak(b)
}

Expand Down
47 changes: 21 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
module github.com/NethermindEth/starknet.go

go 1.21
go 1.23.1

require (
github.com/NethermindEth/juno v0.3.1
github.com/ethereum/go-ethereum v1.13.8
github.com/NethermindEth/juno v0.12.2
github.com/ethereum/go-ethereum v1.14.8
github.com/joho/godotenv v1.4.0
github.com/nsf/jsondiff v0.0.0-20210926074059-1e845ec5d249
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
go.uber.org/mock v0.4.0
golang.org/x/crypto v0.17.0
golang.org/x/net v0.18.0
golang.org/x/crypto v0.26.0
golang.org/x/net v0.28.0
)

require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/bits-and-blooms/bitset v1.14.2 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/consensys/gnark-crypto v0.13.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

require (
github.com/google/go-cmp v0.5.9
golang.org/x/sys v0.15.0 // indirect
)
require golang.org/x/sys v0.24.0 // indirect
186 changes: 90 additions & 96 deletions go.sum

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func CalculateTransactionHashCommon(
// Returns:
// - *felt.Felt: a pointer to a felt.Felt object that represents the calculated hash.
// - error: an error object if there was an error during the hash calculation.
func ClassHash(contract rpc.ContractClass) (*felt.Felt, error) {
func ClassHash(contract rpc.ContractClass) *felt.Felt {
// https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/class-hash/

Version := "CONTRACT_CLASS_V" + contract.ContractClassVersion
Expand All @@ -66,13 +66,10 @@ func ClassHash(contract rpc.ContractClass) (*felt.Felt, error) {
ExternalHash := hashEntryPointByType(contract.EntryPointsByType.External)
L1HandleHash := hashEntryPointByType(contract.EntryPointsByType.L1Handler)
SierraProgamHash := curve.Curve.PoseidonArray(contract.SierraProgram...)
ABIHash, err := curve.Curve.StarknetKeccak([]byte(contract.ABI))
if err != nil {
return nil, err
}
ABIHash := curve.Curve.StarknetKeccak([]byte(contract.ABI))

// https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/#deploy_account_hash_calculation
return curve.Curve.PoseidonArray(ContractClassVersionHash, ExternalHash, L1HandleHash, ConstructorHash, ABIHash, SierraProgamHash), nil
return curve.Curve.PoseidonArray(ContractClassVersionHash, ExternalHash, L1HandleHash, ConstructorHash, ABIHash, SierraProgamHash)
}

// hashEntryPointByType calculates the hash of an entry point by type.
Expand Down
12 changes: 7 additions & 5 deletions hash/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import (
// Parameters:
// - t: A testing.T object used for running the test and reporting any failures.
// Returns:
// none
//
// none
func TestUnmarshalCasmClassHash(t *testing.T) {
content, err := os.ReadFile("./tests/hello_starknet_compiled.casm.json")
require.NoError(t, err)
Expand All @@ -36,7 +37,8 @@ func TestUnmarshalCasmClassHash(t *testing.T) {
// Parameters:
// - t: A testing.T object used for running the test and reporting any failures.
// Returns:
// none
//
// none
func TestClassHash(t *testing.T) {
//https://github.com/software-mansion/starknet.py/blob/development/starknet_py/hash/class_hash_test.py
expectedClasshash := "0x4ec2ecf58014bc2ffd7c84843c3525e5ecb0a2cac33c47e9c347f39fc0c0944"
Expand All @@ -47,8 +49,7 @@ func TestClassHash(t *testing.T) {
var class rpc.ContractClass
err = json.Unmarshal(content, &class)
require.NoError(t, err)
compClassHash, err := hash.ClassHash(class)
require.NoError(t, err)
compClassHash := hash.ClassHash(class)
require.Equal(t, expectedClasshash, compClassHash.String())
}

Expand All @@ -60,7 +61,8 @@ func TestClassHash(t *testing.T) {
// Parameters:
// - t: A testing.T object used for running the test and reporting any failures.
// Returns:
// none
//
// none
func TestCompiledClassHash(t *testing.T) {
//https://github.com/software-mansion/starknet.py/blob/development/starknet_py/hash/casm_class_hash_test.py
expectedHash := "0x785fa5f2bacf0bfe3bc413be5820a61e1ea63f2ec27ef00331ee9f46ad07603"
Expand Down
1 change: 0 additions & 1 deletion rpc/types_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ func TestBlockWithReceipts(t *testing.T) {
require.NotEmpty(pBlock.ParentHash, "Error in PendingBlockWithReceipts ParentHash")
require.NotEmpty(pBlock.SequencerAddress, "Error in PendingBlockWithReceipts SequencerAddress")
require.NotEmpty(pBlock.Timestamp, "Error in PendingBlockWithReceipts Timestamp")
require.NotEmpty(pBlock.Transactions, "Error in PendingBlockWithReceipts Transactions")
}

default:
Expand Down

0 comments on commit 182a073

Please sign in to comment.