Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

"ERROR: Bad Request" when trying to transact with deployed SimpleStorage contract #39

Closed
alexfisher opened this issue Jul 5, 2017 · 22 comments
Labels

Comments

@alexfisher
Copy link

alexfisher commented Jul 5, 2017

Description of problem

Deployed a copy of SimpleStorage contract, but was unable to write a value with set() method. Browser throws an error that says "ERROR: Bad Request".

Note: I was able to manually run the set() method (setting value to 99) within geth (noting the contract address and ABI from info supplied in Cakeshop):

var address = "0x341ed42cdfb13b897a198cd1c87ddf070e25e6a1";

var abi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"message","type":"string"},{"indexed":false,"name":"newVal","type":"uint256"}],"name":"Change","type":"event"}];

var storage = eth.contract(abi).at(address);

storage.set(99,{from:eth.coinbase});

Expected behavior

Set variable to int.

Actual behavior

Variable remains set to 0.

Steps to reproduce the behavior

Deploy SimpleStorage contract
Enter value for set and press Transact

System information

Cakeshop version or commit hash: Cakeshop 0.10.0 Build ce816b1

Cakeshop runtime configuration: Attached to 7nodes example

Geth/Quorum version testing against: 1.5.0-unstable

Cakeshop OS & Version: Linux

Browser OS & Version: Linux (Ubuntu 16.04 LTS) Chrome 57.0.2987.133 (64-bit)

Backtrace/logs

Console outputs:
[WARN ] 2017-07-05 15:28:02.295 [qtp133124661-187] BaseController - Caught exception: Too few arguments: 0 < 1
com.jpmorgan.cakeshop.error.ABIException: Too few arguments: 0 < 1
at com.jpmorgan.cakeshop.model.ContractABI$Entry$Param.encodeList(ContractABI.java:146) ~[cakeshop-abi-0.10.0.jar!/:?]
at com.jpmorgan.cakeshop.model.ContractABI$Function.encode(ContractABI.java:333) ~[cakeshop-abi-0.10.0.jar!/:?]
at com.jpmorgan.cakeshop.model.ContractABI$Function.encodeAsHex(ContractABI.java:329) ~[cakeshop-abi-0.10.0.jar!/:?]
at com.jpmorgan.cakeshop.model.TransactionRequest.toGethArgs(TransactionRequest.java:65) ~[classes!/:?]
at com.jpmorgan.cakeshop.service.impl.ContractServiceImpl.transact(ContractServiceImpl.java:301) ~[classes!/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) ~[spring-aop-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) ~[spring-aop-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
at com.sun.proxy.$Proxy112.transact(Unknown Source) ~[?:?]
at com.jpmorgan.cakeshop.controller.ContractController$1.call(ContractController.java:180) ~[classes!/:?]
at com.jpmorgan.cakeshop.controller.ContractController$1.call(ContractController.java:172) ~[classes!/:?]
at org.springframework.web.context.request.async.WebAsyncManager$4.run(WebAsyncManager.java:317) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_131]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]

@raymond00000
Copy link

I faced same problem:

runcontract

runcontract2

Thanks for help.

@fixanoid
Copy link
Contributor

@raymond00000 I've yet to look into these issues, but from your screens above:
PrivateFor must be a quorum node key, not address of the "to"...

@raymond00000
Copy link

raymond00000 commented Jul 11, 2017

Yes, I also found I input wrong and retried, but I didn't take a new pic. But there was same error.
I used this public key: ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc=

Dear @fixanoid , can you look into this issue, and provide a set of correct input that can be "transacted" successfully? Many thanks for your help.

@alexfisher
Copy link
Author

FWIW, I tried without putting anything in the PrivateFor field, too. Same issue.

@raymond00000
Copy link

(Actually, I also tested a bit more, and in the "API" menu of cakeshop, I got this contract lookup request sample:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"id":"0xce4815e2c820a8e273206d43d77a7da481c03d61"}' 'http://localhost:8080/cakeshop/api/contract/get'

But there was very slow and finally returned error:

