diff --git a/core/state/accounts/accounts.go b/core/state/accounts/accounts.go index 58e548b8c..b1e7cd478 100644 --- a/core/state/accounts/accounts.go +++ b/core/state/accounts/accounts.go @@ -8,6 +8,7 @@ import ( "github.com/MinterTeam/minter-go-node/formula" "github.com/MinterTeam/minter-go-node/rlp" "github.com/MinterTeam/minter-go-node/tree" + "github.com/MinterTeam/minter-go-node/upgrades" "math/big" "sort" "sync" @@ -176,7 +177,7 @@ func (a *Accounts) ExistsMultisig(msigAddress types.Address) bool { return false } -func (a *Accounts) CreateMultisig(weights []uint, addresses []types.Address, threshold uint) types.Address { +func (a *Accounts) CreateMultisig(weights []uint, addresses []types.Address, threshold uint, height uint64) types.Address { msig := Multisig{ Weights: weights, Threshold: threshold, @@ -201,6 +202,10 @@ func (a *Accounts) CreateMultisig(weights []uint, addresses []types.Address, thr account.MultisigData = msig account.markDirty(account.address) + if height > upgrades.UpgradeBlock1 { + account.isDirty = true + } + a.setToMap(address, account) return address diff --git a/core/state/state.go b/core/state/state.go index 007699d7c..bffdc9cee 100644 --- a/core/state/state.go +++ b/core/state/state.go @@ -151,7 +151,7 @@ func (s *State) Import(state types.AppState) error { for _, a := range state.Accounts { if a.MultisigData != nil { - s.Accounts.CreateMultisig(a.MultisigData.Weights, a.MultisigData.Addresses, a.MultisigData.Threshold) + s.Accounts.CreateMultisig(a.MultisigData.Weights, a.MultisigData.Addresses, a.MultisigData.Threshold, 1) } s.Accounts.SetNonce(a.Address, a.Nonce) diff --git a/core/transaction/create_multisig.go b/core/transaction/create_multisig.go index 7fb14f8f9..ef6d08668 100644 --- a/core/transaction/create_multisig.go +++ b/core/transaction/create_multisig.go @@ -163,7 +163,7 @@ func (data CreateMultisigData) Run(tx *Transaction, context *state.State, isChec context.Accounts.SubBalance(sender, tx.GasCoin, commission) context.Accounts.SetNonce(sender, tx.Nonce) - context.Accounts.CreateMultisig(data.Weights, data.Addresses, data.Threshold) + context.Accounts.CreateMultisig(data.Weights, data.Addresses, data.Threshold, currentBlock) } tags := kv.Pairs{ diff --git a/core/transaction/create_multisig_test.go b/core/transaction/create_multisig_test.go index 072dfaebf..b00c135b4 100644 --- a/core/transaction/create_multisig_test.go +++ b/core/transaction/create_multisig_test.go @@ -233,7 +233,7 @@ func TestCreateExistingMultisigTx(t *testing.T) { }, } - cState.Accounts.CreateMultisig(data.Weights, data.Addresses, data.Threshold) + cState.Accounts.CreateMultisig(data.Weights, data.Addresses, data.Threshold, 1) encodedData, err := rlp.EncodeToBytes(data) if err != nil { diff --git a/core/transaction/executor_test.go b/core/transaction/executor_test.go index 5ee43d219..5c473d4ae 100644 --- a/core/transaction/executor_test.go +++ b/core/transaction/executor_test.go @@ -231,7 +231,7 @@ func TestMultiSigTx(t *testing.T) { addr := crypto.PubkeyToAddress(privateKey.PublicKey) coin := types.GetBaseCoin() - msigAddress := cState.Accounts.CreateMultisig([]uint{1}, []types.Address{addr}, 1) + msigAddress := cState.Accounts.CreateMultisig([]uint{1}, []types.Address{addr}, 1, 1) cState.Accounts.AddBalance(msigAddress, coin, helpers.BipToPip(big.NewInt(1000000))) txData := SendData{ @@ -275,7 +275,7 @@ func TestMultiSigDoubleSignTx(t *testing.T) { addr := crypto.PubkeyToAddress(privateKey.PublicKey) coin := types.GetBaseCoin() - msigAddress := cState.Accounts.CreateMultisig([]uint{1, 1}, []types.Address{addr, {}}, 2) + msigAddress := cState.Accounts.CreateMultisig([]uint{1, 1}, []types.Address{addr, {}}, 2, 1) cState.Accounts.AddBalance(msigAddress, coin, helpers.BipToPip(big.NewInt(1000000))) txData := SendData{ @@ -323,7 +323,7 @@ func TestMultiSigTooManySignsTx(t *testing.T) { addr := crypto.PubkeyToAddress(privateKey.PublicKey) coin := types.GetBaseCoin() - msigAddress := cState.Accounts.CreateMultisig([]uint{1, 1}, []types.Address{addr, {}}, 2) + msigAddress := cState.Accounts.CreateMultisig([]uint{1, 1}, []types.Address{addr, {}}, 2, 1) cState.Accounts.AddBalance(msigAddress, coin, helpers.BipToPip(big.NewInt(1000000))) txData := SendData{ @@ -374,7 +374,7 @@ func TestMultiSigNotEnoughTx(t *testing.T) { addr := crypto.PubkeyToAddress(privateKey.PublicKey) coin := types.GetBaseCoin() - msigAddress := cState.Accounts.CreateMultisig([]uint{1}, []types.Address{addr}, 2) + msigAddress := cState.Accounts.CreateMultisig([]uint{1}, []types.Address{addr}, 2, 1) cState.Accounts.AddBalance(msigAddress, coin, helpers.BipToPip(big.NewInt(1000000))) txData := SendData{ @@ -418,7 +418,7 @@ func TestMultiSigIncorrectSignsTx(t *testing.T) { addr := crypto.PubkeyToAddress(privateKey.PublicKey) coin := types.GetBaseCoin() - msigAddress := cState.Accounts.CreateMultisig([]uint{1}, []types.Address{addr}, 1) + msigAddress := cState.Accounts.CreateMultisig([]uint{1}, []types.Address{addr}, 1, 1) cState.Accounts.AddBalance(msigAddress, coin, helpers.BipToPip(big.NewInt(1000000))) txData := SendData{ diff --git a/core/transaction/send_test.go b/core/transaction/send_test.go index f523ed8c2..97378715f 100644 --- a/core/transaction/send_test.go +++ b/core/transaction/send_test.go @@ -82,7 +82,7 @@ func TestSendMultisigTx(t *testing.T) { coin := types.GetBaseCoin() - msig := cState.Accounts.CreateMultisig([]uint{1, 1}, []types.Address{addr1, addr2}, 1) + msig := cState.Accounts.CreateMultisig([]uint{1, 1}, []types.Address{addr1, addr2}, 1, 1) cState.Accounts.AddBalance(msig, coin, helpers.BipToPip(big.NewInt(1000000))) @@ -150,7 +150,7 @@ func TestSendFailedMultisigTx(t *testing.T) { coin := types.GetBaseCoin() - msig := cState.Accounts.CreateMultisig([]uint{1, 3}, []types.Address{addr1, addr2}, 3) + msig := cState.Accounts.CreateMultisig([]uint{1, 3}, []types.Address{addr1, addr2}, 3, 1) cState.Accounts.AddBalance(msig, coin, helpers.BipToPip(big.NewInt(1000000))) diff --git a/upgrades/blocks.go b/upgrades/blocks.go index 3922ee05b..65edacff2 100644 --- a/upgrades/blocks.go +++ b/upgrades/blocks.go @@ -1 +1,3 @@ package upgrades + +const UpgradeBlock1 = 5000 diff --git a/upgrades/grace.go b/upgrades/grace.go index d0b40e4c5..98540e9f6 100644 --- a/upgrades/grace.go +++ b/upgrades/grace.go @@ -2,6 +2,7 @@ package upgrades var gracePeriods = []*gracePeriod{ NewGracePeriod(1, 120), + NewGracePeriod(UpgradeBlock1, UpgradeBlock1+120), } type gracePeriod struct { diff --git a/version/version.go b/version/version.go index d367924e4..e23069a1e 100755 --- a/version/version.go +++ b/version/version.go @@ -11,7 +11,7 @@ const ( var ( // Must be a string because scripts like dist.sh read this file. - Version = "1.1.0" + Version = "1.1.1" // GitCommit is the current HEAD set using ldflags. GitCommit string