@@ -1746,24 +1746,31 @@ func handlePrivateTransaction(ctx context.Context, b Backend, tx *types.Transact
1746
1746
log .Info ("sending private tx" , "isRaw" , isRaw , "data" , common .FormatTerminalString (data ), "privatefrom" , privateTxArgs .PrivateFrom , "privatefor" , privateTxArgs .PrivateFor , "psvsender" , privateTxArgs .PrivateStateValidation , "messageCall" , isMessageCall )
1747
1747
if isRaw {
1748
1748
hash = common .BytesToEncryptedPayloadHash (data )
1749
- /*
1750
- privatePayload, _, _, revErr := private.P.Receive<TODO need new API to retrieve payload>(data)
1751
- if revErr != nil {
1752
- return isPrivate, nil, revErr
1753
- }
1754
- var privateTx *types.Transaction
1755
- if tx.To() == nil {
1756
- privateTx = types.NewContractCreation(tx.Nonce(), tx.Value(), tx.Gas(), tx.GasPrice(), privatePayload)
1757
- } else {
1758
- privateTx = types.NewTransaction(tx.Nonce(), *tx.To(), tx.Value(), tx.Gas(), tx.GasPrice(), privatePayload)
1759
- }
1760
- creationTxEncryptedPayloadHashes, merkleRoot, err = simulateExecution(ctx, b, from, privateTx)
1761
- if err != nil {
1762
- return
1763
- }
1764
- */
1765
-
1766
- //TODO: how to send correct psv without simulation??
1749
+
1750
+ privatePayload , _ , revErr := private .P .Receive (hash )
1751
+ if revErr != nil {
1752
+ return isPrivate , common.EncryptedPayloadHash {}, revErr
1753
+ }
1754
+ log .Trace ("raw" , "hash" , hash , "privatepayload" , privatePayload )
1755
+ var privateTx * types.Transaction
1756
+ if tx .To () == nil {
1757
+ log .Trace ("raw creation" )
1758
+ privateTx = types .NewContractCreation (tx .Nonce (), tx .Value (), tx .Gas (), tx .GasPrice (), privatePayload )
1759
+ } else {
1760
+ log .Trace ("raw message call" )
1761
+ privateTx = types .NewTransaction (tx .Nonce (), * tx .To (), tx .Value (), tx .Gas (), tx .GasPrice (), privatePayload )
1762
+ }
1763
+ creationTxEncryptedPayloadHashes , merkleRoot , err = simulateExecution (ctx , b , from , privateTx )
1764
+
1765
+ log .Trace ("raw-data returned from sim" , "creationPayloadHashes" , creationTxEncryptedPayloadHashes , "MR" , merkleRoot , "err" , err )
1766
+ if err != nil {
1767
+ return
1768
+ }
1769
+
1770
+ if ! isMessageCall && ! privateTxArgs .PrivateStateValidation {
1771
+ merkleRoot = common.Hash {}
1772
+ }
1773
+
1767
1774
data , err = private .P .SendSignedTx (hash , privateTxArgs .PrivateFor , & engine.ExtraMetadata {
1768
1775
ACHashes : creationTxEncryptedPayloadHashes ,
1769
1776
ACMerkleRoot : merkleRoot ,
@@ -1775,6 +1782,11 @@ func handlePrivateTransaction(ctx context.Context, b Backend, tx *types.Transact
1775
1782
if ! isMessageCall && ! privateTxArgs .PrivateStateValidation {
1776
1783
merkleRoot = common.Hash {}
1777
1784
}
1785
+
1786
+ log .Trace ("privatetx" , "creationtxs" , creationTxEncryptedPayloadHashes )
1787
+ if isMessageCall && len (creationTxEncryptedPayloadHashes ) == 0 {
1788
+ return isPrivate , common.EncryptedPayloadHash {}, errors .New ("non-party to message call" )
1789
+ }
1778
1790
log .Trace ("data returned from sim" , "creationPayloadHashes" , creationTxEncryptedPayloadHashes , "MR" , merkleRoot , "err" , err )
1779
1791
if err != nil {
1780
1792
return
@@ -1784,7 +1796,7 @@ func handlePrivateTransaction(ctx context.Context, b Backend, tx *types.Transact
1784
1796
ACMerkleRoot : merkleRoot ,
1785
1797
})
1786
1798
}
1787
- log .Info ("sent private tx" , "isRaw" , isRaw , "data" , common .FormatTerminalString (data ), "privatefrom" , privateTxArgs .PrivateFrom , "privatefor" , privateTxArgs .PrivateFor , "merkleroot" , merkleRoot , "ismessagecall" , isMessageCall , "error" , err , "hash" , hash )
1799
+ log .Info ("sent private tx" , "isRaw" , isRaw , "data" , common .FormatTerminalString (data ), "privatefrom" , privateTxArgs .PrivateFrom , "privatefor" , privateTxArgs .PrivateFor , "merkleroot" , merkleRoot , "ismessagecall" , isMessageCall , "error" , err , "encryptedhahses" , creationTxEncryptedPayloadHashes , " hash" , hash )
1788
1800
if err != nil {
1789
1801
return isPrivate , common.EncryptedPayloadHash {}, err
1790
1802
}
@@ -1856,6 +1868,7 @@ func simulateExecution(ctx context.Context, b Backend, from common.Address, priv
1856
1868
affectedContractsHashes := make (common.EncryptedPayloadHashes )
1857
1869
addresses := evm .AffectedContracts ()
1858
1870
psv := true
1871
+ log .Trace ("simulation" , "affectedaddresses" , addresses )
1859
1872
for _ , addr := range addresses {
1860
1873
privacyMetadata , err := evm .StateDB .GetStatePrivacyMetadata (addr )
1861
1874
log .Debug ("Found affected contract" , "address" , addr .Hex (), "privacyMetadata" , privacyMetadata )
@@ -1881,7 +1894,7 @@ func simulateExecution(ctx context.Context, b Backend, from common.Address, priv
1881
1894
return nil , common.Hash {}, err
1882
1895
}
1883
1896
}
1884
- log .Trace ("simulation end" , "mr" , merkleRoot )
1897
+ log .Trace ("simulation end" , "mr" , merkleRoot , "affectedhashes" , affectedContractsHashes )
1885
1898
return affectedContractsHashes , merkleRoot , nil
1886
1899
}
1887
1900
0 commit comments