{
"errors":
[
{
"status": "500",
"title": "Internal server error",
"detail": "APIException: RPC request failed: invalid or missing value for params[0]"
}
],
"meta":
{
"version": "1.0",
"cakeshop-version": "0.10.0",
"cakeshop-build-id": "ce816b147a62d9ae817e48c37de2f00e39fce1bc",
"cakeshop-build-date": "2017-04-04T14:28:43.324-0400"
}

@fixanoid
Copy link
Contributor

Gentlemen, if you could please clarify a thing for me:

  • Did you build from scratch or use cakeshop pre-release?
  • Did the issue occur while working with a private instance of contract or public?

Thanks!

@raymond00000
Copy link

We used pre-release version, I just tried the Cakeshop v0.9.1, it works fine.

"Did the issue occur while working with a private instance of contract or public?" How can I check this info?

Sorry, and thanks for help.

@raymond00000
Copy link

But i tested with Cakeshop v0.9.1. It ran the simple storage example, and it seems all users can read the same storage value. It was fine to enter anything to the privatefor field to change the value.
Besides, how can I get the public key address of another user via the cakeshop? Thanks.

fixanoid added a commit that referenced this issue Jul 14, 2017
@fixanoid
Copy link
Contributor

This issue is now resolved, please pull and rebuild or download new release from: https://github.com/jpmorganchase/cakeshop/releases Please validate. Thank you!

@raymond00000
Copy link

raymond00000 commented Jul 17, 2017

I tried the new "fixed" version (downloaded from release page, "updated 14 July"), but I still got an error like below:
runcontract_step3

The console log is:

[DEBUG] 2017-07-17 09:28:53.241 [StreamLogAdapter] geth - I0717 09:28:53.241678 internal/ethapi/api.go:1263] Tx(e30e78265f540349f06fda40567cfbd380270b229644e426c8c376cfd1129cf3) to: &0000000000000000000000000000000000000020
[WARN ] 2017-07-17 09:28:55.799 [qtp3565780-84] BaseController - Caught exception: RPC request failed: Non-200 status code: &{Status:500 Internal Server Error StatusCode:500 Proto:HTTP/1.0 ProtoMajor:1 ProtoMinor:0 Header:map[Server:[Warp/3.2.11.1] Content-Type:[text/plain; charset=utf-8] Date:[Mon, 17 Jul 2017 01:28:55 GMT]] Body:0xc443f53600 ContentLength:-1 TransferEncoding:[] Close:true Uncompressed:false Trailer:map[] Request:0xc443f46870 TLS:}
com.jpmorgan.cakeshop.error.APIException: RPC request failed: Non-200 status code: &{Status:500 Internal Server Error StatusCode:500 Proto:HTTP/1.0 ProtoMajor:1 ProtoMinor:0 Header:map[Server:[Warp/3.2.11.1] Content-Type:[text/plain; charset=utf-8] Date:[Mon, 17 Jul 2017 01:28:55 GMT]] Body:0xc443f53600 ContentLength:-1 TransferEncoding:[] Close:true Uncompressed:false Trailer:map[] Request:0xc443f46870 TLS:}
at com.jpmorgan.cakeshop.service.impl.GethHttpServiceImpl.processResponse(GethHttpServiceImpl.java:199) ~[classes!/:0.10.0]
at com.jpmorgan.cakeshop.service.impl.GethHttpServiceImpl.executeGethCall(GethHttpServiceImpl.java:165) ~[classes!/:0.10.0]
at com.jpmorgan.cakeshop.service.impl.GethHttpServiceImpl.executeGethCall(GethHttpServiceImpl.java:146) ~[classes!/:0.10.0]
at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
at com.sun.proxy.$Proxy116.executeGethCall(Unknown Source) ~[?:?]
at com.jpmorgan.cakeshop.service.impl.ContractServiceImpl.transact(ContractServiceImpl.java:326) ~[classes!/:0.10.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
at com.sun.proxy.$Proxy129.transact(Unknown Source) ~[?:?]
at com.jpmorgan.cakeshop.controller.ContractController.lambda$transact$0(ContractController.java:223) ~[classes!/:0.10.0]
at org.springframework.web.context.request.async.WebAsyncManager$4.run(WebAsyncManager.java:316) ~[spring-web-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_131]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
[DEBUG] 2017-07-17 09:28:56.241 [StreamLogAdapter] geth - I0717 09:28:56.241033 core/blockchain.go:1060] imported 1 blocks, 2 txs ( 0.123 Mg) in 2.380ms (51.774 Mg/s). #20 [deae758a…]

@tylobban
Copy link

Hi - please can your try deploy the contract as a public contract and then send the set() tx as a public tx (i.e. in both cases do not populate the privateFor array). This looks like a constellation connectivity issue so want to confirm that. Thanks.

@raymond00000
Copy link

sure i can try it, but how to "deploy the contract as a public contract "? Thanks.

@tylobban
Copy link

Just don't populate the privateFor field.

@fixanoid
Copy link
Contributor

@raymond00000, theres a lot of work left to be done on our: the Cakeshop API/UI errors should be clearer and I'll work on improving that in the next few weeks. In the mean time, there are some rules for using Cakeshop/Quorum when working with contracts:

  • When using existing public contract, you should not send in privateFor field as it will lead to an error
  • When creating a private contract, you must specify the other party. Entering your constellation key will result in an error. Entering a wrong key will result in an error
  • When using existing private contract you must specify privateFor, otherwise the request will result in an error

@raymond00000
Copy link

