Skip to content

Commit

Permalink
Remove supported block version check
Browse files Browse the repository at this point in the history
Allows processing of all versions without explicit checks
  • Loading branch information
wojciechos committed Nov 19, 2024
1 parent e29c217 commit e515322
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
8 changes: 1 addition & 7 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"sync/atomic"
"time"

"github.com/Masterminds/semver/v3"
"github.com/NethermindEth/juno/core"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/db"
Expand Down Expand Up @@ -51,19 +50,14 @@ type Reader interface {

var (
ErrParentDoesNotMatchHead = errors.New("block's parent hash does not match head block hash")
supportedStarknetVersion = semver.MustParse("0.13.3")
)

func checkBlockVersion(protocolVersion string) error {
blockVer, err := core.ParseBlockVersion(protocolVersion)
_, err := core.ParseBlockVersion(protocolVersion)
if err != nil {
return err
}

if blockVer.GreaterThan(supportedStarknetVersion) {
return errors.New("unsupported block version")
}

return nil
}

Expand Down
15 changes: 0 additions & 15 deletions blockchain/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,6 @@ func TestVerifyBlock(t *testing.T) {
require.Error(t, chain.Store(mainnetBlock0, &emptyCommitments, mainnetStateUpdate0, nil))
})

t.Run("needs padding", func(t *testing.T) {
mainnetBlock0.ProtocolVersion = "99.0" // should be padded to "99.0.0"
require.EqualError(t, chain.Store(mainnetBlock0, &emptyCommitments, mainnetStateUpdate0, nil), "unsupported block version")
})

t.Run("needs truncating", func(t *testing.T) {
mainnetBlock0.ProtocolVersion = "99.0.0.0" // last 0 digit should be ignored
require.EqualError(t, chain.Store(mainnetBlock0, &emptyCommitments, mainnetStateUpdate0, nil), "unsupported block version")
})

t.Run("greater than supportedStarknetVersion", func(t *testing.T) {
mainnetBlock0.ProtocolVersion = "99.0.0"
require.EqualError(t, chain.Store(mainnetBlock0, &emptyCommitments, mainnetStateUpdate0, nil), "unsupported block version")
})

t.Run("no error with no version string", func(t *testing.T) {
mainnetBlock0.ProtocolVersion = ""
require.NoError(t, chain.Store(mainnetBlock0, &emptyCommitments, mainnetStateUpdate0, nil))
Expand Down

0 comments on commit e515322

Please sign in to comment.