Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove supported block version check #2275

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 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 @@ -49,23 +48,7 @@ type Reader interface {
Network() *utils.Network
}

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)
if err != nil {
return err
}

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

return nil
}
var ErrParentDoesNotMatchHead = errors.New("block's parent hash does not match head block hash")

var _ Reader = (*Blockchain)(nil)

Expand Down Expand Up @@ -382,7 +365,7 @@ func (b *Blockchain) VerifyBlock(block *core.Block) error {
}

func verifyBlock(txn db.Transaction, block *core.Block) error {
if err := checkBlockVersion(block.ProtocolVersion); err != nil {
if _, err := core.ParseBlockVersion(block.ProtocolVersion); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we still need this or should also remove the block parsing check?

return err
}

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