Hi @fixanoid Thanks for update. I was working on other tasks, I will resume trying Cakeshop now. I think the simplest test case is:

private transaction from node 1 to node7 with default private contract: SimpleStorage.

I tried to match the parameters:
contract_4

But still, I got error, I just would like to know what are the correct value that I can run the transact operation of "SimpleStorage" successfully on cakeshop? Or reply a "Not now" so I will stop trying until the bug is fixed.

Many thanks for clarification.

@fixanoid
Copy link
Contributor

@raymond00000 Hey, I'm around and the functionality in question works fine on my PC. That said, you need to clarify a whole bunch of things for me before I can give you the right answer.

Some setup questions:

  • is your quorum-examples cluster up?
  • is your cakeshop node running separately or as an embedded node over another node in the cluster?
  • is your cakeshop node connected to every other node in the cluster?
  • is your constellation node registering every other constellation running?

Most of these questions could be answered by looking into the dashboard

@raymond00000
Copy link

@fixanoid

thanks for reply.

What I did is:

Download latest version released 14 july.
run java -jar cakeshop.jar
Visit the cakeshop through browser.
go to SandBox page.

Select the: simpleContract.
Then input as shown in my last reply.
Then received request error.

Please kindly let me know any extra steps I missed.
.

@fixanoid
Copy link
Contributor

I see. With the setup you made, you are running a single node that is not connected to any other nodes. In such setup, you are not going to be able to create a private contract -- for that, you need at least 2 nodes. As I reported above, the errors are very confusing right now, so when you submit a key constellation knows nothing about, you get a generic error -- that the case you've ran into.

To test out being able to create and communicate via a private contract, you need to spin up multiple cakeshop nodes. Here's how you would set it up on a single machine:

  • create several directories (must be at least 2) for the node contents and copy cakeshop.war into each
  • start every node once, wait until it starts and then shut it down
  • edit applications.properties for every setup directory and change these props to be different for every node (I generally just increase the last digit by 1): geth.url, geth.node.port, and a system variable: geth.constellaiton.url (notice misspelling, constellation URL should be of as such: -Dgeth.constellaiton.url=http://127.0.0.1:9000)
  • Start every node on a different port like so: java -Dserver.port=8080 -jar cakeshop.war for [docs] Added download link; links to other repos; more license info #1 node, java -Dserver.port=8081 -jar cakeshop.war for Win 10 Error - ERROR 2016-12-16 20:40:35,304 [BlockSaver-38] (SavingBlockListener.java:53 ) BlockSaverThread died #2 node, ...
  • Open nodes' dashboards in your browser and connect nodes to each other by perusing Node Info, Add Peer, and Add Constellation widgets
  • Finally, after every node is connected into the network, you are going to be able to create a private contract via the Sandbox IDE. To do that, open one of the nodes Sandbox, paste the contract and paste in another node private key that you should see on the Dashboard in the Node Info widget (look for node key)

This is a pretty lengthy thing, @tylobban may be a video would be useful for something like this might be in order?

@raymond00000
Copy link

@fixanoid Thanks a lot, I will try tmr, as it is mid-night already. I will update after trying.

@tylobban It will be excellent if there is a video to follow, will be very helpful to beginners. Thanks in advance.

Besides, I guess one issue is about Quickstart section, to me, it seems hint this: just run cakeshop.jar and everything is ready.
https://github.com/jpmorganchase/cakeshop

Thanks a lot.

@raymond00000
Copy link

@fixanoid I tried to follow the step, but on this step:

edit applications.properties for every setup directory and change these props to be different for every node (I generally just increase the last digit by 1): geth.url, geth.node.port, and a system variable: geth.constellaiton.url (notice misspelling, constellation URL should be of as such: -Dgeth.constellaiton.url=http://127.0.0.1:9000)

I cannot find the system variable, inside "applications.properties", or "printenv".

Thanks.

@raymond00000
Copy link

still cannot find geth.constellaiton.url, I guess I just one step away from successful deployment, much appreciated for help, plz.

@ksagami
Copy link

ksagami commented Apr 17, 2018

Hi ,
By following quorum-examples/7Nodes we can able to implement a 3 node cluster. Three nodes deployed in 3 different machines. I have node keys and pubs for all 3 nodes. But while doing private transaction from Boot node to voter node I can able to reproduce this error.

Error: Non-200 status code: &{Status:400 Bad Request StatusCode:400 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Date:[Tue, 17 Apr 2018 09:46:08 GMT] Server:[Warp/3.2.12]] Body:0xc42776efc0 ContentLength:-1 TransferEncoding:[chunked] Close:false Uncompressed:false Trailer:map[] Request:0xc424d851d0 TLS:}

Could you please provide any solution for this. Thanks in advance.
contractDeployment.txt

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

No branches or pull requests

6 participants