Closed ameeuw closed 6 years ago
hey Arne! great question, the docs are a bit behind on this one.
you can skip the GCI / bittorrent magic like this:
let { connect } = require('lotion')
let genesis = require('./genesis.json')
let ip = '159.89.140.7'
let tendermintPort = '41763'
let nodes = [ `ws://${ip}:${tendermintPort}` ]
async function main() {
let { state } = await connect(null, { genesis, nodes })
console.log(await state) // { count: 0 }
}
main()
running a lite node with the same http interface as a local full node used to be supported, and the http servers used to listen publicly by default. I changed this because it encouraged people to build apps that blindly trust full nodes they didn't control, and there are very few situations where that's a good idea.
by using the connect()
API, all the tendermint headers get verified in JavaScript, and the client verifies a merkle proof of the queried part of the state to make sure the full node can't send you back an invalid response.
hope that helps :)
Thank you - I will try it as soon as I find the time.
Hey @keppel - I tried setting it up like you suggested. The script keeps on failing as it can't parse a json. I found something I cannot quite make sense of (index.js line:313)
getState: async function(path = '') {
let queryResponse = await axios.get(
`${fullNodeRpcAddress}/abci_query?path="${path}"`
)
let resp = queryResponse.data.result.response
resp.height = Number(resp.height)
let proof = parse(Buffer.from(resp.proof, 'hex').toString())
await waitForHeight(resp.height, lc)
let rootHash = appHashByHeight[resp.height].toLowerCase()
let verifiedValue = merk.verify(rootHash, proof, path)
return verifiedValue
}
The code tries to compute the appHash from the height and tries to get the proof via the abci. It is then trying to parse the resp.proof
as a hex encoded JSON.
The proof however only includes a number and the JSON including the state is only within the resp.value
.
Am I missing something completely?
By the way: its really nice some serious development is going on in this repo! I support you wherever I can.
I think your full node might be running an older version of Lotion
Yep that seemed to be one issue.. now that I updated them I am running into the problem that the response from the abci query only yields this:
{ code: 2,
index: '0',
key: '',
value: '',
proof: '',
height: 0,
log: 'invalid query: Cannot read property \'key\' of null' }
It seems like the abci_query with path=' '
does not yield any proper response. Am I missing something again?
hey Arne, are you still getting this? can you post the code that you're using to do this query? is the client also on the latest version of Lotion?
facing the same issue
ok, this should be fixed in v0.1.15.
Yep - works for me. Thanks so much for your effort.
@ameeuw how did you fix it? I am facing issue to run access lotiontx port on a container
Hi everybody. So far I have been using lotion locally to develop my application. I recently deployed it to two EC2 instances and found out two things:
The express tx-server is run with 'localhost' as host and therefore only available on the host itself. Now that I need to have clients sending transactions and not being full validator nodes I have two options:
1) Run the tx-server openly on a port for clients to send their transactions to the lotion application. (probably a security issue) 2) Run a lite node on the client side and submit transactions via a local tx-server (currently not working for me)
I have tried to run a lite node but have not been successful. It seems that the supercop module is crashing. Is there a step that I have to include other than running lotion as lite and giving it the GCI as a target?
As I actually have all the information (genesis etc.) from the chain - is there a way to run a light client without utilising the GCI and the bittorrent magic behind it?
Is opening a tx-server to the 'public' and using it as an end-point for my clients a wrong pattern?
Thank you very much.