From 039a22e9e338756d089b5009c49499b071a7b644 Mon Sep 17 00:00:00 2001 From: Vanessa Violet Date: Thu, 6 Jul 2023 11:20:23 +0000 Subject: [PATCH] change the old kernel node group to universal mint group --- common/encoding_test.go | 4 +-- common/mint.go | 10 +++---- custodian/README.md | 59 ----------------------------------------- kernel/election.go | 2 +- kernel/mint.go | 4 +-- kernel/node.go | 2 +- rpc/mint.go | 2 +- 7 files changed, 12 insertions(+), 71 deletions(-) delete mode 100644 custodian/README.md diff --git a/common/encoding_test.go b/common/encoding_test.go index 5516b46b5..7fdc8d5ea 100644 --- a/common/encoding_test.go +++ b/common/encoding_test.go @@ -116,7 +116,7 @@ func TestCommonDataEncoding(t *testing.T) { mint := &MintDistribution{ MintData: MintData{ - Group: MintGroupKernelNode, + Group: MintGroupUniversal, Batch: 123, Amount: NewIntegerFromString("3.14159"), }, @@ -129,7 +129,7 @@ func TestCommonDataEncoding(t *testing.T) { assert.Equal("0000000028b52ffd0300c118533ca10100777700010001000000000000007b000412b9af98eea889c227076f8c62106b59a478e043c0030392f3be0f5d714ed27953cb2668", hex.EncodeToString(enc)) res, err := DecompressUnmarshalMintDistribution(enc) assert.Nil(err) - assert.Equal(MintGroupKernelNode, res.Group) + assert.Equal(MintGroupUniversal, res.Group) assert.Equal(uint64(123), res.Batch) assert.Equal("3.14159000", res.Amount.String()) assert.Equal("eea889c227076f8c62106b59a478e043c0030392f3be0f5d714ed27953cb2668", res.Transaction.String()) diff --git a/common/mint.go b/common/mint.go index f92a09212..f33ba5b1f 100644 --- a/common/mint.go +++ b/common/mint.go @@ -7,7 +7,7 @@ import ( ) const ( - MintGroupKernelNode = "KERNELNODE" + MintGroupUniversal = "UNIVERSAL" ) type MintData struct { @@ -42,7 +42,7 @@ func (tx *VersionedTransaction) validateMint(store DataStore) error { } mint := tx.Inputs[0].Mint - if mint.Group != MintGroupKernelNode { + if mint.Group != MintGroupUniversal { return fmt.Errorf("invalid mint group %s", mint.Group) } @@ -65,7 +65,7 @@ func (tx *VersionedTransaction) validateMint(store DataStore) error { func (tx *Transaction) AddKernelNodeMintInput(batch uint64, amount Integer) { tx.Inputs = append(tx.Inputs, &Input{ Mint: &MintData{ - Group: MintGroupKernelNode, + Group: MintGroupUniversal, Batch: batch, Amount: amount, }, @@ -87,7 +87,7 @@ func DecompressUnmarshalMintDistribution(b []byte) (*MintDistribution, error) { func (m *MintDistribution) Marshal() []byte { enc := NewMinimumEncoder() switch m.Group { - case MintGroupKernelNode: + case MintGroupUniversal: enc.WriteUint16(0x1) default: panic(m.Group) @@ -116,7 +116,7 @@ func UnmarshalMintDistribution(b []byte) (*MintDistribution, error) { } switch group { case 0x1: - m.Group = MintGroupKernelNode + m.Group = MintGroupUniversal default: return nil, fmt.Errorf("invalid mint distribution group %d", group) } diff --git a/custodian/README.md b/custodian/README.md deleted file mode 100644 index c9c330a95..000000000 --- a/custodian/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# Mixin Custodian - -The custodian connects to a private Mixin Kernel node to get the latest custodian list, we call it _M_, all the custodians in _M_ will do a DKG. - -Because the kernel nodes change on a daily basis, the custodian list may change to _Mc_. The custodians will not do a DKG evolution unless, _Nd_ the number of differences between _Mc_ and _M_, satisfies _Nd > M/7_. - -After a new DKG, the custodians transfer assets to _Mc_, and _Mc_ becomes the new _M_. - -And all custodians pass messages to each other through a secure end-to-end encrypted Mixin Messenger chat group. - -## Evolution - -All kernel nodes should have the consensus that when the custodian evolution threshold reached, they should wait for the new custodian key generation, until then, no nodes could be removed or pledged. - -The custodian key should be bind to network-id and the current nodes transactions queue, after the generation, there should be a custodian key evolution transaction snapshot in the kernel. - -The evolution transaction may have multiple outputs typed as CustodianEvolution, each output has public key, signature, algorithm and curve. Thus enable a single evolution transaction to update different kind of DKG keys. The signature algorithm can be Schnorr or BLS, and curve may be secp256k1, edwards25519, or anything. - -## Deposit - -A custodian deposit transaction submitted to the Kernel will be credited to the custodian DKG address, and all custodian nodes should check this transaction on Bitcoin or Ethereum blockchains respectively, through a proxy node. - -After a valid custodian deposit, the custodian should submit a CustodianDepositAccepted transaction, similar to the domain deposit transaction format. - -## Withdrawal - -A custodian withdrawal transaction submitted to the Kernel triggers the custodian to verify and submit the exact withdrawal transaction on Bitcoin or Ethereum. - -The custodian withdrawal transaction can only be submitted by the domain, then the custodian should ensure this domain has enough balance, and the balance not below some threshold. - -Let's assume the kernel has a total balance of 100BTC in the UTXOs, and the domain can't withdraw unless the remaining is more than 70BTC. - -Whenever a UTXO is spent on the withdrawal submit transaction, the total balance is dropped, so the threshold, then the domain is able to withdraw assets instantly. - -## Bitcoin - -Use a taproot address as custodian, and transfer coins to new address whenever a DKG evolution happens. This also applies to all Bitcoin similar blockchains without smart contracts. - -## Ethereum - -Use a contract as custodian which is owned by the DKG address, and change the owner to new address whenever a DKG evolution happens. This also applies to all smart contracts enabled blockchains. - -## NOTICE - -custodian <---> private proxy <---> kernel and mm - -0. Never allow any incoming traffic. -1. Only allow outbound traffic to the proxy. -2. Never deploy this on public servers. -3. Never connect this to public Mixin Kernel nodes. -4. May use the Mixin Messenger API as a trust source to verify the custodian list. - -## Self Custodian - -Besides the general domain custodian, any people _P_ can make a self custodian request to have part of the key to custody some money in a custodian address owned by the kernel, domain and _P_ together as a 2/3 multisig. This self custodian will be charged for creation and any transactions. - -The self custodian is simply a normal UTXO, and the asset locked in the self custodian multisig address. This UTXO can be transferred freely in the same self custodian, and is not allowed to be moved to another self custodian. This UTXO must be released from the multisig address to the domain custodian before it is allowed to be transformed to a general kernel UTXO. - -The self custodian should provide a single key, this key can be generated from anywhere, and are suggested to use the same domain custodian DKG process to generate this key. diff --git a/kernel/election.go b/kernel/election.go index bde07d500..ee16b41b1 100644 --- a/kernel/election.go +++ b/kernel/election.go @@ -359,7 +359,7 @@ func (node *Node) validateNodeAcceptSnapshot(s *common.Snapshot, tx *common.Vers func (node *Node) reloadConsensusState(s *common.Snapshot, tx *common.VersionedTransaction) error { if tx.TransactionType() == common.TransactionTypeMint { - mint, err := node.persistStore.ReadLastMintDistribution(common.MintGroupKernelNode) + mint, err := node.persistStore.ReadLastMintDistribution(common.MintGroupUniversal) if err != nil { return err } diff --git a/kernel/mint.go b/kernel/mint.go index 9268f0fbd..51a12b66e 100644 --- a/kernel/mint.go +++ b/kernel/mint.go @@ -116,7 +116,7 @@ func (node *Node) MintLoop() { } func (node *Node) PoolSize() (common.Integer, error) { - dist, err := node.persistStore.ReadLastMintDistribution(common.MintGroupKernelNode) + dist, err := node.persistStore.ReadLastMintDistribution(common.MintGroupUniversal) if err != nil { return common.Zero, err } @@ -296,7 +296,7 @@ func (node *Node) checkMintPossibility(timestamp uint64, validateOnly bool) (int light := total.Div(10) full := light.Mul(9) - dist, err := node.persistStore.ReadLastMintDistribution(common.MintGroupKernelNode) + dist, err := node.persistStore.ReadLastMintDistribution(common.MintGroupUniversal) if err != nil { logger.Verbosef("ReadLastMintDistribution ERROR %s\n", err) return 0, common.Zero diff --git a/kernel/node.go b/kernel/node.go index 7fab9c5c8..e34465676 100644 --- a/kernel/node.go +++ b/kernel/node.go @@ -87,7 +87,7 @@ func SetupNode(custom *config.Custom, persistStore storage.Store, cacheStore *ri node.LoadNodeConfig() - mint, err := node.persistStore.ReadLastMintDistribution(common.MintGroupKernelNode) + mint, err := node.persistStore.ReadLastMintDistribution(common.MintGroupUniversal) if err != nil { return nil, fmt.Errorf("ReadLastMintDistribution() => %v", err) } diff --git a/rpc/mint.go b/rpc/mint.go index 90ac7ed57..b6244846e 100644 --- a/rpc/mint.go +++ b/rpc/mint.go @@ -47,7 +47,7 @@ func listMintDistributions(store storage.Store, params []any) ([]map[string]any, return nil, err } - mints, transactions, err := store.ReadMintDistributions(common.MintGroupKernelNode, offset, count) + mints, transactions, err := store.ReadMintDistributions(common.MintGroupUniversal, offset, count) return mintsToMap(mints, transactions, tx), err }