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

[vms/proposervm] Remove getForkHeight() #2929

Merged
merged 1 commit into from
Apr 10, 2024
Merged
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
2 changes: 1 addition & 1 deletion vms/proposervm/pre_fork_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (b *preForkBlock) acceptInnerBlk(ctx context.Context) error {
}

func (b *preForkBlock) Status() choices.Status {
forkHeight, err := b.vm.getForkHeight()
forkHeight, err := b.vm.GetForkHeight()
if err == database.ErrNotFound {
return b.Block.Status()
}
Expand Down
26 changes: 1 addition & 25 deletions vms/proposervm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ var (
_ block.BatchedChainVM = (*VM)(nil)
_ block.StateSyncableVM = (*VM)(nil)

// TODO: remove after the X-chain supports height indexing.
mainnetXChainID = ids.FromStringOrPanic("2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM")
fujiXChainID = ids.FromStringOrPanic("2JVSBoinj9C2J33VntvzYtVJNZdN2NKiwwKjcumHUWEb5DbBrm")

dbPrefix = []byte("proposervm")
)

Expand Down Expand Up @@ -214,7 +210,7 @@ func (vm *VM) Initialize(
return err
}

forkHeight, err := vm.getForkHeight()
forkHeight, err := vm.GetForkHeight()
switch err {
case nil:
chainCtx.Log.Info("initialized proposervm",
Expand Down Expand Up @@ -575,26 +571,6 @@ func (vm *VM) getBlock(ctx context.Context, id ids.ID) (Block, error) {
return vm.getPreForkBlock(ctx, id)
}

// TODO: remove after the P-chain and X-chain support height indexing.
func (vm *VM) getForkHeight() (uint64, error) {
// The fork block can be easily identified with the provided links because
// the `Parent Hash` is equal to the `Proposer Parent ID`.
switch vm.ctx.ChainID {
case constants.PlatformChainID:
switch vm.ctx.NetworkID {
case constants.MainnetID:
return 805732, nil // https://subnets.avax.network/p-chain/block/805732
case constants.FujiID:
return 47529, nil // https://subnets-test.avax.network/p-chain/block/47529
}
case mainnetXChainID:
return 1, nil // https://subnets.avax.network/x-chain/block/1
case fujiXChainID:
return 1, nil // https://subnets-test.avax.network/x-chain/block/1
}
return vm.GetForkHeight()
}

func (vm *VM) getPostForkBlock(ctx context.Context, blkID ids.ID) (PostForkBlock, error) {
block, exists := vm.verifiedBlocks[blkID]
if exists {
Expand Down
Loading