Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private Transaction from Private Contract #78

Closed
paliwalg opened this issue Mar 18, 2017 · 8 comments
Closed

Private Transaction from Private Contract #78

paliwalg opened this issue Mar 18, 2017 · 8 comments

Comments

@paliwalg
Copy link

paliwalg commented Mar 18, 2017

System information

Geth version: geth version
1.5.0-unstable

OS & Version: Windows/Linux/OSX
Ubuntu 16.04.1 LTS

Branch, Commit Hash or Release: git status
Master

Expected behaviour

Should succeed

Actual behaviour

Transaction not getting deployed.

Steps to reproduce the behaviour

I have 6 Nodes each node having two accounts and are configured as Voter & Block maker.
I am trying to deploy contract(SimpleCustomerFactory) from node 6 as private to Node 1,2,3,4,5. It is getting deployed successfully.

Now I am trying to perform a private transaction(addCustomer) from the contract from node 6 to node 1.. I do receive transactionHash as a result, but I don't see the transaction to be added. Contract address remains null when I do getTransactionReceipt().
I don't see any error in any of the logs.
In the Node 6 log, I do see one line for the matching transaction hash.

I0318 09:24:48.615015 internal/ethapi/api.go:1060] Tx(0xcf39e4877e57e5f6e819832e
a9afbb3a863fb0f77d156147ab2933177bb09125) to: 0x6a8331ace0824d4c7872f6d2618b45a4
2f887798

I have attached the contract code and configuration files for your reference

init.txt
start.txt
SimpleCustomerFactory.txt
SimpleCustomer.txt

@tylobban
Copy link
Contributor

Hi, please can you post the command/code you're using to send the addCustomer private transaction to node6?

@paliwalg
Copy link
Author

Below is the code that i am executing from Node 6 geth console.

var address = "0x6a8331ace0824d4c7872f6d2618b45a42f887798";
var abi = 'removed it for simplicity';
var contractOb = eth.contract(abi).at(address);
contractOb.addCustomer("3252FGH","Shell UK Pty Ltd","Public Listed","Wholly Listed",web3.eth.coinbase,{from:web3.eth.coinbase,
gas: 98000000, privateFor: ["BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="
,"QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=","1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=","oNspPPgszVUFw0qmGFfWwh1uxVUXgvBxleXORHj07g8=","R56gy4dn24YOjwyesTczYa8m5xhP6hF2uTMCju/1xkY="
]});

@patrickmn
Copy link
Contributor

Could you attach/gist the constellation log for the sending node?

@paliwalg
Copy link
Author

No errors in the constellation log of any of the nodes. Below is the constellation log of Node 6 from where the transactions are executed

root@78c007ffd0b7:/# less qdata/logs/constellation6.log
nohup: appending output to 'nohup.out'
2017 Mar-18 09:01:01352566 [INFO] Constellation initializing using config file t
m6.conf
2017 Mar-18 09:01:01356124 [INFO] Log level is LevelWarn

@tylobban
Copy link
Contributor

I am not able to reproduce the issue using the 7nodes setup. Can you please also send through the code for the initial contract deployment tx?

@paliwalg
Copy link
Author

var newC = web3.eth.contract(contract.interface);

newC.new({
    data:("0x" +  contract.bytecode),
    gas: 98000000,
    from: owner
	,privateFor:["BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="
	,"QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc="
	,"1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg="
	,"oNspPPgszVUFw0qmGFfWwh1uxVUXgvBxleXORHj07g8="
	,"R56gy4dn24YOjwyesTczYa8m5xhP6hF2uTMCju/1xkY="
	]
	}, function(err, myContract){
        if(err){
            console.log(err);
        }
        if(!err) {
           // NOTE: The callback will fire twice!
           // Once the contract has the transactionHash property set and once its deployed on an address.

           // e.g. check tx hash on the first call (transaction send)
           if(!myContract.address) {
               console.log(myContract.transactionHash); // The hash of the transaction, which deploys the contract

           // check address on the second call (contract deployed)
           } else {
               cb(null, myContract.address); // the contract address
           }

           // Note that the returned "myContractReturned" === "myContract",
           // so the returned "myContractReturned" object will also get the address set.
        }
});

