Skip to content

Commit

Permalink
Remove core.BlockHash()
Browse files Browse the repository at this point in the history
  • Loading branch information
kirugan committed Sep 19, 2024
1 parent da71835 commit 5074099
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
13 changes: 0 additions & 13 deletions core/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,6 @@ func VerifyBlockHash(b *Block, network *utils.Network, stateDiff *StateDiff) (*B
return nil, errors.New("can not verify hash in block header")
}

// BlockHash assumes block.SequencerAddress is not nil as this is called with post v0.12.0
// and by then issues with unverifiable block hash were resolved.
// In future, this may no longer be required.
// Todo: Pass stateDiff so that p2p layer can calculate post 0.13.2 Block Hash
func BlockHash(b *Block) (*felt.Felt, error) { // todo remove function?
if b.SequencerAddress == nil {
return nil, errors.New("block.SequencerAddress is nil")
}

h, _, err := post07Hash(b, nil)
return h, err
}

// blockHash computes the block hash, with option to override sequence address
func blockHash(b *Block, stateDiff *StateDiff, network *utils.Network, overrideSeqAddr *felt.Felt) (*felt.Felt,
*BlockCommitments, error,
Expand Down
14 changes: 0 additions & 14 deletions core/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,3 @@ func Test0132BlockHash(t *testing.T) {
})
}
}

func TestBlockHashP2P(t *testing.T) {
mainnetGW := adaptfeeder.New(feeder.NewTestClient(t, &utils.Mainnet))

t.Run("error if block.SequencerAddress is nil", func(t *testing.T) {
mainnetBlock1, err := mainnetGW.BlockByNumber(context.Background(), 1)
require.NoError(t, err)

mainnetBlock1.SequencerAddress = nil

_, err = core.BlockHash(mainnetBlock1)
assert.EqualError(t, err, "block.SequencerAddress is nil")
})
}

0 comments on commit 5074099

Please sign in to comment.