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 obsolete migrations #2306

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
46 changes: 23 additions & 23 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ func (b *Blockchain) Height() (uint64, error) {
var height uint64
return height, b.database.View(func(txn db.Transaction) error {
var err error
height, err = ChainHeight(txn)
height, err = chainHeight(txn)
return err
})
}

func ChainHeight(txn db.Transaction) (uint64, error) {
func chainHeight(txn db.Transaction) (uint64, error) {
var height uint64
return height, txn.Get(db.ChainHeight.Key(), func(val []byte) error {
height = binary.BigEndian.Uint64(val)
Expand Down Expand Up @@ -157,15 +157,15 @@ func (b *Blockchain) HeadsHeader() (*core.Header, error) {
}

func head(txn db.Transaction) (*core.Block, error) {
height, err := ChainHeight(txn)
height, err := chainHeight(txn)
if err != nil {
return nil, err
}
return BlockByNumber(txn, height)
return blockByNumber(txn, height)
}

func headsHeader(txn db.Transaction) (*core.Header, error) {
height, err := ChainHeight(txn)
height, err := chainHeight(txn)
if err != nil {
return nil, err
}
Expand All @@ -178,7 +178,7 @@ func (b *Blockchain) BlockByNumber(number uint64) (*core.Block, error) {
var block *core.Block
return block, b.database.View(func(txn db.Transaction) error {
var err error
block, err = BlockByNumber(txn, number)
block, err = blockByNumber(txn, number)
return err
})
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func (b *Blockchain) Store(block *core.Block, blockCommitments *core.BlockCommit
if err := core.NewState(txn).Update(block.Number, stateUpdate, newClasses); err != nil {
return err
}
if err := StoreBlockHeader(txn, block.Header); err != nil {
if err := storeBlockHeader(txn, block.Header); err != nil {
return err
}

Expand All @@ -338,16 +338,16 @@ func (b *Blockchain) Store(block *core.Block, blockCommitments *core.BlockCommit
return err
}

if err := StoreBlockCommitments(txn, block.Number, blockCommitments); err != nil {
if err := storeBlockCommitments(txn, block.Number, blockCommitments); err != nil {
return err
}

if err := StoreL1HandlerMsgHashes(txn, block.Transactions); err != nil {
if err := storeL1HandlerMsgHashes(txn, block.Transactions); err != nil {
return err
}

// Head of the blockchain is maintained as follows:
// [db.ChainHeight]() -> (BlockNumber)
// [db.chainHeight]() -> (BlockNumber)
heightBin := core.MarshalBlockNumber(block.Number)
return txn.Set(db.ChainHeight.Key(), heightBin)
})
Expand Down Expand Up @@ -386,7 +386,7 @@ func verifyBlock(txn db.Transaction, block *core.Block) error {
return nil
}

func StoreBlockCommitments(txn db.Transaction, blockNumber uint64, commitments *core.BlockCommitments) error {
func storeBlockCommitments(txn db.Transaction, blockNumber uint64, commitments *core.BlockCommitments) error {
numBytes := core.MarshalBlockNumber(blockNumber)

commitmentBytes, err := encoder.Marshal(commitments)
Expand Down Expand Up @@ -420,7 +420,7 @@ func blockCommitmentsByNumber(txn db.Transaction, blockNumber uint64) (*core.Blo
return commitments, nil
}

// StoreBlockHeader stores the given block in the database.
// storeBlockHeader stores the given block in the database.
// The db storage for blocks is maintained by two buckets as follows:
//
// [db.BlockHeaderNumbersByHash](BlockHash) -> (BlockNumber)
Expand All @@ -429,7 +429,7 @@ func blockCommitmentsByNumber(txn db.Transaction, blockNumber uint64) (*core.Blo
// "[]" is the db prefix to represent a bucket
// "()" are additional keys appended to the prefix or multiple values marshalled together
// "->" represents a key value pair.
func StoreBlockHeader(txn db.Transaction, header *core.Header) error {
func storeBlockHeader(txn db.Transaction, header *core.Header) error {
numBytes := core.MarshalBlockNumber(header.Number)

if err := txn.Set(db.BlockHeaderNumbersByHash.Key(header.Hash.Marshal()), numBytes); err != nil {
Expand Down Expand Up @@ -467,16 +467,16 @@ func blockHeaderByHash(txn db.Transaction, hash *felt.Felt) (*core.Header, error
})
}

// BlockByNumber retrieves a block from database by its number
func BlockByNumber(txn db.Transaction, number uint64) (*core.Block, error) {
// blockByNumber retrieves a block from database by its number
func blockByNumber(txn db.Transaction, number uint64) (*core.Block, error) {
header, err := blockHeaderByNumber(txn, number)
if err != nil {
return nil, err
}

block := new(core.Block)
block.Header = header
block.Transactions, err = TransactionsByBlockNumber(txn, number)
block.Transactions, err = transactionsByBlockNumber(txn, number)
if err != nil {
return nil, err
}
Expand All @@ -488,7 +488,7 @@ func BlockByNumber(txn db.Transaction, number uint64) (*core.Block, error) {
return block, nil
}

func TransactionsByBlockNumber(txn db.Transaction, number uint64) ([]core.Transaction, error) {
func transactionsByBlockNumber(txn db.Transaction, number uint64) ([]core.Transaction, error) {
iterator, err := txn.NewIterator()
if err != nil {
return nil, err
Expand Down Expand Up @@ -563,12 +563,12 @@ func blockByHash(txn db.Transaction, hash *felt.Felt) (*core.Block, error) {
var block *core.Block
return block, txn.Get(db.BlockHeaderNumbersByHash.Key(hash.Marshal()), func(val []byte) error {
var err error
block, err = BlockByNumber(txn, binary.BigEndian.Uint64(val))
block, err = blockByNumber(txn, binary.BigEndian.Uint64(val))
return err
})
}

func StoreL1HandlerMsgHashes(dbTxn db.Transaction, blockTxns []core.Transaction) error {
func storeL1HandlerMsgHashes(dbTxn db.Transaction, blockTxns []core.Transaction) error {
for _, txn := range blockTxns {
if l1Handler, ok := (txn).(*core.L1HandlerTransaction); ok {
err := dbTxn.Set(db.L1HandlerTxnHashByMsgHash.Key(l1Handler.MessageHash()), txn.Hash().Marshal())
Expand Down Expand Up @@ -760,7 +760,7 @@ func (b *Blockchain) HeadState() (core.StateReader, StateCloser, error) {
return nil, nil, err
}

_, err = ChainHeight(txn)
_, err = chainHeight(txn)
if err != nil {
return nil, nil, utils.RunAndWrapOnError(txn.Discard, err)
}
Expand Down Expand Up @@ -814,7 +814,7 @@ func (b *Blockchain) EventFilter(from *felt.Felt, keys [][]felt.Felt) (EventFilt
return nil, err
}

latest, err := ChainHeight(txn)
latest, err := chainHeight(txn)
if err != nil {
return nil, err
}
Expand All @@ -830,7 +830,7 @@ func (b *Blockchain) RevertHead() error {
func (b *Blockchain) GetReverseStateDiff() (*core.StateDiff, error) {
var reverseStateDiff *core.StateDiff
return reverseStateDiff, b.database.View(func(txn db.Transaction) error {
blockNumber, err := ChainHeight(txn)
blockNumber, err := chainHeight(txn)
if err != nil {
return err
}
Expand All @@ -845,7 +845,7 @@ func (b *Blockchain) GetReverseStateDiff() (*core.StateDiff, error) {
}

func (b *Blockchain) revertHead(txn db.Transaction) error {
blockNumber, err := ChainHeight(txn)
blockNumber, err := chainHeight(txn)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion blockchain/event_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ type FilteredEvent struct {
//nolint:gocyclo
func (e *EventFilter) Events(cToken *ContinuationToken, chunkSize uint64) ([]*FilteredEvent, *ContinuationToken, error) {
var matchedEvents []*FilteredEvent
latest, err := ChainHeight(e.txn)
latest, err := chainHeight(e.txn)
if err != nil {
return nil, nil, err
}
Expand Down
1 change: 1 addition & 0 deletions clients/feeder/feeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ func (c *Client) CompiledClassDefinition(ctx context.Context, classHash *felt.Fe
return nil, err
}

// todo before merge check that this is not used
if deprecated, _ := starknet.IsDeprecatedCompiledClassDefinition(definition); deprecated {
return nil, ErrDeprecatedCompiledClass
}
Expand Down
1 change: 0 additions & 1 deletion core/felt/felt.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const (
)

const (
Limbs = fp.Limbs // number of 64 bits words needed to represent a Element
IronGauntlets marked this conversation as resolved.
Show resolved Hide resolved
Bits = fp.Bits // number of bits needed to represent a Element
Bytes = fp.Bytes // number of bytes needed to represent a Element
)
Expand Down
Loading
Loading