diff --git a/scripts/mocks.mockgen.txt b/scripts/mocks.mockgen.txt index a70046ee8088..be565912634f 100644 --- a/scripts/mocks.mockgen.txt +++ b/scripts/mocks.mockgen.txt @@ -26,7 +26,7 @@ github.com/ava-labs/avalanchego/utils/filesystem=Reader=utils/filesystem/mock_io github.com/ava-labs/avalanchego/utils/hashing=Hasher=utils/hashing/mock_hasher.go github.com/ava-labs/avalanchego/utils/logging=Logger=utils/logging/mock_logger.go github.com/ava-labs/avalanchego/utils/resource=User=utils/resource/mock_user.go -github.com/ava-labs/avalanchego/vms/avm/blocks=Block=vms/avm/blocks/mock_block.go +github.com/ava-labs/avalanchego/vms/avm/block=Block=vms/avm/block/mock_block.go github.com/ava-labs/avalanchego/vms/avm/metrics=Metrics=vms/avm/metrics/mock_metrics.go github.com/ava-labs/avalanchego/vms/avm/states=Chain,State,Diff=vms/avm/states/mock_states.go github.com/ava-labs/avalanchego/vms/avm/txs/mempool=Mempool=vms/avm/txs/mempool/mock_mempool.go diff --git a/vms/avm/blocks/block.go b/vms/avm/block/block.go similarity index 98% rename from vms/avm/blocks/block.go rename to vms/avm/block/block.go index 6ab2af6be086..331c310274e1 100644 --- a/vms/avm/blocks/block.go +++ b/vms/avm/block/block.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package blocks +package block import ( "time" diff --git a/vms/avm/blocks/block_test.go b/vms/avm/block/block_test.go similarity index 99% rename from vms/avm/blocks/block_test.go rename to vms/avm/block/block_test.go index 1dad208ffd5f..568eef5f5851 100644 --- a/vms/avm/blocks/block_test.go +++ b/vms/avm/block/block_test.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package blocks +package block import ( "testing" diff --git a/vms/avm/blocks/builder/builder.go b/vms/avm/block/builder/builder.go similarity index 95% rename from vms/avm/blocks/builder/builder.go rename to vms/avm/block/builder/builder.go index 77b7d2589942..77bbf38a6a35 100644 --- a/vms/avm/blocks/builder/builder.go +++ b/vms/avm/block/builder/builder.go @@ -12,12 +12,12 @@ import ( "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/utils/units" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/states" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/avm/txs/mempool" - blockexecutor "github.com/ava-labs/avalanchego/vms/avm/blocks/executor" + blockexecutor "github.com/ava-labs/avalanchego/vms/avm/block/executor" txexecutor "github.com/ava-labs/avalanchego/vms/avm/txs/executor" ) @@ -153,7 +153,7 @@ func (b *builder) BuildBlock(context.Context) (snowman.Block, error) { return nil, ErrNoTransactions } - statelessBlk, err := blocks.NewStandardBlock( + statelessBlk, err := block.NewStandardBlock( preferredID, nextHeight, nextTimestamp, diff --git a/vms/avm/blocks/builder/builder_test.go b/vms/avm/block/builder/builder_test.go similarity index 96% rename from vms/avm/blocks/builder/builder_test.go rename to vms/avm/block/builder/builder_test.go index 13887d00dbfe..a0edd1d0bad6 100644 --- a/vms/avm/blocks/builder/builder_test.go +++ b/vms/avm/block/builder/builder_test.go @@ -27,7 +27,7 @@ import ( "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/version" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/avm/metrics" "github.com/ava-labs/avalanchego/vms/avm/states" @@ -36,7 +36,7 @@ import ( "github.com/ava-labs/avalanchego/vms/components/avax" "github.com/ava-labs/avalanchego/vms/secp256k1fx" - blkexecutor "github.com/ava-labs/avalanchego/vms/avm/blocks/executor" + blkexecutor "github.com/ava-labs/avalanchego/vms/avm/block/executor" txexecutor "github.com/ava-labs/avalanchego/vms/avm/txs/executor" ) @@ -86,7 +86,7 @@ func TestBuilderBuildBlock(t *testing.T) { preferredID := ids.GenerateTestID() preferredHeight := uint64(1337) preferredTimestamp := time.Now() - preferredBlock := blocks.NewMockBlock(ctrl) + preferredBlock := block.NewMockBlock(ctrl) preferredBlock.EXPECT().Height().Return(preferredHeight) preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp) @@ -117,7 +117,7 @@ func TestBuilderBuildBlock(t *testing.T) { preferredID := ids.GenerateTestID() preferredHeight := uint64(1337) preferredTimestamp := time.Now() - preferredBlock := blocks.NewMockBlock(ctrl) + preferredBlock := block.NewMockBlock(ctrl) preferredBlock.EXPECT().Height().Return(preferredHeight) preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp) @@ -161,7 +161,7 @@ func TestBuilderBuildBlock(t *testing.T) { preferredID := ids.GenerateTestID() preferredHeight := uint64(1337) preferredTimestamp := time.Now() - preferredBlock := blocks.NewMockBlock(ctrl) + preferredBlock := block.NewMockBlock(ctrl) preferredBlock.EXPECT().Height().Return(preferredHeight) preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp) @@ -206,7 +206,7 @@ func TestBuilderBuildBlock(t *testing.T) { preferredID := ids.GenerateTestID() preferredHeight := uint64(1337) preferredTimestamp := time.Now() - preferredBlock := blocks.NewMockBlock(ctrl) + preferredBlock := block.NewMockBlock(ctrl) preferredBlock.EXPECT().Height().Return(preferredHeight) preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp) @@ -252,7 +252,7 @@ func TestBuilderBuildBlock(t *testing.T) { preferredID := ids.GenerateTestID() preferredHeight := uint64(1337) preferredTimestamp := time.Now() - preferredBlock := blocks.NewMockBlock(ctrl) + preferredBlock := block.NewMockBlock(ctrl) preferredBlock.EXPECT().Height().Return(preferredHeight) preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp) @@ -300,7 +300,7 @@ func TestBuilderBuildBlock(t *testing.T) { // Assert created block has one tx, tx1, // and other fields are set correctly. manager.EXPECT().NewBlock(gomock.Any()).DoAndReturn( - func(block *blocks.StandardBlock) snowman.Block { + func(block *block.StandardBlock) snowman.Block { require.Len(t, block.Transactions, 1) require.Equal(t, tx1, block.Transactions[0]) require.Equal(t, preferredHeight+1, block.Height()) @@ -345,7 +345,7 @@ func TestBuilderBuildBlock(t *testing.T) { preferredID := ids.GenerateTestID() preferredHeight := uint64(1337) preferredTimestamp := time.Now() - preferredBlock := blocks.NewMockBlock(ctrl) + preferredBlock := block.NewMockBlock(ctrl) preferredBlock.EXPECT().Height().Return(preferredHeight) preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp) @@ -365,7 +365,7 @@ func TestBuilderBuildBlock(t *testing.T) { manager.EXPECT().VerifyUniqueInputs(preferredID, gomock.Any()).Return(nil) // Assert that the created block has the right timestamp manager.EXPECT().NewBlock(gomock.Any()).DoAndReturn( - func(block *blocks.StandardBlock) snowman.Block { + func(block *block.StandardBlock) snowman.Block { require.Equal(t, preferredTimestamp.Unix(), block.Timestamp().Unix()) return nil }, @@ -419,7 +419,7 @@ func TestBuilderBuildBlock(t *testing.T) { // preferred block's timestamp is after the time reported by clock now := time.Now() preferredTimestamp := now.Add(-2 * time.Second) - preferredBlock := blocks.NewMockBlock(ctrl) + preferredBlock := block.NewMockBlock(ctrl) preferredBlock.EXPECT().Height().Return(preferredHeight) preferredBlock.EXPECT().Timestamp().Return(preferredTimestamp) @@ -439,7 +439,7 @@ func TestBuilderBuildBlock(t *testing.T) { manager.EXPECT().VerifyUniqueInputs(preferredID, gomock.Any()).Return(nil) // Assert that the created block has the right timestamp manager.EXPECT().NewBlock(gomock.Any()).DoAndReturn( - func(block *blocks.StandardBlock) snowman.Block { + func(block *block.StandardBlock) snowman.Block { require.Equal(t, now.Unix(), block.Timestamp().Unix()) return nil }, @@ -513,7 +513,7 @@ func TestBlockBuilderAddLocalTx(t *testing.T) { require.NoError(mempool.Add(tx)) require.True(mempool.Has(txID)) - parser, err := blocks.NewParser([]fxs.Fx{ + parser, err := block.NewParser([]fxs.Fx{ &secp256k1fx.Fx{}, }) require.NoError(err) @@ -539,7 +539,7 @@ func TestBlockBuilderAddLocalTx(t *testing.T) { cm := parser.Codec() txs, err := createParentTxs(cm) require.NoError(err) - parentBlk, err := blocks.NewStandardBlock(parentID, 0, parentTimestamp, txs, cm) + parentBlk, err := block.NewStandardBlock(parentID, 0, parentTimestamp, txs, cm) require.NoError(err) state.AddBlock(parentBlk) state.SetLastAccepted(parentBlk.ID()) diff --git a/vms/avm/blocks/executor/block.go b/vms/avm/block/executor/block.go similarity index 99% rename from vms/avm/blocks/executor/block.go rename to vms/avm/block/executor/block.go index d17f7d69887b..418ca0b539ca 100644 --- a/vms/avm/blocks/executor/block.go +++ b/vms/avm/block/executor/block.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/states" "github.com/ava-labs/avalanchego/vms/avm/txs/executor" ) @@ -37,7 +37,7 @@ var ( // Exported for testing in avm package. type Block struct { - blocks.Block + block.Block manager *manager rejected bool } diff --git a/vms/avm/blocks/executor/block_test.go b/vms/avm/block/executor/block_test.go similarity index 95% rename from vms/avm/blocks/executor/block_test.go rename to vms/avm/block/executor/block_test.go index 3e66cdd43915..9d7f291a8f60 100644 --- a/vms/avm/blocks/executor/block_test.go +++ b/vms/avm/block/executor/block_test.go @@ -22,7 +22,7 @@ import ( "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/timer/mockable" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/metrics" "github.com/ava-labs/avalanchego/vms/avm/states" "github.com/ava-labs/avalanchego/vms/avm/txs" @@ -41,7 +41,7 @@ func TestBlockVerify(t *testing.T) { { name: "block already verified", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() b := &Block{ Block: mockBlock, @@ -59,7 +59,7 @@ func TestBlockVerify(t *testing.T) { { name: "block timestamp too far in the future", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.GenerateTestID()).AnyTimes() return &Block{ @@ -72,7 +72,7 @@ func TestBlockVerify(t *testing.T) { { name: "block timestamp too far in the future", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() now := time.Now() @@ -92,7 +92,7 @@ func TestBlockVerify(t *testing.T) { { name: "block contains no transactions", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().Timestamp().Return(time.Now()).AnyTimes() @@ -110,7 +110,7 @@ func TestBlockVerify(t *testing.T) { { name: "block transaction fails verification", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().Timestamp().Return(time.Now()).AnyTimes() @@ -138,7 +138,7 @@ func TestBlockVerify(t *testing.T) { { name: "parent doesn't exist", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().Timestamp().Return(time.Now()).AnyTimes() @@ -169,7 +169,7 @@ func TestBlockVerify(t *testing.T) { { name: "block height isn't parent height + 1", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().Timestamp().Return(time.Now()).AnyTimes() @@ -187,7 +187,7 @@ func TestBlockVerify(t *testing.T) { mockBlock.EXPECT().Parent().Return(parentID).AnyTimes() mockState := states.NewMockState(ctrl) - mockParentBlock := blocks.NewMockBlock(ctrl) + mockParentBlock := block.NewMockBlock(ctrl) mockParentBlock.EXPECT().Height().Return(blockHeight) // Should be blockHeight - 1 mockState.EXPECT().GetBlock(parentID).Return(mockParentBlock, nil) @@ -205,7 +205,7 @@ func TestBlockVerify(t *testing.T) { { name: "block timestamp before parent timestamp", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() blockTimestamp := time.Now() @@ -223,7 +223,7 @@ func TestBlockVerify(t *testing.T) { parentID := ids.GenerateTestID() mockBlock.EXPECT().Parent().Return(parentID).AnyTimes() - mockParentBlock := blocks.NewMockBlock(ctrl) + mockParentBlock := block.NewMockBlock(ctrl) mockParentBlock.EXPECT().Height().Return(blockHeight - 1) mockParentState := states.NewMockDiff(ctrl) @@ -249,7 +249,7 @@ func TestBlockVerify(t *testing.T) { { name: "tx fails semantic verification", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() blockTimestamp := time.Now() @@ -268,7 +268,7 @@ func TestBlockVerify(t *testing.T) { parentID := ids.GenerateTestID() mockBlock.EXPECT().Parent().Return(parentID).AnyTimes() - mockParentBlock := blocks.NewMockBlock(ctrl) + mockParentBlock := block.NewMockBlock(ctrl) mockParentBlock.EXPECT().Height().Return(blockHeight - 1) mockParentState := states.NewMockDiff(ctrl) @@ -298,7 +298,7 @@ func TestBlockVerify(t *testing.T) { { name: "tx fails execution", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() blockTimestamp := time.Now() @@ -318,7 +318,7 @@ func TestBlockVerify(t *testing.T) { parentID := ids.GenerateTestID() mockBlock.EXPECT().Parent().Return(parentID).AnyTimes() - mockParentBlock := blocks.NewMockBlock(ctrl) + mockParentBlock := block.NewMockBlock(ctrl) mockParentBlock.EXPECT().Height().Return(blockHeight - 1) mockParentState := states.NewMockDiff(ctrl) @@ -349,7 +349,7 @@ func TestBlockVerify(t *testing.T) { { name: "tx imported inputs overlap", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() blockTimestamp := time.Now() @@ -396,7 +396,7 @@ func TestBlockVerify(t *testing.T) { parentID := ids.GenerateTestID() mockBlock.EXPECT().Parent().Return(parentID).AnyTimes() - mockParentBlock := blocks.NewMockBlock(ctrl) + mockParentBlock := block.NewMockBlock(ctrl) mockParentBlock.EXPECT().Height().Return(blockHeight - 1) mockParentState := states.NewMockDiff(ctrl) @@ -427,7 +427,7 @@ func TestBlockVerify(t *testing.T) { { name: "tx input overlaps with other tx", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() blockTimestamp := time.Now() @@ -458,7 +458,7 @@ func TestBlockVerify(t *testing.T) { parentID := ids.GenerateTestID() mockBlock.EXPECT().Parent().Return(parentID).AnyTimes() - mockParentBlock := blocks.NewMockBlock(ctrl) + mockParentBlock := block.NewMockBlock(ctrl) mockParentBlock.EXPECT().Height().Return(blockHeight - 1) mockParentState := states.NewMockDiff(ctrl) @@ -486,7 +486,7 @@ func TestBlockVerify(t *testing.T) { { name: "happy path", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes() mockBlock.EXPECT().MerkleRoot().Return(ids.Empty).AnyTimes() blockTimestamp := time.Now() @@ -506,7 +506,7 @@ func TestBlockVerify(t *testing.T) { parentID := ids.GenerateTestID() mockBlock.EXPECT().Parent().Return(parentID).AnyTimes() - mockParentBlock := blocks.NewMockBlock(ctrl) + mockParentBlock := block.NewMockBlock(ctrl) mockParentBlock.EXPECT().Height().Return(blockHeight - 1) mockParentState := states.NewMockDiff(ctrl) @@ -582,7 +582,7 @@ func TestBlockAccept(t *testing.T) { { name: "block not found", blockFunc: func(ctrl *gomock.Controller) *Block { - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(ids.GenerateTestID()).AnyTimes() mockBlock.EXPECT().Txs().Return([]*txs.Tx{}).AnyTimes() @@ -609,7 +609,7 @@ func TestBlockAccept(t *testing.T) { name: "can't get commit batch", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() mockBlock.EXPECT().Txs().Return([]*txs.Tx{}).AnyTimes() @@ -647,7 +647,7 @@ func TestBlockAccept(t *testing.T) { name: "can't apply shared memory", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() mockBlock.EXPECT().Txs().Return([]*txs.Tx{}).AnyTimes() @@ -691,7 +691,7 @@ func TestBlockAccept(t *testing.T) { name: "failed to apply metrics", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() mockBlock.EXPECT().Txs().Return([]*txs.Tx{}).AnyTimes() @@ -739,7 +739,7 @@ func TestBlockAccept(t *testing.T) { name: "no error", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() mockBlock.EXPECT().Height().Return(uint64(0)).AnyTimes() mockBlock.EXPECT().Parent().Return(ids.GenerateTestID()).AnyTimes() @@ -814,7 +814,7 @@ func TestBlockReject(t *testing.T) { name: "one tx passes verification; one fails syntactic verification; one fails semantic verification; one fails execution", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() mockBlock.EXPECT().Height().Return(uint64(0)).AnyTimes() mockBlock.EXPECT().Parent().Return(ids.GenerateTestID()).AnyTimes() @@ -889,7 +889,7 @@ func TestBlockReject(t *testing.T) { name: "all txs valid", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() mockBlock.EXPECT().Height().Return(uint64(0)).AnyTimes() mockBlock.EXPECT().Parent().Return(ids.GenerateTestID()).AnyTimes() @@ -979,7 +979,7 @@ func TestBlockStatus(t *testing.T) { name: "block is last accepted", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() return &Block{ Block: mockBlock, @@ -994,7 +994,7 @@ func TestBlockStatus(t *testing.T) { name: "block is processing", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() return &Block{ Block: mockBlock, @@ -1011,7 +1011,7 @@ func TestBlockStatus(t *testing.T) { name: "block is accepted but not last accepted", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() mockState := states.NewMockState(ctrl) @@ -1031,7 +1031,7 @@ func TestBlockStatus(t *testing.T) { name: "block is unknown", blockFunc: func(ctrl *gomock.Controller) *Block { blockID := ids.GenerateTestID() - mockBlock := blocks.NewMockBlock(ctrl) + mockBlock := block.NewMockBlock(ctrl) mockBlock.EXPECT().ID().Return(blockID).AnyTimes() mockState := states.NewMockState(ctrl) diff --git a/vms/avm/blocks/executor/manager.go b/vms/avm/block/executor/manager.go similarity index 94% rename from vms/avm/blocks/executor/manager.go rename to vms/avm/block/executor/manager.go index 0a233b6a359d..aa99ede6392f 100644 --- a/vms/avm/blocks/executor/manager.go +++ b/vms/avm/block/executor/manager.go @@ -11,7 +11,7 @@ import ( "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/utils/timer/mockable" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/metrics" "github.com/ava-labs/avalanchego/vms/avm/states" "github.com/ava-labs/avalanchego/vms/avm/txs" @@ -36,8 +36,8 @@ type Manager interface { Preferred() ids.ID GetBlock(blkID ids.ID) (snowman.Block, error) - GetStatelessBlock(blkID ids.ID) (blocks.Block, error) - NewBlock(blocks.Block) snowman.Block + GetStatelessBlock(blkID ids.ID) (block.Block, error) + NewBlock(block.Block) snowman.Block // VerifyTx verifies that the transaction can be issued based on the // currently preferred state. @@ -92,7 +92,7 @@ type manager struct { } type blockState struct { - statelessBlock blocks.Block + statelessBlock block.Block onAcceptState states.Diff importedInputs set.Set[ids.ID] atomicRequests map[ids.ID]*atomic.Requests @@ -126,7 +126,7 @@ func (m *manager) GetBlock(blkID ids.ID) (snowman.Block, error) { return m.NewBlock(blk), nil } -func (m *manager) GetStatelessBlock(blkID ids.ID) (blocks.Block, error) { +func (m *manager) GetStatelessBlock(blkID ids.ID) (block.Block, error) { // See if the block is in memory. if blkState, ok := m.blkIDToState[blkID]; ok { return blkState.statelessBlock, nil @@ -135,7 +135,7 @@ func (m *manager) GetStatelessBlock(blkID ids.ID) (blocks.Block, error) { return m.state.GetBlock(blkID) } -func (m *manager) NewBlock(blk blocks.Block) snowman.Block { +func (m *manager) NewBlock(blk block.Block) snowman.Block { return &Block{ Block: blk, manager: m, diff --git a/vms/avm/blocks/executor/manager_test.go b/vms/avm/block/executor/manager_test.go similarity index 97% rename from vms/avm/blocks/executor/manager_test.go rename to vms/avm/block/executor/manager_test.go index 2a8e42bfb733..c21201417add 100644 --- a/vms/avm/blocks/executor/manager_test.go +++ b/vms/avm/block/executor/manager_test.go @@ -14,7 +14,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/set" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/states" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/avm/txs/executor" @@ -39,7 +39,7 @@ func TestManagerGetStatelessBlock(t *testing.T) { // Case: block is in memory { - statelessBlk := blocks.NewMockBlock(ctrl) + statelessBlk := block.NewMockBlock(ctrl) blkID := ids.GenerateTestID() blk := &blockState{ statelessBlock: statelessBlk, @@ -53,7 +53,7 @@ func TestManagerGetStatelessBlock(t *testing.T) { // Case: block isn't in memory { blkID := ids.GenerateTestID() - blk := blocks.NewMockBlock(ctrl) + blk := block.NewMockBlock(ctrl) state.EXPECT().GetBlock(blkID).Return(blk, nil) gotBlk, err := m.GetStatelessBlock(blkID) require.NoError(err) @@ -233,7 +233,7 @@ func TestManagerVerifyTx(t *testing.T) { lastAcceptedID := ids.GenerateTestID() preferredID := ids.GenerateTestID() - preferred := blocks.NewMockBlock(ctrl) + preferred := block.NewMockBlock(ctrl) preferred.EXPECT().Parent().Return(lastAcceptedID).AnyTimes() // These values don't matter for this test @@ -318,7 +318,7 @@ func TestVerifyUniqueInputs(t *testing.T) { // blk0 is blk1's parent blk0ID, blk1ID := ids.GenerateTestID(), ids.GenerateTestID() - blk0, blk1 := blocks.NewMockBlock(ctrl), blocks.NewMockBlock(ctrl) + blk0, blk1 := block.NewMockBlock(ctrl), block.NewMockBlock(ctrl) blk1.EXPECT().Parent().Return(blk0ID).AnyTimes() blk0.EXPECT().Parent().Return(ids.Empty).AnyTimes() // blk0's parent is accepted diff --git a/vms/avm/blocks/executor/mock_manager.go b/vms/avm/block/executor/mock_manager.go similarity index 94% rename from vms/avm/blocks/executor/mock_manager.go rename to vms/avm/block/executor/mock_manager.go index 56c4512eb3a1..b3560f2e8afa 100644 --- a/vms/avm/blocks/executor/mock_manager.go +++ b/vms/avm/block/executor/mock_manager.go @@ -2,7 +2,7 @@ // See the file LICENSE for licensing terms. // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ava-labs/avalanchego/vms/avm/blocks/executor (interfaces: Manager) +// Source: github.com/ava-labs/avalanchego/vms/avm/block/executor (interfaces: Manager) // Package executor is a generated GoMock package. package executor @@ -13,7 +13,7 @@ import ( ids "github.com/ava-labs/avalanchego/ids" snowman "github.com/ava-labs/avalanchego/snow/consensus/snowman" set "github.com/ava-labs/avalanchego/utils/set" - blocks "github.com/ava-labs/avalanchego/vms/avm/blocks" + block "github.com/ava-labs/avalanchego/vms/avm/block" states "github.com/ava-labs/avalanchego/vms/avm/states" txs "github.com/ava-labs/avalanchego/vms/avm/txs" gomock "go.uber.org/mock/gomock" @@ -73,10 +73,10 @@ func (mr *MockManagerMockRecorder) GetState(arg0 interface{}) *gomock.Call { } // GetStatelessBlock mocks base method. -func (m *MockManager) GetStatelessBlock(arg0 ids.ID) (blocks.Block, error) { +func (m *MockManager) GetStatelessBlock(arg0 ids.ID) (block.Block, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStatelessBlock", arg0) - ret0, _ := ret[0].(blocks.Block) + ret0, _ := ret[0].(block.Block) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -102,7 +102,7 @@ func (mr *MockManagerMockRecorder) LastAccepted() *gomock.Call { } // NewBlock mocks base method. -func (m *MockManager) NewBlock(arg0 blocks.Block) snowman.Block { +func (m *MockManager) NewBlock(arg0 block.Block) snowman.Block { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "NewBlock", arg0) ret0, _ := ret[0].(snowman.Block) diff --git a/vms/avm/blocks/mock_block.go b/vms/avm/block/mock_block.go similarity index 97% rename from vms/avm/blocks/mock_block.go rename to vms/avm/block/mock_block.go index d25719c3dc6b..770dbae29b7d 100644 --- a/vms/avm/blocks/mock_block.go +++ b/vms/avm/block/mock_block.go @@ -2,10 +2,10 @@ // See the file LICENSE for licensing terms. // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ava-labs/avalanchego/vms/avm/blocks (interfaces: Block) +// Source: github.com/ava-labs/avalanchego/vms/avm/block (interfaces: Block) -// Package blocks is a generated GoMock package. -package blocks +// Package block is a generated GoMock package. +package block import ( reflect "reflect" diff --git a/vms/avm/blocks/parser.go b/vms/avm/block/parser.go similarity index 99% rename from vms/avm/blocks/parser.go rename to vms/avm/block/parser.go index 17023b2088cf..4cdab44f25e2 100644 --- a/vms/avm/blocks/parser.go +++ b/vms/avm/block/parser.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package blocks +package block import ( "fmt" diff --git a/vms/avm/blocks/standard_block.go b/vms/avm/block/standard_block.go similarity index 99% rename from vms/avm/blocks/standard_block.go rename to vms/avm/block/standard_block.go index 03d9cf06abe1..be6f1c7456cd 100644 --- a/vms/avm/blocks/standard_block.go +++ b/vms/avm/block/standard_block.go @@ -1,7 +1,7 @@ // Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. // See the file LICENSE for licensing terms. -package blocks +package block import ( "fmt" diff --git a/vms/avm/environment_test.go b/vms/avm/environment_test.go index 10d22cb5eb7e..a75fb315ccc9 100644 --- a/vms/avm/environment_test.go +++ b/vms/avm/environment_test.go @@ -30,7 +30,7 @@ import ( "github.com/ava-labs/avalanchego/utils/linkedhashmap" "github.com/ava-labs/avalanchego/utils/sampler" "github.com/ava-labs/avalanchego/version" - "github.com/ava-labs/avalanchego/vms/avm/blocks/executor" + "github.com/ava-labs/avalanchego/vms/avm/block/executor" "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/avm/txs" diff --git a/vms/avm/metrics/metrics.go b/vms/avm/metrics/metrics.go index 233dd65aa654..59c4e159a901 100644 --- a/vms/avm/metrics/metrics.go +++ b/vms/avm/metrics/metrics.go @@ -8,7 +8,7 @@ import ( "github.com/ava-labs/avalanchego/utils/metric" "github.com/ava-labs/avalanchego/utils/wrappers" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/txs" ) @@ -23,7 +23,7 @@ type Metrics interface { // MarkBlockAccepted updates all metrics relating to the acceptance of a // block, including the underlying acceptance of the contained transactions. - MarkBlockAccepted(b blocks.Block) error + MarkBlockAccepted(b block.Block) error // MarkTxAccepted updates all metrics relating to the acceptance of a // transaction. // @@ -53,7 +53,7 @@ func (m *metrics) IncTxRefreshMisses() { m.numTxRefreshMisses.Inc() } -func (m *metrics) MarkBlockAccepted(b blocks.Block) error { +func (m *metrics) MarkBlockAccepted(b block.Block) error { for _, tx := range b.Txs() { if err := tx.Unsigned.Visit(m.txMetrics); err != nil { return err diff --git a/vms/avm/metrics/mock_metrics.go b/vms/avm/metrics/mock_metrics.go index de1b94dcea5f..b83a065e3fa0 100644 --- a/vms/avm/metrics/mock_metrics.go +++ b/vms/avm/metrics/mock_metrics.go @@ -11,7 +11,7 @@ import ( http "net/http" reflect "reflect" - blocks "github.com/ava-labs/avalanchego/vms/avm/blocks" + block "github.com/ava-labs/avalanchego/vms/avm/block" txs "github.com/ava-labs/avalanchego/vms/avm/txs" rpc "github.com/gorilla/rpc/v2" gomock "go.uber.org/mock/gomock" @@ -103,7 +103,7 @@ func (mr *MockMetricsMockRecorder) InterceptRequest(arg0 interface{}) *gomock.Ca } // MarkBlockAccepted mocks base method. -func (m *MockMetrics) MarkBlockAccepted(arg0 blocks.Block) error { +func (m *MockMetrics) MarkBlockAccepted(arg0 block.Block) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "MarkBlockAccepted", arg0) ret0, _ := ret[0].(error) diff --git a/vms/avm/network/network.go b/vms/avm/network/network.go index 0c6a64e3dd3e..1c3e7e5558ae 100644 --- a/vms/avm/network/network.go +++ b/vms/avm/network/network.go @@ -13,7 +13,7 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/avalanchego/vms/avm/blocks/executor" + "github.com/ava-labs/avalanchego/vms/avm/block/executor" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/avm/txs/mempool" "github.com/ava-labs/avalanchego/vms/components/message" diff --git a/vms/avm/network/network_test.go b/vms/avm/network/network_test.go index d2ddb659e5a8..6d779eadcc28 100644 --- a/vms/avm/network/network_test.go +++ b/vms/avm/network/network_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/avalanchego/vms/avm/blocks/executor" + "github.com/ava-labs/avalanchego/vms/avm/block/executor" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/avm/txs/mempool" diff --git a/vms/avm/service_test.go b/vms/avm/service_test.go index 81fc9e7c1a11..1a97bad62d47 100644 --- a/vms/avm/service_test.go +++ b/vms/avm/service_test.go @@ -33,8 +33,8 @@ import ( "github.com/ava-labs/avalanchego/utils/formatting/address" "github.com/ava-labs/avalanchego/utils/json" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/avalanchego/vms/avm/blocks" - "github.com/ava-labs/avalanchego/vms/avm/blocks/executor" + "github.com/ava-labs/avalanchego/vms/avm/block" + "github.com/ava-labs/avalanchego/vms/avm/block/executor" "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/states" "github.com/ava-labs/avalanchego/vms/avm/txs" @@ -2002,7 +2002,7 @@ func TestServiceGetBlock(t *testing.T) { { name: "JSON format", serviceAndExpectedBlockFunc: func(_ *testing.T, ctrl *gomock.Controller) (*Service, interface{}) { - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) block.EXPECT().InitCtx(gomock.Any()) block.EXPECT().Txs().Return(nil) @@ -2023,7 +2023,7 @@ func TestServiceGetBlock(t *testing.T) { { name: "hex format", serviceAndExpectedBlockFunc: func(t *testing.T, ctrl *gomock.Controller) (*Service, interface{}) { - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) blockBytes := []byte("hi mom") block.EXPECT().Bytes().Return(blockBytes) @@ -2047,7 +2047,7 @@ func TestServiceGetBlock(t *testing.T) { { name: "hexc format", serviceAndExpectedBlockFunc: func(t *testing.T, ctrl *gomock.Controller) (*Service, interface{}) { - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) blockBytes := []byte("hi mom") block.EXPECT().Bytes().Return(blockBytes) @@ -2071,7 +2071,7 @@ func TestServiceGetBlock(t *testing.T) { { name: "hexnc format", serviceAndExpectedBlockFunc: func(t *testing.T, ctrl *gomock.Controller) (*Service, interface{}) { - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) blockBytes := []byte("hi mom") block.EXPECT().Bytes().Return(blockBytes) @@ -2188,7 +2188,7 @@ func TestServiceGetBlockByHeight(t *testing.T) { { name: "JSON format", serviceAndExpectedBlockFunc: func(_ *testing.T, ctrl *gomock.Controller) (*Service, interface{}) { - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) block.EXPECT().InitCtx(gomock.Any()) block.EXPECT().Txs().Return(nil) @@ -2213,7 +2213,7 @@ func TestServiceGetBlockByHeight(t *testing.T) { { name: "hex format", serviceAndExpectedBlockFunc: func(t *testing.T, ctrl *gomock.Controller) (*Service, interface{}) { - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) blockBytes := []byte("hi mom") block.EXPECT().Bytes().Return(blockBytes) @@ -2241,7 +2241,7 @@ func TestServiceGetBlockByHeight(t *testing.T) { { name: "hexc format", serviceAndExpectedBlockFunc: func(t *testing.T, ctrl *gomock.Controller) (*Service, interface{}) { - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) blockBytes := []byte("hi mom") block.EXPECT().Bytes().Return(blockBytes) @@ -2269,7 +2269,7 @@ func TestServiceGetBlockByHeight(t *testing.T) { { name: "hexnc format", serviceAndExpectedBlockFunc: func(t *testing.T, ctrl *gomock.Controller) (*Service, interface{}) { - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) blockBytes := []byte("hi mom") block.EXPECT().Bytes().Return(blockBytes) @@ -2370,7 +2370,7 @@ func TestServiceGetHeight(t *testing.T) { state := states.NewMockState(ctrl) state.EXPECT().GetLastAccepted().Return(blockID) - block := blocks.NewMockBlock(ctrl) + block := block.NewMockBlock(ctrl) block.EXPECT().Height().Return(blockHeight) manager := executor.NewMockManager(ctrl) diff --git a/vms/avm/states/diff.go b/vms/avm/states/diff.go index 2b91861dd6b1..2ca6d58cd5ee 100644 --- a/vms/avm/states/diff.go +++ b/vms/avm/states/diff.go @@ -10,7 +10,7 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" ) @@ -33,9 +33,9 @@ type diff struct { // map of modified UTXOID -> *UTXO if the UTXO is nil, it has been removed modifiedUTXOs map[ids.ID]*avax.UTXO - addedTxs map[ids.ID]*txs.Tx // map of txID -> tx - addedBlockIDs map[uint64]ids.ID // map of height -> blockID - addedBlocks map[ids.ID]blocks.Block // map of blockID -> block + addedTxs map[ids.ID]*txs.Tx // map of txID -> tx + addedBlockIDs map[uint64]ids.ID // map of height -> blockID + addedBlocks map[ids.ID]block.Block // map of blockID -> block lastAccepted ids.ID timestamp time.Time @@ -55,7 +55,7 @@ func NewDiff( modifiedUTXOs: make(map[ids.ID]*avax.UTXO), addedTxs: make(map[ids.ID]*txs.Tx), addedBlockIDs: make(map[uint64]ids.ID), - addedBlocks: make(map[ids.ID]blocks.Block), + addedBlocks: make(map[ids.ID]block.Block), lastAccepted: parentState.GetLastAccepted(), timestamp: parentState.GetTimestamp(), }, nil @@ -112,7 +112,7 @@ func (d *diff) GetBlockIDAtHeight(height uint64) (ids.ID, error) { return parentState.GetBlockIDAtHeight(height) } -func (d *diff) GetBlock(blkID ids.ID) (blocks.Block, error) { +func (d *diff) GetBlock(blkID ids.ID) (block.Block, error) { if blk, exists := d.addedBlocks[blkID]; exists { return blk, nil } @@ -124,7 +124,7 @@ func (d *diff) GetBlock(blkID ids.ID) (blocks.Block, error) { return parentState.GetBlock(blkID) } -func (d *diff) AddBlock(blk blocks.Block) { +func (d *diff) AddBlock(blk block.Block) { blkID := blk.ID() d.addedBlockIDs[blk.Height()] = blkID d.addedBlocks[blkID] = blk diff --git a/vms/avm/states/mock_states.go b/vms/avm/states/mock_states.go index fa6550d04149..007b8622042e 100644 --- a/vms/avm/states/mock_states.go +++ b/vms/avm/states/mock_states.go @@ -15,7 +15,7 @@ import ( database "github.com/ava-labs/avalanchego/database" ids "github.com/ava-labs/avalanchego/ids" logging "github.com/ava-labs/avalanchego/utils/logging" - blocks "github.com/ava-labs/avalanchego/vms/avm/blocks" + block "github.com/ava-labs/avalanchego/vms/avm/block" txs "github.com/ava-labs/avalanchego/vms/avm/txs" avax "github.com/ava-labs/avalanchego/vms/components/avax" gomock "go.uber.org/mock/gomock" @@ -45,7 +45,7 @@ func (m *MockChain) EXPECT() *MockChainMockRecorder { } // AddBlock mocks base method. -func (m *MockChain) AddBlock(arg0 blocks.Block) { +func (m *MockChain) AddBlock(arg0 block.Block) { m.ctrl.T.Helper() m.ctrl.Call(m, "AddBlock", arg0) } @@ -93,10 +93,10 @@ func (mr *MockChainMockRecorder) DeleteUTXO(arg0 interface{}) *gomock.Call { } // GetBlock mocks base method. -func (m *MockChain) GetBlock(arg0 ids.ID) (blocks.Block, error) { +func (m *MockChain) GetBlock(arg0 ids.ID) (block.Block, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBlock", arg0) - ret0, _ := ret[0].(blocks.Block) + ret0, _ := ret[0].(block.Block) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -240,7 +240,7 @@ func (mr *MockStateMockRecorder) Abort() *gomock.Call { } // AddBlock mocks base method. -func (m *MockState) AddBlock(arg0 blocks.Block) { +func (m *MockState) AddBlock(arg0 block.Block) { m.ctrl.T.Helper() m.ctrl.Call(m, "AddBlock", arg0) } @@ -346,10 +346,10 @@ func (mr *MockStateMockRecorder) DeleteUTXO(arg0 interface{}) *gomock.Call { } // GetBlock mocks base method. -func (m *MockState) GetBlock(arg0 ids.ID) (blocks.Block, error) { +func (m *MockState) GetBlock(arg0 ids.ID) (block.Block, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBlock", arg0) - ret0, _ := ret[0].(blocks.Block) + ret0, _ := ret[0].(block.Block) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -553,7 +553,7 @@ func (m *MockDiff) EXPECT() *MockDiffMockRecorder { } // AddBlock mocks base method. -func (m *MockDiff) AddBlock(arg0 blocks.Block) { +func (m *MockDiff) AddBlock(arg0 block.Block) { m.ctrl.T.Helper() m.ctrl.Call(m, "AddBlock", arg0) } @@ -613,10 +613,10 @@ func (mr *MockDiffMockRecorder) DeleteUTXO(arg0 interface{}) *gomock.Call { } // GetBlock mocks base method. -func (m *MockDiff) GetBlock(arg0 ids.ID) (blocks.Block, error) { +func (m *MockDiff) GetBlock(arg0 ids.ID) (block.Block, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBlock", arg0) - ret0, _ := ret[0].(blocks.Block) + ret0, _ := ret[0].(block.Block) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/vms/avm/states/state.go b/vms/avm/states/state.go index 4d28e583abc5..1520fdd3a2ae 100644 --- a/vms/avm/states/state.go +++ b/vms/avm/states/state.go @@ -27,7 +27,7 @@ import ( "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/utils/timer" "github.com/ava-labs/avalanchego/utils/wrappers" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" ) @@ -66,7 +66,7 @@ type ReadOnlyChain interface { GetTx(txID ids.ID) (*txs.Tx, error) GetBlockIDAtHeight(height uint64) (ids.ID, error) - GetBlock(blkID ids.ID) (blocks.Block, error) + GetBlock(blkID ids.ID) (block.Block, error) GetLastAccepted() ids.ID GetTimestamp() time.Time } @@ -77,7 +77,7 @@ type Chain interface { avax.UTXODeleter AddTx(tx *txs.Tx) - AddBlock(block blocks.Block) + AddBlock(block block.Block) SetLastAccepted(blkID ids.ID) SetTimestamp(t time.Time) } @@ -146,7 +146,7 @@ type State interface { * '-- lastAcceptedKey -> lastAccepted */ type state struct { - parser blocks.Parser + parser block.Parser db *versiondb.Database modifiedUTXOs map[ids.ID]*avax.UTXO // map of modified UTXOID -> *UTXO if the UTXO is nil, it has been removed @@ -165,8 +165,8 @@ type state struct { blockIDCache cache.Cacher[uint64, ids.ID] // cache of height -> blockID. If the entry is ids.Empty, it is not in the database blockIDDB database.Database - addedBlocks map[ids.ID]blocks.Block // map of blockID -> Block - blockCache cache.Cacher[ids.ID, blocks.Block] // cache of blockID -> Block. If the entry is nil, it is not in the database + addedBlocks map[ids.ID]block.Block // map of blockID -> Block + blockCache cache.Cacher[ids.ID, block.Block] // cache of blockID -> Block. If the entry is nil, it is not in the database blockDB database.Database // [lastAccepted] is the most recently accepted block. @@ -180,7 +180,7 @@ type state struct { func New( db *versiondb.Database, - parser blocks.Parser, + parser block.Parser, metrics prometheus.Registerer, trackChecksums bool, ) (State, error) { @@ -218,10 +218,10 @@ func New( return nil, err } - blockCache, err := metercacher.New[ids.ID, blocks.Block]( + blockCache, err := metercacher.New[ids.ID, block.Block]( "block_cache", metrics, - &cache.LRU[ids.ID, blocks.Block]{Size: blockCacheSize}, + &cache.LRU[ids.ID, block.Block]{Size: blockCacheSize}, ) if err != nil { return nil, err @@ -251,7 +251,7 @@ func New( blockIDCache: blockIDCache, blockIDDB: blockIDDB, - addedBlocks: make(map[ids.ID]blocks.Block), + addedBlocks: make(map[ids.ID]block.Block), blockCache: blockCache, blockDB: blockDB, @@ -409,7 +409,7 @@ func (s *state) GetBlockIDAtHeight(height uint64) (ids.ID, error) { return blkID, nil } -func (s *state) GetBlock(blkID ids.ID) (blocks.Block, error) { +func (s *state) GetBlock(blkID ids.ID) (block.Block, error) { if blk, exists := s.addedBlocks[blkID]; exists { return blk, nil } @@ -439,7 +439,7 @@ func (s *state) GetBlock(blkID ids.ID) (blocks.Block, error) { return blk, nil } -func (s *state) AddBlock(block blocks.Block) { +func (s *state) AddBlock(block block.Block) { blkID := block.ID() s.addedBlockIDs[block.Height()] = blkID s.addedBlocks[blkID] = block @@ -460,7 +460,7 @@ func (s *state) InitializeChainState(stopVertexID ids.ID, genesisTimestamp time. } func (s *state) initializeChainState(stopVertexID ids.ID, genesisTimestamp time.Time) error { - genesis, err := blocks.NewStandardBlock( + genesis, err := block.NewStandardBlock( stopVertexID, 0, genesisTimestamp, diff --git a/vms/avm/states/state_test.go b/vms/avm/states/state_test.go index 07db5fadd5df..7ca0113a06e8 100644 --- a/vms/avm/states/state_test.go +++ b/vms/avm/states/state_test.go @@ -16,7 +16,7 @@ import ( "github.com/ava-labs/avalanchego/database/versiondb" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/version" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/avm/txs" "github.com/ava-labs/avalanchego/vms/components/avax" @@ -26,19 +26,19 @@ import ( const trackChecksums = false var ( - parser blocks.Parser + parser block.Parser populatedUTXO *avax.UTXO populatedUTXOID ids.ID populatedTx *txs.Tx populatedTxID ids.ID - populatedBlk blocks.Block + populatedBlk block.Block populatedBlkHeight uint64 populatedBlkID ids.ID ) func init() { var err error - parser, err = blocks.NewParser([]fxs.Fx{ + parser, err = block.NewParser([]fxs.Fx{ &secp256k1fx.Fx{}, }) if err != nil { @@ -67,7 +67,7 @@ func init() { } populatedTxID = populatedTx.ID() - populatedBlk, err = blocks.NewStandardBlock( + populatedBlk, err = block.NewStandardBlock( ids.GenerateTestID(), 1, time.Now(), @@ -234,7 +234,7 @@ func ChainBlockTest(t *testing.T, c Chain) { require.NoError(err) require.Equal(populatedBlk.ID(), fetchedBlk.ID()) - blk, err := blocks.NewStandardBlock( + blk, err := block.NewStandardBlock( ids.GenerateTestID(), 10, time.Now(), @@ -295,7 +295,7 @@ func TestInitializeChainState(t *testing.T) { require.Equal(stopVertexID, genesis.Parent()) require.Equal(genesisTimestamp.UnixNano(), genesis.Timestamp().UnixNano()) - childBlock, err := blocks.NewStandardBlock( + childBlock, err := block.NewStandardBlock( genesis.ID(), genesis.Height()+1, genesisTimestamp, diff --git a/vms/avm/txs/executor/executor_test.go b/vms/avm/txs/executor/executor_test.go index c8c6c11d1aac..042ae39a9048 100644 --- a/vms/avm/txs/executor/executor_test.go +++ b/vms/avm/txs/executor/executor_test.go @@ -17,7 +17,7 @@ import ( "github.com/ava-labs/avalanchego/utils/constants" "github.com/ava-labs/avalanchego/utils/crypto/secp256k1" "github.com/ava-labs/avalanchego/utils/units" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/avm/states" "github.com/ava-labs/avalanchego/vms/avm/txs" @@ -37,7 +37,7 @@ func TestBaseTxExecutor(t *testing.T) { require := require.New(t) secpFx := &secp256k1fx.Fx{} - parser, err := blocks.NewParser([]fxs.Fx{secpFx}) + parser, err := block.NewParser([]fxs.Fx{secpFx}) require.NoError(err) codec := parser.Codec() @@ -142,7 +142,7 @@ func TestCreateAssetTxExecutor(t *testing.T) { require := require.New(t) secpFx := &secp256k1fx.Fx{} - parser, err := blocks.NewParser([]fxs.Fx{secpFx}) + parser, err := block.NewParser([]fxs.Fx{secpFx}) require.NoError(err) codec := parser.Codec() @@ -285,7 +285,7 @@ func TestOperationTxExecutor(t *testing.T) { require := require.New(t) secpFx := &secp256k1fx.Fx{} - parser, err := blocks.NewParser([]fxs.Fx{secpFx}) + parser, err := block.NewParser([]fxs.Fx{secpFx}) require.NoError(err) codec := parser.Codec() diff --git a/vms/avm/vm.go b/vms/avm/vm.go index afe466761c16..9ef3f6cad65e 100644 --- a/vms/avm/vm.go +++ b/vms/avm/vm.go @@ -34,7 +34,7 @@ import ( "github.com/ava-labs/avalanchego/utils/timer/mockable" "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/ava-labs/avalanchego/version" - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/config" "github.com/ava-labs/avalanchego/vms/avm/metrics" "github.com/ava-labs/avalanchego/vms/avm/network" @@ -47,8 +47,8 @@ import ( "github.com/ava-labs/avalanchego/vms/components/keystore" "github.com/ava-labs/avalanchego/vms/secp256k1fx" - blockbuilder "github.com/ava-labs/avalanchego/vms/avm/blocks/builder" - blockexecutor "github.com/ava-labs/avalanchego/vms/avm/blocks/executor" + blockbuilder "github.com/ava-labs/avalanchego/vms/avm/block/builder" + blockexecutor "github.com/ava-labs/avalanchego/vms/avm/block/executor" extensions "github.com/ava-labs/avalanchego/vms/avm/fxs" txexecutor "github.com/ava-labs/avalanchego/vms/avm/txs/executor" ) @@ -84,7 +84,7 @@ type VM struct { registerer prometheus.Registerer - parser blocks.Parser + parser block.Parser pubsub *pubsub.Server @@ -207,7 +207,7 @@ func (vm *VM) Initialize( } vm.typeToFxIndex = map[reflect.Type]int{} - vm.parser, err = blocks.NewCustomParser( + vm.parser, err = block.NewCustomParser( vm.typeToFxIndex, &vm.clock, ctx.Log, diff --git a/wallet/chain/x/constants.go b/wallet/chain/x/constants.go index ec5ea7b46322..ed43fc07a84d 100644 --- a/wallet/chain/x/constants.go +++ b/wallet/chain/x/constants.go @@ -4,7 +4,7 @@ package x import ( - "github.com/ava-labs/avalanchego/vms/avm/blocks" + "github.com/ava-labs/avalanchego/vms/avm/block" "github.com/ava-labs/avalanchego/vms/avm/fxs" "github.com/ava-labs/avalanchego/vms/nftfx" "github.com/ava-labs/avalanchego/vms/propertyfx" @@ -18,11 +18,11 @@ const ( ) // Parser to support serialization and deserialization -var Parser blocks.Parser +var Parser block.Parser func init() { var err error - Parser, err = blocks.NewParser([]fxs.Fx{ + Parser, err = block.NewParser([]fxs.Fx{ &secp256k1fx.Fx{}, &nftfx.Fx{}, &propertyfx.Fx{},