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

Dynamic Fees - Add E Upgrade boilerplate #2597

Merged
merged 50 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
1adc328
E fork scaffolding
abi87 Jan 10, 2024
f6d7382
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 10, 2024
3889e51
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 12, 2024
e725961
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 15, 2024
30a4343
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 16, 2024
add3a35
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 17, 2024
3d08216
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 18, 2024
8f35564
Merge branch 'dev' into e-fork-scaffolding
abi87 Jan 19, 2024
2b16538
Merge branch 'master' into e-fork-scaffolding
abi87 Jan 26, 2024
4751e79
Merge branch 'master' into e-fork-scaffolding
abi87 Jan 29, 2024
e00d7c9
drop temporary fork time
abi87 Jan 29, 2024
b454987
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 1, 2024
f832034
nits
abi87 Feb 1, 2024
d33a6a2
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 7, 2024
8a89505
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 8, 2024
3daec34
cleanup
abi87 Feb 8, 2024
a0020b1
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 9, 2024
f28b80b
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 12, 2024
26fcb79
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 13, 2024
199424b
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 15, 2024
5ea9c0b
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 15, 2024
2b05cf1
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 16, 2024
9b97764
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 19, 2024
a4b81e6
fork switch to the avm
abi87 Feb 20, 2024
392e935
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 21, 2024
d3a733e
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 22, 2024
f735491
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 25, 2024
33e3b70
Merge branch 'master' into e-fork-scaffolding
abi87 Feb 29, 2024
507636e
latestFork in avm
abi87 Feb 29, 2024
399dfc8
default test config for a few unit tests
abi87 Feb 29, 2024
089af5e
come more unit tests helpers
abi87 Feb 29, 2024
3c52428
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 4, 2024
e34e3de
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 5, 2024
7feb04f
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 6, 2024
7d7d1f7
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 7, 2024
5992b33
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 11, 2024
cda811f
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 11, 2024
cd989f3
nits from code reviews
abi87 Mar 11, 2024
32da156
some more nits from code reviews
abi87 Mar 11, 2024
ae8231b
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 12, 2024
95d3ab5
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 13, 2024
7a17a9b
drop DurangoTime from avm config
abi87 Mar 13, 2024
2906756
nit
abi87 Mar 13, 2024
d3edbaa
nit
abi87 Mar 13, 2024
737d429
Merge branch 'master' into e-fork-scaffolding
abi87 Mar 18, 2024
7fc9532
Provide AVM eUpgradeTime and address nits
StephenButtolph Mar 18, 2024
8aca600
Merge branch 'e-fork-scaffolding' of github.com:ava-labs/avalanchego …
StephenButtolph Mar 18, 2024
4e10234
nit
StephenButtolph Mar 18, 2024
20bc290
nit
StephenButtolph Mar 18, 2024
fbab037
nit
StephenButtolph Mar 18, 2024
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
3 changes: 3 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,7 @@ func (n *Node) initVMs() error {
}