I am able to successfully deploy the SimpleCustomerFactory contract through this code. I have attached the contract JSON also here.

var address = "0x67611335713bbfdc6eadfc40878958e485ddc077";
var abi = '****';
var contractOb = eth.contract(abi).at(address);
contractOb.addCustomer("3252FGH","Shell UK Pty Ltd","Public Listed","Wholly Listed",web3.eth.coinbase,{from:web3.eth.coinbase,
gas: 98000000, privateFor: ["BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="
,"QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=","1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=","oNspPPgszVUFw0qmGFfWwh1uxVUXgvBxleXORHj07g8=","R56gy4dn24YOjwyesTczYa8m5xhP6hF2uTMCju/1xkY="
]});
This gives the output as
"0x6519ef7c0772dfea279fe7ffab6bf594bc39362bea492d77dca7c22aa1574b48"

eth.getTransactionReceipt("0x6519ef7c0772dfea279fe7ffab6bf594bc39362bea492d77dca7c22aa1574b48") output

{
blockHash: "0x78566ca4d1212d6171d8eff4e84ab36f81219dbab194e2c0c22eb3e3e668b5ee
",
blockNumber: 90,
contractAddress: null,
cumulativeGasUsed: 123223,
from: "0xbd40abe8943345b4886302553703141e0c8ae968",
gasUsed: 0,
logs: [],
logsBloom: "0x0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000",
root: "0x0519fb3e9763e0e61fbfa36a12d858466032bceaf700b97e9e3f7f2f47a62462",
to: "0x67611335713bbfdc6eadfc40878958e485ddc077",
transactionHash: "0x6519ef7c0772dfea279fe7ffab6bf594bc39362bea492d77dca7c22aa1
574b48",
transactionIndex: 2
}

eth.getTransaction("0x6519ef7c0772dfea279fe7ffab6bf594bc39362bea492d77dca7c22aa1574b48"}
{
blockHash: "0x78566ca4d1212d6171d8eff4e84ab36f81219dbab194e2c0c22eb3e3e668b5ee
",
blockNumber: 90,
from: "0xbd40abe8943345b4886302553703141e0c8ae968",
gas: 98000000,
gasPrice: 0,
hash: "0x6519ef7c0772dfea279fe7ffab6bf594bc39362bea492d77dca7c22aa1574b48",
input: "0x1021b81018eea43d5f6297bc5ef96fc554626fef3ce7185a0a8944e6f1f5d20510a7
17010cf76664056d1d925edfd58829d944017d7e80b68649ea4516e228c5",
nonce: 55,
r: "0x6b8c19794a6a273893ac1a0583039345be85c9ef11836d485628655b9cb4919d",
s: "0x4b22718026dfec660257900b713ab5758d9ed9143243a6617a45365b36c0474a",
to: "0x67611335713bbfdc6eadfc40878958e485ddc077",
transactionIndex: 2,
v: "0x25",
value: 0
}

SimpleCustomerFactoryjson.txt

@tylobban
Copy link
Contributor

tylobban commented Mar 18, 2017

Hi @paliwalg, I am able to create the contract both as a public contract and a private contract using the standard 7nodes setup. In the case of the private contract, I made it privateFor node1 and node 7. Here's what I get:

Note that factoryPriv is at address 0x57f6e9596693364d33fd7c35ae525568a350cbae and was created with privateFor:
["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="]

factoryPriv.addCustomer("3252FGH","Shell UK Pty Ltd","Public Listed","Wholly Listed",web3.eth.coinbase,{from:web3.eth.coinbase,
gas: 98000000, privateFor: ["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="]});
"0x51e244febb4f68df76c8dc9107bbcfb8779e333bc00f55f683a54ef06ce07eb3" #tx ID

