Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Dec 17, 2024
1 parent be21143 commit 8706311
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
12 changes: 0 additions & 12 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,18 +930,6 @@ func removeTxsAndReceipts(txn db.Transaction, blockNumber, numTxs uint64) error
return nil
}

func (b *Blockchain) verifyStateUpdateRoot(s *core.State, root *felt.Felt) error {
currentRoot, err := s.Root()
if err != nil {
return err
}

if !root.Equal(currentRoot) {
return fmt.Errorf("state's current state root: %s does not match the expected state root: %s", currentRoot, root)
}
return nil
}

type BlockSignFunc func(blockHash, stateDiffCommitment *felt.Felt) ([]*felt.Felt, error)

// Finalise will calculate the state commitment and block hash for the given pending block and append it to the
Expand Down
1 change: 0 additions & 1 deletion grpc/gen/kv.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 26 additions & 18 deletions vm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ func TestV0Call(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, []*felt.Felt{&felt.Zero}, ret)

require.NoError(t, testState.Update(1, &core.StateUpdate{StateDiff: &core.StateDiff{
StorageDiffs: map[felt.Felt]map[felt.Felt]*felt.Felt{
*contractAddr: {
*utils.HexToFelt(t, "0x206f38f7e4f15e87567361213c28f235cccdaa1d7fd34c9db1dfe9489c6a091"): new(felt.Felt).SetUint64(1337),
require.NoError(t, testState.Update(1, &core.StateUpdate{
StateDiff: &core.StateDiff{
StorageDiffs: map[felt.Felt]map[felt.Felt]*felt.Felt{
*contractAddr: {
*utils.HexToFelt(t, "0x206f38f7e4f15e87567361213c28f235cccdaa1d7fd34c9db1dfe9489c6a091"): new(felt.Felt).SetUint64(1337),
},
},
}},
},
}, nil))

ret, err = New(false, nil).Call(&CallInfo{
Expand Down Expand Up @@ -90,10 +92,12 @@ func TestV1Call(t *testing.T) {
require.NoError(t, encoder.RegisterType(reflect.TypeOf(core.Cairo1Class{})))

testState := core.NewState(txn)
require.NoError(t, testState.Update(0, &core.StateUpdate{StateDiff: &core.StateDiff{
DeployedContracts: map[felt.Felt]*felt.Felt{
*contractAddr: classHash,
}},
require.NoError(t, testState.Update(0, &core.StateUpdate{
StateDiff: &core.StateDiff{
DeployedContracts: map[felt.Felt]*felt.Felt{
*contractAddr: classHash,
},
},
}, map[felt.Felt]core.Class{
*classHash: simpleClass,
}))
Expand All @@ -114,12 +118,14 @@ func TestV1Call(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, []*felt.Felt{&felt.Zero}, ret)

require.NoError(t, testState.Update(1, &core.StateUpdate{StateDiff: &core.StateDiff{
StorageDiffs: map[felt.Felt]map[felt.Felt]*felt.Felt{
*contractAddr: {
*storageLocation: new(felt.Felt).SetUint64(37),
require.NoError(t, testState.Update(1, &core.StateUpdate{
StateDiff: &core.StateDiff{
StorageDiffs: map[felt.Felt]map[felt.Felt]*felt.Felt{
*contractAddr: {
*storageLocation: new(felt.Felt).SetUint64(37),
},
},
}},
},
}, nil))

ret, err = New(false, log).Call(&CallInfo{
Expand Down Expand Up @@ -152,10 +158,12 @@ func TestCall_MaxSteps(t *testing.T) {
encoder.RegisterType(reflect.TypeOf(core.Cairo0Class{})) //nolint:errcheck

testState := core.NewState(txn)
require.NoError(t, testState.Update(0, &core.StateUpdate{StateDiff: &core.StateDiff{
DeployedContracts: map[felt.Felt]*felt.Felt{
*contractAddr: classHash,
}},
require.NoError(t, testState.Update(0, &core.StateUpdate{
StateDiff: &core.StateDiff{
DeployedContracts: map[felt.Felt]*felt.Felt{
*contractAddr: classHash,
},
},
}, map[felt.Felt]core.Class{
*classHash: simpleClass,
}))
Expand Down

0 comments on commit 8706311

Please sign in to comment.