// Register the VMs that Avalanche supports
eUpgradeTime := version.GetEUpgradeTime(n.Config.NetworkID)
err := utils.Err(
n.VMManager.RegisterFactory(context.TODO(), constants.PlatformVMID, &platformvm.Factory{
Config: platformconfig.Config{
Expand Down Expand Up @@ -1153,13 +1154,15 @@ func (n *Node) initVMs() error {
BanffTime: version.GetBanffTime(n.Config.NetworkID),
CortinaTime: version.GetCortinaTime(n.Config.NetworkID),
DurangoTime: version.GetDurangoTime(n.Config.NetworkID),
EUpgradeTime: eUpgradeTime,
UseCurrentHeight: n.Config.UseCurrentHeight,
},
}),
n.VMManager.RegisterFactory(context.TODO(), constants.AVMID, &avm.Factory{
Config: avmconfig.Config{
TxFee: n.Config.TxFee,
CreateAssetTxFee: n.Config.CreateAssetTxFee,
EUpgradeTime: eUpgradeTime,
},
}),
n.VMManager.RegisterFactory(context.TODO(), constants.EVMID, &coreth.Factory{}),
Expand Down
12 changes: 12 additions & 0 deletions version/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ var (
constants.MainnetID: time.Date(2024, time.March, 6, 16, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(2024, time.February, 13, 16, 0, 0, 0, time.UTC),
}

EUpgradeTimes = map[uint32]time.Time{
constants.MainnetID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC),
constants.FujiID: time.Date(10000, time.December, 1, 0, 0, 0, 0, time.UTC),
}
)

func init() {
Expand Down Expand Up @@ -240,6 +245,13 @@ func GetDurangoTime(networkID uint32) time.Time {
return DefaultUpgradeTime
}

func GetEUpgradeTime(networkID uint32) time.Time {
if upgradeTime, exists := EUpgradeTimes[networkID]; exists {
return upgradeTime
}
return DefaultUpgradeTime
}

func GetCompatibility(networkID uint32) Compatibility {
return NewCompatibility(
CurrentApp,
Expand Down
99 changes: 48 additions & 51 deletions vms/avm/block/executor/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/ava-labs/avalanchego/utils/set"
"github.com/ava-labs/avalanchego/utils/timer/mockable"
"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/state"
"github.com/ava-labs/avalanchego/vms/avm/txs"
Expand All @@ -45,6 +46,7 @@ func TestBlockVerify(t *testing.T) {
b := &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{},
},
}
Expand All @@ -62,8 +64,10 @@ func TestBlockVerify(t *testing.T) {
mockBlock.EXPECT().ID().Return(ids.Empty).AnyTimes()
mockBlock.EXPECT().MerkleRoot().Return(ids.GenerateTestID()).AnyTimes()
return &Block{
Block: mockBlock,
manager: &manager{},
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
},
}
},
expectedErr: ErrUnexpectedMerkleRoot,
Expand All @@ -82,7 +86,8 @@ func TestBlockVerify(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
clk: clk,
backend: defaultTestBackend(false, nil),
clk: clk,
},
}
},
Expand All @@ -99,6 +104,7 @@ func TestBlockVerify(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{},
clk: &mockable.Clock{},
},
Expand All @@ -125,6 +131,7 @@ func TestBlockVerify(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
mempool: mempool,
metrics: metrics.NewMockMetrics(ctrl),
blkIDToState: map[ids.ID]*blockState{},
Expand Down Expand Up @@ -157,6 +164,7 @@ func TestBlockVerify(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
state: mockState,
blkIDToState: map[ids.ID]*blockState{},
clk: &mockable.Clock{},
Expand Down Expand Up @@ -193,6 +201,7 @@ func TestBlockVerify(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
state: mockState,
blkIDToState: map[ids.ID]*blockState{},
clk: &mockable.Clock{},
Expand Down Expand Up @@ -232,6 +241,7 @@ func TestBlockVerify(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{
parentID: {
onAcceptState: mockParentState,
Expand Down Expand Up @@ -279,6 +289,7 @@ func TestBlockVerify(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
mempool: mempool,
metrics: metrics.NewMockMetrics(ctrl),
blkIDToState: map[ids.ID]*blockState{
Expand Down Expand Up @@ -331,7 +342,7 @@ func TestBlockVerify(t *testing.T) {
manager: &manager{
mempool: mempool,
metrics: metrics.NewMockMetrics(ctrl),
backend: &executor.Backend{},
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{
parentID: {
onAcceptState: mockParentState,
Expand Down Expand Up @@ -409,7 +420,7 @@ func TestBlockVerify(t *testing.T) {
manager: &manager{
mempool: mempool,
metrics: metrics.NewMockMetrics(ctrl),
backend: &executor.Backend{},
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{
parentID: {
onAcceptState: mockParentState,
Expand Down Expand Up @@ -467,7 +478,7 @@ func TestBlockVerify(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: &executor.Backend{},
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{
parentID: {
onAcceptState: mockParentState,
Expand Down Expand Up @@ -519,7 +530,7 @@ func TestBlockVerify(t *testing.T) {
manager: &manager{
mempool: mockMempool,
metrics: metrics.NewMockMetrics(ctrl),
backend: &executor.Backend{},
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{
parentID: {
onAcceptState: mockParentState,
Expand Down Expand Up @@ -591,13 +602,9 @@ func TestBlockAccept(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
mempool: mempool,
metrics: metrics.NewMockMetrics(ctrl),
backend: &executor.Backend{
Ctx: &snow.Context{
Log: logging.NoLog{},
},
},
mempool: mempool,
metrics: metrics.NewMockMetrics(ctrl),
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{},
},
}
Expand Down Expand Up @@ -627,11 +634,7 @@ func TestBlockAccept(t *testing.T) {
manager: &manager{
state: mockManagerState,
mempool: mempool,
backend: &executor.Backend{
Ctx: &snow.Context{
Log: logging.NoLog{},
},
},
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{
blockID: {
onAcceptState: mockOnAcceptState,
Expand Down Expand Up @@ -670,12 +673,7 @@ func TestBlockAccept(t *testing.T) {
manager: &manager{
state: mockManagerState,
mempool: mempool,
backend: &executor.Backend{
Ctx: &snow.Context{
SharedMemory: mockSharedMemory,
Log: logging.NoLog{},
},
},
backend: defaultTestBackend(false, mockSharedMemory),
blkIDToState: map[ids.ID]*blockState{
blockID: {
onAcceptState: mockOnAcceptState,
Expand Down Expand Up @@ -718,12 +716,7 @@ func TestBlockAccept(t *testing.T) {
state: mockManagerState,
mempool: mempool,
metrics: metrics,
backend: &executor.Backend{
Ctx: &snow.Context{
SharedMemory: mockSharedMemory,
Log: logging.NoLog{},
},
},
backend: defaultTestBackend(false, mockSharedMemory),
blkIDToState: map[ids.ID]*blockState{
blockID: {
onAcceptState: mockOnAcceptState,
Expand Down Expand Up @@ -769,12 +762,7 @@ func TestBlockAccept(t *testing.T) {
state: mockManagerState,
mempool: mempool,
metrics: metrics,
backend: &executor.Backend{
Ctx: &snow.Context{
SharedMemory: mockSharedMemory,
Log: logging.NoLog{},
},
},
backend: defaultTestBackend(false, mockSharedMemory),
blkIDToState: map[ids.ID]*blockState{
blockID: {
onAcceptState: mockOnAcceptState,
Expand Down Expand Up @@ -869,13 +857,8 @@ func TestBlockReject(t *testing.T) {
lastAccepted: lastAcceptedID,
mempool: mempool,
metrics: metrics.NewMockMetrics(ctrl),
backend: &executor.Backend{
Bootstrapped: true,
Ctx: &snow.Context{
Log: logging.NoLog{},
},
},
state: mockState,
backend: defaultTestBackend(true, nil),
state: mockState,
blkIDToState: map[ids.ID]*blockState{
blockID: {},
},
Expand Down Expand Up @@ -927,13 +910,8 @@ func TestBlockReject(t *testing.T) {
lastAccepted: lastAcceptedID,
mempool: mempool,
metrics: metrics.NewMockMetrics(ctrl),
backend: &executor.Backend{
Bootstrapped: true,
Ctx: &snow.Context{
Log: logging.NoLog{},
},
},
state: mockState,
backend: defaultTestBackend(true, nil),
state: mockState,
blkIDToState: map[ids.ID]*blockState{
blockID: {},
},
Expand Down Expand Up @@ -981,6 +959,7 @@ func TestBlockStatus(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
lastAccepted: blockID,
},
}
Expand All @@ -996,6 +975,7 @@ func TestBlockStatus(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{
blockID: {},
},
Expand All @@ -1017,6 +997,7 @@ func TestBlockStatus(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{},
state: mockState,
},
Expand All @@ -1037,6 +1018,7 @@ func TestBlockStatus(t *testing.T) {
return &Block{
Block: mockBlock,
manager: &manager{
backend: defaultTestBackend(false, nil),
blkIDToState: map[ids.ID]*blockState{},
state: mockState,
},
Expand All @@ -1055,3 +1037,18 @@ func TestBlockStatus(t *testing.T) {
})
}
}

func defaultTestBackend(bootstrapped bool, sharedMemory atomic.SharedMemory) *executor.Backend {
return &executor.Backend{
Bootstrapped: bootstrapped,
Ctx: &snow.Context{
SharedMemory: sharedMemory,
Log: logging.NoLog{},
},
Config: &config.Config{
EUpgradeTime: mockable.MaxTime,
TxFee: 0,
CreateAssetTxFee: 0,
},
}
}
19 changes: 5 additions & 14 deletions vms/avm/block/executor/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/ava-labs/avalanchego/vms/avm/block"
"github.com/ava-labs/avalanchego/vms/avm/state"
"github.com/ava-labs/avalanchego/vms/avm/txs"
"github.com/ava-labs/avalanchego/vms/avm/txs/executor"
)

var (
Expand Down Expand Up @@ -123,7 +122,7 @@ func TestManagerVerifyTx(t *testing.T) {
},
managerF: func(*gomock.Controller) *manager {
return &manager{
backend: &executor.Backend{},
backend: defaultTestBackend(false, nil),
}
},
expectedErr: ErrChainNotSynced,
Expand All @@ -139,9 +138,7 @@ func TestManagerVerifyTx(t *testing.T) {
},
managerF: func(*gomock.Controller) *manager {
return &manager{
backend: &executor.Backend{
Bootstrapped: true,
},
backend: defaultTestBackend(true, nil),
}
},
expectedErr: errTestSyntacticVerifyFail,
Expand All @@ -167,9 +164,7 @@ func TestManagerVerifyTx(t *testing.T) {
state.EXPECT().GetTimestamp().Return(time.Time{})

return &manager{
backend: &executor.Backend{
Bootstrapped: true,
},
backend: defaultTestBackend(true, nil),
state: state,
lastAccepted: lastAcceptedID,
}
Expand Down Expand Up @@ -199,9 +194,7 @@ func TestManagerVerifyTx(t *testing.T) {
state.EXPECT().GetTimestamp().Return(time.Time{})

return &manager{
backend: &executor.Backend{
Bootstrapped: true,
},
backend: defaultTestBackend(true, nil),
state: state,
lastAccepted: lastAcceptedID,
}
Expand Down Expand Up @@ -231,9 +224,7 @@ func TestManagerVerifyTx(t *testing.T) {
state.EXPECT().GetTimestamp().Return(time.Time{})

return &manager{
backend: &executor.Backend{
Bootstrapped: true,
},
backend: defaultTestBackend(true, nil),
state: state,
lastAccepted: lastAcceptedID,
}
Expand Down
Loading
Loading