From ba64caac485b0e2920e30f571eb14ce4354fd2f3 Mon Sep 17 00:00:00 2001 From: txhsl <799498265@qq.com> Date: Thu, 6 Feb 2025 18:42:41 +0800 Subject: [PATCH 1/2] consensus/dbft: fix preblock dkg round index --- consensus/dbft/dbft.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/dbft/dbft.go b/consensus/dbft/dbft.go index 8b087e3320..a738c7a44b 100644 --- a/consensus/dbft/dbft.go +++ b/consensus/dbft/dbft.go @@ -1260,7 +1260,7 @@ func (c *DBFT) newPreBlockFromContext(sealingProposal *types.Header) *PreBlock { // called by dBFT library to properly initialize PreBlock's transactions. res := &PreBlock{ header: h, - dkgRound: uint32(c.dkgSnapshot.Round), + dkgRound: uint32(c.dkgSnapshot.Round - 1), enforceECDSASignatures: c.config.enforceECDSASignatures, } // Withdrawals are temporary empty if Shanghai is passed. From 7773fbe6226986322e5c742acd8f0ff7f9ab67d4 Mon Sep 17 00:00:00 2001 From: txhsl <799498265@qq.com> Date: Thu, 6 Feb 2025 18:45:53 +0800 Subject: [PATCH 2/2] antimev: use node0 in generation test Use a watch-only node, so the nonce 0 is always valid. --- antimev/tpke_test.go | 12 ++++++------ privnet/README.md | 24 ++++++------------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/antimev/tpke_test.go b/antimev/tpke_test.go index b9777a2088..64f216b3fc 100644 --- a/antimev/tpke_test.go +++ b/antimev/tpke_test.go @@ -140,7 +140,7 @@ func TestGenerateEncryptedTx(t *testing.T) { kss[i] = NewKeyStore(filepath.Join("..", "privnet", "seven", fmt.Sprintf("node%d", i+1), "antimev-keystore")) require.NoError(t, kss[i].Load(accounts[i+1].pwd)) } - tx := buildTransferFromPriv1(t) + tx := buildTransferFromPriv0(t) // Encrypt transaction. buf := bytes.NewBuffer(nil) require.NoError(t, tx.EncodeRLP(buf)) @@ -176,12 +176,12 @@ func TestGenerateEncryptedTx(t *testing.T) { require.True(t, bytes.Equal(results[0], msg), hex.EncodeToString(results[0]), hex.EncodeToString(msg)) } -// buildTransferFromPriv1 returns a signed transaction that transfers 1 wei from -// node1 to node1 with nonce 0. -func buildTransferFromPriv1(t *testing.T) *types.Transaction { - ks := keystore.NewKeyStore(filepath.Join("..", "privnet", "seven", "node1", "keystore"), keystore.StandardScryptN, keystore.StandardScryptP) +// buildTransferFromPriv0 returns a signed transaction that transfers 1 wei from +// node0 to node0 with nonce 0. +func buildTransferFromPriv0(t *testing.T) *types.Transaction { + ks := keystore.NewKeyStore(filepath.Join("..", "privnet", "seven", "node0", "keystore"), keystore.StandardScryptN, keystore.StandardScryptP) acc := ks.Accounts()[0] - require.NoError(t, ks.Unlock(acc, accounts[1].pwd)) + require.NoError(t, ks.Unlock(acc, accounts[0].pwd)) // These variables are taken based on experience of previously generated transfer // transactions for privnet. This transaction has nonce set to 0, hence it's valid diff --git a/privnet/README.md b/privnet/README.md index 42aa017f65..c9f9f9fbc8 100644 --- a/privnet/README.md +++ b/privnet/README.md @@ -332,29 +332,17 @@ gas: 30000 Example of Envelope transaction with encrypted data inside. Encrypted data is a hex-encoded byte slice containing 4-bytes length prefix identifying Envelope -transaction followed by 192-byte length CipherText got after transaction encryption -followed by the encrypted transaction itself (a simple 1 wei transfer from CN1 to CN1 -with zero nonce signed by CN1) encrypted by a shared public key of 4-CNs privnet: +transaction followed by 4-bytes DKG index followed by 192-byte length CipherText got +after transaction encryption followed by the encrypted transaction itself (a simple +1 wei transfer from Node0 to Node0 with zero nonce signed by Node0) encrypted by a +shared public key of 7-CNs privnet: ``` eth.sendTransaction({ -from: '74f4effb0b538baec703346b03b6d9292f53a4cd', -to: '1212000000000000000000000000000000000003', -value: 250, -gas_price: 10, -gas: 30000, -data: '0xffffffff958b9e5b4c7030287330e8dd593fa547ea95e9d51c6e206bf02879d8895380554eee2c23a4d140e2385d52df4df52c558adcc9562120b7acd4c31eb62cdd8c55811cfba97468480ed0e0912d24a5399b266b922201b81b02a9aef78efcfce4d882d97daf2eb318406ae2e74774afa511f118a4073ea636f96b4a98d41f213dff1026b0fc6d316b71c2be4b3f32cf927112c14c441d8b1e5ed034a6da5fbf773839d1681cc269827b2c8cd69d2ea1fdb8ba4fa4d25deaf2eaf75fd42890d20858adba403734db6b4e8ab220a3780fb163a81bf6985c238e479128f3accde467e1cd33e7c2e06ebd5b9195a9fdd2078537d921620eaf679ae30a3176327374617ffeb7f8d7c286efd4bed340a5d4365298bd4a361464ac3d805b5ca2bdd75caf97c83770f09107753df5152a26b8939d9270182b61145a6a23a8b12df4e5545b3b' -}); -``` - -Example of Envelope transaction with encrypted transfer of 1 wei for 7-CN privnet: -``` -eth.sendTransaction({ -from: '74f4effb0b538baec703346b03b6d9292f53a4cd', +from: '5e6D9680428e6fe62a09BBb6AC23Df5bFE069AE8', to: '1212000000000000000000000000000000000003', value: 250, gas_price: 10, -gas: 30000, -data: '0xffffffff9700c6906942f0db87d4c54b83be740e8fceef927bd36eeb70bea33176fb3838ee481589b4a15e60fee6ea39871c4a7aa3fa9a0469ae2f0dd720e383a0068e9236dd27354b0b8fc2434a53c72c3699a56a61a0e42c4b01d54f4a740064937577a3d3b1e8f58a831cd4a7352eab95e31c6cf5ee90b26133979a27b6c953c829fa652a097087b923cf1930be1204066c64099fd55e346af803feb08859b9635d45deadcf3943678ede7a9b8ea4ae79176459f9cc6f6298cfa4e47903b15caa1803c5db416064ba9b115c924ad432a58b0fd0b9a78914f23082baa3ca74d3d6c8d0038c24ce1165a141ca8329b74198e3ff7e7fbee4e9f50ed890ae42854b0a796307a1c2b0685da30f5b0602bc8785c507e86a599e083230e03d0987286084a14e942f7b9c67e30c5825aa2f81046dfe1c' +data: '0xffffffff01000000828b448503d5444f5ad70dbfb9d5eefc942dcdf9c25805ae928854e9a0aecfbcca2636a739dd432908623a19007b89ea9208c61cf65e341d1359b524dbfd8bf3b6a05813f7ffea1a05da38c78e897dce6dcb03be6647565839c08299d04c22d1b12e2b99f04a2ac2b0ac5e27d656afb3a84fcf97b3777832b51bc8844a47c4d897b604626279d2207aa152089295822e19bc5ea54b3e32522dc7ccab8780ab5c4aebe941d5c8adee7ba60dffd72dc04c219955b72ba57475e619ef726ab79012957e6aa04f63e837e845720755e21c9cd0420c316071386b00f91a16135ec435313d54853aae15b7678cc3c7ea1187fbd48ad2a3a9b95d73d391577276ac4c8503dbd004d20c31ca63aa426e245a6cd38bfb171ee53063108105b1d9b3e7dda2cb8b384805e00faef2faab647db83d43' }); ```