factoryPriv.getParticipantContractAddressFrom(web3.eth.coinbase)
"0x771eb3d2ac9e1bda241c9a45af90132fece70997" #address of SimpleCustomer contract created by SimpleCustomerFactory 

var newPrivSimpleCustomerContractAdd = "0x771eb3d2ac9e1bda241c9a45af90132fece70997"
var newPrivSimpleCustomerAbi = #abi of SimpleCustomer Contract, omitted for brevity
var newPrivSimpleCustomerContractOb = eth.contract(newPrivSimpleCustomerAbi).at(newPrivSimpleCustomerContractAdd);
newPrivSimpleCustomerContractOb.LegalName()
"0x5368656c6c20554b20507479204c746400000000000000000000000000000000" # Shell UK Pty Ltd

When I instantiate the contract object on node 7 I am able to retrieve the value, as expected:

#steps omitted for brevity
newPrivSimpleCustomerContractOb.LegalName()
"0x5368656c6c20554b20507479204c746400000000000000000000000000000000" # Shell UK Pty Ltd 

When I instantiate the contract object on node 2 I am not able to retrieve the result, as expected:

#steps omitted for brevity
newPrivSimpleCustomerContractOb.LegalName()
"0x"

The result of eth.getTransactionReceipt("0x51e244febb4f68df76c8dc9107bbcfb8779e333bc00f55f683a54ef06ce07eb3") (the addCustomer tx ID from above) is below for reference. contractAddress is null, even though the SimpleCustomer contract was created.

{
  blockHash: "0x359b52ac02de3708a252ed7aa7fbd4c09ba53ba8aaca3a3e3ada161fa9225180",
  blockNumber: 5164,
  contractAddress: null,
  cumulativeGasUsed: 91996,
  from: "0xed9d02e382b34818e88b88a309c7fe71e65f419d",
  gasUsed: 0,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  root: "0x4c87a4d8fa6209ddda562e865ac03bd24e05857d27f1283972b6687c29a34bf4",
  to: "0x57f6e9596693364d33fd7c35ae525568a350cbae",
  transactionHash: "0x51e244febb4f68df76c8dc9107bbcfb8779e333bc00f55f683a54ef06ce07eb3",
  transactionIndex: 1
}

Here's the result of eth.getTransaction("0x51e244febb4f68df76c8dc9107bbcfb8779e333bc00f55f683a54ef06ce07eb3"). Note the v value of "0x26" (38), indicating the transaction is private.

{
  blockHash: "0x359b52ac02de3708a252ed7aa7fbd4c09ba53ba8aaca3a3e3ada161fa9225180",
  blockNumber: 5164,
  from: "0xed9d02e382b34818e88b88a309c7fe71e65f419d",
  gas: 98000000,
  gasPrice: 0,
  hash: "0x51e244febb4f68df76c8dc9107bbcfb8779e333bc00f55f683a54ef06ce07eb3",
  input: "0x7ec184424778e07db2422da1e2ba513a99f5e9d624e43128e552429660ab92652d953532f9f9a158bcd7543d7e7b3dcd4408aebbe4bccee23a08e468c90332fd",
  nonce: 14,
  r: "0xa5b5874d512abc210d4f016cbfdfb89b4a30153546e47d12427f46f6c911e7ae",
  s: "0x2314ab214eafda27bd7aa7ceed7cc08ebdb87fe2b10d3475260329c0cd884d49",
  to: "0x57f6e9596693364d33fd7c35ae525568a350cbae",
  transactionIndex: 1,
  v: "0x26",
  value: 0
}

@paliwalg
Copy link
Author

Its working fine now, i have to adjust the gasAmount I am passing while doing addCustomer().
And Yes seems like a bug, getTransactionReceipt() shows the contract address as null only.
Closing this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants