Skip to content

Commit 7f94d23

Browse files
Remove the vesting module (#4328)
v6.7 rejects `MsgCreateVestingAccount` once its upgrade has run, but kept the module wired in so existing vesting accounts still decode. The only ones left are test accounts: three on pacific-1 holding 2.1 SEI locked until the year 3000 (a full scan of the account store on 24 September found no others, and the scan is repeated before the upgrade), and a few dozen already fully vested ones on atlantic-2. Keeping the module means bank reads and decodes an account on every debit, delegation and EVM balance lookup just to learn that nothing is locked. This deletes `x/auth/vesting`, its protos, `seid tx vesting` and the `add-genesis-account --vesting-*` flags, and adds a `v6.8` upgrade. Its handler runs the new auth 3 to 4 migration, `Migrator.Migrate3to4`, then deletes the `vesting` module version. The migration scans the account store once and rewrites every account stored under a vesting type as the `BaseAccount` it embeds, keeping address, public key, account number and sequence; balances are untouched, so locked coins become spendable. It parses the raw bytes because the vesting account types are gone, and it returns an error, halting the upgrade, rather than leave behind an account the new binary cannot decode. A full scan beats a hardcoded address list because atlantic-2's tx index does not cover its whole history; through the real store stack it costs about 235 ns per account, roughly 25 s of CPU for pacific-1's 102M accounts plus disk reads. `MsgCreateVestingAccount` itself moves to a decode-only `app/retiredvesting` package with its type URL and fields, as `app/retiredibc` and the oracle removal in #4319 do for their types, so transactions from before v6.8 still decode. Bank's `LockedCoins` stays as the one place that used to read the account. It now returns no coins and performs the read only when `RetracesLockedCoinsLookup` reports a re-trace of a block from before v6.8, the same pattern as distribution's `ReadOnlyRewardsUpgrade`, and delegation keeps its account lookup behind the same gate. Without this, the evmrpc mainnet regression replays fail: traces of old precompile calls change gas, and one historical out-of-gas transaction starts succeeding. The gate is only as precise as the `ClosestUpgradeName` the RPC context carries, and `GetClosestUpgrade` returns the next upgrade rather than the one in effect, so once v6.8 is applied most v6.7-era blocks re-trace without the read; v6.7 freeze nodes serve those traces. Live execution skips the read, so transactions and precompile calls that move coins use less gas (1,405 per bank debit in the updated wasm tests), and delegating or undelegating no longer requires the delegator to have an account. This is state-machine breaking and ships behind `v6.8`, which also runs gov's 3 to 4 migration from #4000, so the upgrade moves auth and gov to version 4 and drops `vesting` from the version map. After the upgrade `MsgCreateVestingAccount` still decodes, but its `ValidateBasic` returns v6.7's deprecation error (codespace `vesting`, code 2), so it is refused at CheckTx and in DeliverTx before any fee, where v6.7 charged the fee first. The vesting account types are deliberately not retired: the migration leaves none in state, and registering them would let a genesis file create vesting accounts nothing enforces, so v6.8 nodes cannot decode vesting accounts from before the upgrade and v6.7 freeze nodes serve those historical queries. `x/auth/keeper/legacy_vesting.go` and the gate in `x/bank/keeper/view.go` deserve the closest look. Validated with the new v6.8 in-process tests, the offline source, target and reopen phases run against `release/v6.7`, `make upgrade-test-vet`, the affected package suites, and the live v6.7 to v6.8 cross-version run in CI's Minor release boundary job. --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0a2649b commit 7f94d23

65 files changed

Lines changed: 1881 additions & 5932 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎app/app.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ import (
5555
authsims "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/simulation"
5656
authtx "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/tx"
5757
authtypes "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/types"
58-
"github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/vesting"
59-
vestingtypes "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/vesting/types"
6058
"github.com/sei-protocol/sei-chain/sei-cosmos/x/authz"
6159
authzkeeper "github.com/sei-protocol/sei-chain/sei-cosmos/x/authz/keeper"
6260
authzmodule "github.com/sei-protocol/sei-chain/sei-cosmos/x/authz/module"
@@ -208,7 +206,6 @@ var (
208206
slashing.AppModuleBasic{},
209207
upgrade.AppModuleBasic{},
210208
evidence.AppModuleBasic{},
211-
vesting.AppModuleBasic{},
212209
evm.AppModuleBasic{},
213210
wasm.AppModuleBasic{},
214211
epochmodule.AppModuleBasic{},
@@ -282,6 +279,7 @@ const (
282279
capabilityModuleName = "capability"
283280
feegrantModuleName = "feegrant"
284281
transferModuleName = "transfer"
282+
vestingModuleName = "vesting"
285283

286284
// NewHeadsNotifierCapacity bounds the in-process eth_newHeads
287285
// notifier buffer. Capacity 1 pairs with the notifier's
@@ -816,7 +814,6 @@ func New(
816814
encodingConfig.TxConfig,
817815
),
818816
auth.NewAppModule(appCodec, app.AccountKeeper, nil),
819-
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper, app.UpgradeKeeper),
820817
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
821818
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
822819
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
@@ -876,7 +873,6 @@ func New(
876873
slashingtypes.ModuleName,
877874
govtypes.ModuleName,
878875
minttypes.ModuleName,
879-
vestingtypes.ModuleName,
880876
genutiltypes.ModuleName,
881877
evidencetypes.ModuleName,
882878
authz.ModuleName,

‎app/encoding.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/sei-protocol/sei-chain/app/params"
55
retiredibcgov "github.com/sei-protocol/sei-chain/app/retiredibc/gov"
66
"github.com/sei-protocol/sei-chain/app/retiredoracle"
7+
"github.com/sei-protocol/sei-chain/app/retiredvesting"
78
"github.com/sei-protocol/sei-chain/sei-cosmos/std"
89
)
910

@@ -17,6 +18,7 @@ func MakeEncodingConfig() params.EncodingConfig {
1718
retiredibcgov.RegisterInterfaces(encodingConfig.InterfaceRegistry)
1819
retiredoracle.RegisterInterfaces(encodingConfig.InterfaceRegistry)
1920
retiredoracle.RegisterLegacyAminoCodec(encodingConfig.Amino)
21+
retiredvesting.RegisterInterfaces(encodingConfig.InterfaceRegistry)
2022
return encodingConfig
2123
}
2224

@@ -30,5 +32,6 @@ func MakeLegacyEncodingConfig() params.EncodingConfig {
3032
retiredibcgov.RegisterInterfaces(encodingConfig.InterfaceRegistry)
3133
retiredoracle.RegisterInterfaces(encodingConfig.InterfaceRegistry)
3234
retiredoracle.RegisterLegacyAminoCodec(encodingConfig.Amino)
35+
retiredvesting.RegisterInterfaces(encodingConfig.InterfaceRegistry)
3336
return encodingConfig
3437
}

‎app/retiredvesting/codec.go‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package retiredvesting
2+
3+
import (
4+
"github.com/sei-protocol/sei-chain/sei-cosmos/codec"
5+
codectypes "github.com/sei-protocol/sei-chain/sei-cosmos/codec/types"
6+
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
7+
)
8+
9+
// RegisterInterfaces registers MsgCreateVestingAccount as an sdk.Msg implementation.
10+
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
11+
registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateVestingAccount{})
12+
}
13+
14+
// amino must not register a name for MsgCreateVestingAccount: a registered name
15+
// wraps the JSON GetSignBytes returns in a type envelope, changing the bytes
16+
// the message was signed over.
17+
var amino = codec.NewLegacyAmino()

‎app/retiredvesting/errors.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package retiredvesting
2+
3+
import "github.com/sei-protocol/sei-chain/sei-cosmos/types/errors"
4+
5+
// ErrDeprecated is the error every retired vesting message fails validation with.
6+
var ErrDeprecated = errors.Register(ModuleName, 2, "vesting module is deprecated; creating new vesting accounts is disabled")

‎app/retiredvesting/msgs.go‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Package retiredvesting provides decode-only compatibility for retired vesting transactions.
2+
package retiredvesting
3+
4+
import (
5+
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
6+
)
7+
8+
const (
9+
ModuleName = "vesting"
10+
TypeMsgCreateVestingAccount = "msg_create_vesting_account"
11+
)
12+
13+
var _ sdk.Msg = (*MsgCreateVestingAccount)(nil)
14+
15+
func (msg MsgCreateVestingAccount) Route() string { return ModuleName }
16+
17+
func (msg MsgCreateVestingAccount) Type() string { return TypeMsgCreateVestingAccount }
18+
19+
func (msg MsgCreateVestingAccount) GetSignBytes() []byte {
20+
return sdk.MustSortJSON(amino.MustMarshalJSON(&msg))
21+
}
22+
23+
func (msg MsgCreateVestingAccount) GetSigners() []sdk.AccAddress {
24+
from, err := sdk.AccAddressFromBech32(msg.FromAddress)
25+
if err != nil {
26+
panic(err)
27+
}
28+
return []sdk.AccAddress{from}
29+
}
30+
31+
func (msg MsgCreateVestingAccount) ValidateBasic() error { return ErrDeprecated }
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
package retiredvesting_test
2+
3+
import (
4+
"crypto/sha256"
5+
"encoding/hex"
6+
"strings"
7+
"testing"
8+
9+
"github.com/stretchr/testify/require"
10+
"google.golang.org/protobuf/encoding/protowire"
11+
12+
seiapp "github.com/sei-protocol/sei-chain/app"
13+
appparams "github.com/sei-protocol/sei-chain/app/params"
14+
"github.com/sei-protocol/sei-chain/app/retiredvesting"
15+
codectypes "github.com/sei-protocol/sei-chain/sei-cosmos/codec/types"
16+
sdk "github.com/sei-protocol/sei-chain/sei-cosmos/types"
17+
sdkerrors "github.com/sei-protocol/sei-chain/sei-cosmos/types/errors"
18+
txtypes "github.com/sei-protocol/sei-chain/sei-cosmos/types/tx"
19+
authtestutil "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/testutil"
20+
authtypes "github.com/sei-protocol/sei-chain/sei-cosmos/x/auth/types"
21+
)
22+
23+
const (
24+
msgCreateVestingAccountTypeURL = "/cosmos.vesting.v1beta1.MsgCreateVestingAccount"
25+
// vestingEndTime is 3000-01-01, the end time of every vesting account on pacific-1.
26+
vestingEndTime int64 = 32_503_680_000
27+
28+
// pacific1VestingTxHex is the pacific-1 transaction pacific1VestingTxHash,
29+
// included at height 228,422,853, which created a delayed vesting account.
30+
pacific1VestingTxHash = "2838170E42486FE03E4765DDD0C8BC3559AADB1F09B2882C66C45B5906940709"
31+
pacific1VestingTxHex = "0aa6010aa3010a2f2f636f736d6f732e76657374696e672e763162657461312e4d736743726561746556657374696e674163636f756e7412700a2a736569316d366d30323634303930653761666e7030716b32616d766565306339363434637437756c6836122a7365693167613833336d6a366a633664326c7965366a3834737475673968326d7078637875797735616b1a0e0a04757365691206313030303030208098fb8a79280112650a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a2102b4f18f4ea5bc446a46d82d42d0abfe9b1fa4397b037cf7da5ca07dd1c967ace612040a02080112130a0d0a04757365691205333030303010e0a7121a409963a065d4c35e70639703a1d086dfe399ebe8df345fd583ad388055c4d5dba22af9a57c29e026e014d436a67e097ec7aff741cfe9c5ccf7d7fc91a0774187ec"
32+
)
33+
34+
var appEncodings = []struct {
35+
name string
36+
config func() appparams.EncodingConfig
37+
}{
38+
{"app", seiapp.MakeEncodingConfig},
39+
{"legacy app", seiapp.MakeLegacyEncodingConfig},
40+
}
41+
42+
// msgCreateVestingAccountWithEveryField returns a MsgCreateVestingAccount with
43+
// every field set, including the admin the pacific-1 fixture leaves unset, and
44+
// its encoding under cosmos/vesting/v1beta1/tx.proto written field by field
45+
// rather than by the retired type.
46+
func msgCreateVestingAccountWithEveryField(t *testing.T) (*retiredvesting.MsgCreateVestingAccount, []byte) {
47+
t.Helper()
48+
msg := &retiredvesting.MsgCreateVestingAccount{
49+
FromAddress: sdk.AccAddress("vesting-from-address").String(),
50+
ToAddress: sdk.AccAddress("vesting-to---address").String(),
51+
Amount: sdk.NewCoins(sdk.NewInt64Coin("usei", 100_000)),
52+
EndTime: vestingEndTime,
53+
Delayed: true,
54+
Admin: sdk.AccAddress("vesting-admin-addres").String(),
55+
}
56+
coin, err := msg.Amount[0].Marshal()
57+
require.NoError(t, err)
58+
encoded := protowire.AppendString(protowire.AppendTag(nil, 1, protowire.BytesType), msg.FromAddress)
59+
encoded = protowire.AppendString(protowire.AppendTag(encoded, 2, protowire.BytesType), msg.ToAddress)
60+
encoded = protowire.AppendBytes(protowire.AppendTag(encoded, 3, protowire.BytesType), coin)
61+
encoded = protowire.AppendVarint(protowire.AppendTag(encoded, 4, protowire.VarintType), uint64(vestingEndTime))
62+
encoded = protowire.AppendVarint(protowire.AppendTag(encoded, 5, protowire.VarintType), 1)
63+
encoded = protowire.AppendString(protowire.AppendTag(encoded, 6, protowire.BytesType), msg.Admin)
64+
return msg, encoded
65+
}
66+
67+
// txCarrying encodes a transaction whose only message is the
68+
// MsgCreateVestingAccount encoding msg, with a placeholder signature.
69+
func txCarrying(t *testing.T, msg []byte) []byte {
70+
t.Helper()
71+
body, err := (&txtypes.TxBody{
72+
Messages: []*codectypes.Any{{TypeUrl: msgCreateVestingAccountTypeURL, Value: msg}},
73+
}).Marshal()
74+
require.NoError(t, err)
75+
authInfo, err := (&txtypes.AuthInfo{
76+
Fee: &txtypes.Fee{Amount: sdk.NewCoins(sdk.NewInt64Coin("usei", 200_000)), GasLimit: 1_000_000},
77+
}).Marshal()
78+
require.NoError(t, err)
79+
txBytes, err := (&txtypes.TxRaw{
80+
BodyBytes: body,
81+
AuthInfoBytes: authInfo,
82+
Signatures: [][]byte{make([]byte, 64)},
83+
}).Marshal()
84+
require.NoError(t, err)
85+
return txBytes
86+
}
87+
88+
// decodeMsgCreateVestingAccount decodes txBytes with the transaction config of
89+
// config and returns its only message, which must be a MsgCreateVestingAccount.
90+
func decodeMsgCreateVestingAccount(t *testing.T, config func() appparams.EncodingConfig, txBytes []byte) *retiredvesting.MsgCreateVestingAccount {
91+
t.Helper()
92+
tx, err := config().TxConfig.TxDecoder()(txBytes)
93+
require.NoError(t, err)
94+
require.Len(t, tx.GetMsgs(), 1)
95+
msg, ok := tx.GetMsgs()[0].(*retiredvesting.MsgCreateVestingAccount)
96+
require.True(t, ok, "decoded %T", tx.GetMsgs()[0])
97+
return msg
98+
}
99+
100+
// TestPacific1MsgCreateVestingAccountDecodes decodes a MsgCreateVestingAccount
101+
// transaction pacific-1 included through both app transaction configs, and
102+
// requires the retired type to carry the fields it set and encode the message
103+
// back to the bytes the chain included.
104+
func TestPacific1MsgCreateVestingAccountDecodes(t *testing.T) {
105+
txBytes, err := hex.DecodeString(pacific1VestingTxHex)
106+
require.NoError(t, err)
107+
digest := sha256.Sum256(txBytes)
108+
require.Equal(t, pacific1VestingTxHash, strings.ToUpper(hex.EncodeToString(digest[:])))
109+
var raw txtypes.TxRaw
110+
require.NoError(t, raw.Unmarshal(txBytes))
111+
var body txtypes.TxBody
112+
require.NoError(t, body.Unmarshal(raw.BodyBytes))
113+
require.Len(t, body.Messages, 1)
114+
115+
want := &retiredvesting.MsgCreateVestingAccount{
116+
FromAddress: "sei1m6m0264090e7afnp0qk2amvee0c9644ct7ulh6",
117+
ToAddress: "sei1ga833mj6jc6d2lye6j84stug9h2mpxcxuyw5ak",
118+
Amount: sdk.NewCoins(sdk.NewInt64Coin("usei", 100_000)),
119+
EndTime: vestingEndTime,
120+
Delayed: true,
121+
}
122+
for _, encoding := range appEncodings {
123+
t.Run(encoding.name, func(t *testing.T) {
124+
got := decodeMsgCreateVestingAccount(t, encoding.config, txBytes)
125+
require.True(t, want.Equal(got), "decoded %v", got)
126+
reencoded, err := got.Marshal()
127+
require.NoError(t, err)
128+
require.Equal(t, body.Messages[0].Value, reencoded)
129+
})
130+
}
131+
}
132+
133+
// TestMsgCreateVestingAccountWithEveryFieldDecodes decodes a transaction
134+
// carrying a MsgCreateVestingAccount with every field set through both app
135+
// transaction configs, and requires the retired type to carry every field and
136+
// encode it back byte for byte.
137+
func TestMsgCreateVestingAccountWithEveryFieldDecodes(t *testing.T) {
138+
want, encoded := msgCreateVestingAccountWithEveryField(t)
139+
txBytes := txCarrying(t, encoded)
140+
for _, encoding := range appEncodings {
141+
t.Run(encoding.name, func(t *testing.T) {
142+
got := decodeMsgCreateVestingAccount(t, encoding.config, txBytes)
143+
require.True(t, want.Equal(got), "decoded %v", got)
144+
reencoded, err := got.Marshal()
145+
require.NoError(t, err)
146+
require.Equal(t, encoded, reencoded)
147+
})
148+
}
149+
}
150+
151+
// TestRetiredMsgCreateVestingAccountIsRefused requires the retired message to
152+
// keep its type URL and signer, and to fail validation in codespace vesting
153+
// with code 2.
154+
func TestRetiredMsgCreateVestingAccountIsRefused(t *testing.T) {
155+
msg, _ := msgCreateVestingAccountWithEveryField(t)
156+
require.Equal(t, msgCreateVestingAccountTypeURL, sdk.MsgTypeURL(msg))
157+
require.Equal(t, []sdk.AccAddress{sdk.AccAddress("vesting-from-address")}, msg.GetSigners())
158+
159+
err := msg.ValidateBasic()
160+
require.ErrorIs(t, err, retiredvesting.ErrDeprecated)
161+
codespace, code, _ := sdkerrors.ABCIInfo(err, false)
162+
require.Equal(t, "vesting", codespace)
163+
require.EqualValues(t, 2, code)
164+
}
165+
166+
// TestRetiredVestingDoesNotRestoreAccountsOrModule requires the app codec to
167+
// keep refusing every vesting account type, and the vesting module to stay
168+
// unregistered.
169+
func TestRetiredVestingDoesNotRestoreAccountsOrModule(t *testing.T) {
170+
registry := seiapp.MakeEncodingConfig().InterfaceRegistry
171+
for _, typeURL := range authtestutil.LegacyVestingAccountTypeURLs {
172+
var account authtypes.AccountI
173+
err := registry.UnpackAny(&codectypes.Any{TypeUrl: typeURL}, &account)
174+
require.ErrorContains(t, err, "no concrete type registered", typeURL)
175+
}
176+
_, registered := seiapp.ModuleBasics[retiredvesting.ModuleName]
177+
require.False(t, registered)
178+
}

0 commit comments

Comments
 (0)