8000 feat(module): bandchain oracle support by Pantani · Pull Request #1343 · ignite/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(module): bandchain oracle support #1343

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

Merged
merged 48 commits into from
Jul 15, 2021
Merged

Conversation

Pantani
Copy link
Collaborator
@Pantani Pantani commented Jul 7, 2021

closes #1344
closes #1334

What does this MR does?

Add possibility to request data from the Bandchain oracle.

Changes

  • Create oracle Bandchain template files;
  • Add band CLI command;
  • Create placeholders for oracle;
  • Add Oracle modifiers;
  • Add oracle integration tests;
  • Add docs;

How to test?

  • Create and start your own oracle consumer cosmos blockchain (using only the --oracle flag automatically set the ibc flag to true):
$ starport s chain github.com/tendermint/bandchain
$ cd bandchain 
$ starport module create consuming --ibc
$ starport s band bandoracle --module consuming
  • Configure and run the relayer:
$ starport relayer configure -a \
--source-rpc "http://rpc-laozi-testnet2.bandchain.org:26657" \
--source-faucet "https://laozi-testnet2.bandchain.org/faucet/request" \
--source-port "oracle" \
--source-gasprice "0uband" \
--source-gaslimit 5000000 \
--source-prefix "band" \
--source-version "bandchain-1" \
--target-rpc "http://localhost:26657" \
--target-faucet "http://localhost:4500" \
--target-port "consuming" \
--target-gasprice "0.0stake" \
--target-gaslimit 300000 \
--target-prefix "cosmos"  \
--target-version "bandchain-1"

$ starport relayer connect
  • Request and verify data from the Bandchain blockchain:
$ bandchaind tx consuming bandoracle-data 37 4 3 --channel channel-0 --symbols "BTC,ETH,XRP,BCH" --multiplier 1000000 --fee-limit 30uband --request-key "random_string" --prepare-gas 600000 --execute-gas 600000 --from alice --chain-id bandchain

$ bandchaind query consuming last-bandoracle-id
request_id: "101276"

$ bandchaind query consuming bandoracle-result 101276

8000

Copy link
Contributor
@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested anything since it's still in progress, just had a look and this is pretty good so far 👍

@Pantani Pantani self-assigned this Jul 7, 2021
@Pantani Pantani force-pushed the feat/bandchain-oracle-support branch from a5637a4 to ac881b8 Compare July 7, 2021 18:57
@ilgooz ilgooz self-requested a review July 7, 2021 20:54
@fadeev
Copy link
Contributor
fadeev commented Jul 8, 2021

@Pantani have you tried using the relayer from this PR: #1336 ?

8000

@Pantani
Copy link
Collaborator Author
Pantani commented Jul 8, 2021

@Pantani have you tried using the relayer from this PR: #1336 ?

@fadeev not yet. I will do it today

@Pantani Pantani changed the title bandchain oracle support feat(module): bandchain oracle support Jul 8, 2021
@Pantani
Copy link
Collaborator Author
Pantani commented Jul 8, 2021

@Pantani have you tried using the relayer from this PR: #1336 ?

@fadeev still not working:
https://laozi-testnet2.cosmoscan.io/tx/4fdf598d6a996151022d0d263b0d4351c7d6e2caadd3689fd8d16533a90aefcf
https://laozi-testnet2.cosmoscan.io/account/band10zragfpt8xhlnvjpp4mdkgpq93tvh77lzmzzqe

How to test:

  • Start Starport Relayer
$ starport relayer configure -a \  
--source-rpc "http://rpc-laozi-testnet2.bandchain.org:26657" \
--source-faucet "https://laozi-testnet2.bandchain.org/faucet/request" \
--source-port "oracle" \
--source-gasprice "0uband" \
--source-prefix "band" \
--source-version "bandchain-1" \
--target-rpc "http://localhost:26657" \
--target-faucet "http://localhost:4500" \
--target-port "consuming" \
--target-gasprice "0.0stake" \
--target-prefix "cosmos"  \
--target-version "bandchain-1"

$ starport relayer connect 
  • Send Query Tx
$ bandchaind tx consuming oracle-data 37 4 3 --channel channel-0 --symbols "BTC,ETH,XRP,BCH" --multiplier 1000000 --fee-limit 30uband --request-key "random_string" --prepare-gas 200000 --execute-gas 200000 --from alice --chain-id bandchain

I'm using this consumer app:
https://github.com/Pantani/bandchain

Screen Shot 2021-07-08 at 09 46 09

@fadeev
Copy link
Contributor
fadeev commented Jul 8, 2021

@ilgooz let's leave #1341 and #1333 for v0.18 and prioritize bandchain. Right now I'm concerned about the latest TS version not working with the code scaffolded for bandchain.

@fadeev
Copy link
Contributor
fadeev commented Jul 8, 2021

Setting this to be around 600,000 should fix the problem.

Have we tried doing this?

@Pantani
Copy link
Collaborator Author
Pantani commented Jul 8, 2021

Setting this to be around 600,000 should fix the problem.

Have we tried doing this?

@fadeev, is this should be done into the TS relayer?

@Pantani Pantani force-pushed the feat/bandchain-oracle-support branch from 95e0948 to 7f7aa86 Compare July 8, 2021 22:16
@Pantani Pantani marked this pull request as ready for review July 9, 2021 02:35
@Pantani Pantani requested a review from fadeev as a code owner July 9, 2021 02:35
@Pantani Pantani requested review from ilgooz and lumtis July 9, 2021 02:36
Copy link
Contributor
@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still testing the feature but from the code I thing we are on a good track👍

A general feedback is that we should document all generated methods for the user, even the internal ones that begin with a lower case

Also, didn't you mentioned you wanted to go with a model where we don't have a --oracle flag but you scaffold a module with ibc and then you have a command to scaffold queries into this module?

@Pantani Pantani force-pushed the feat/bandchain-oracle-support branch from 30f2f97 to 13e77ed Compare July 9, 2021 18:34
@Pantani Pantani marked this pull request as draft July 9, 2021 18:35
Copy link
Contributor
@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍
Looks very good! Still doing some tests

@fadeev
Copy link
Contributor
fadeev commented Jul 13, 2021

Let's replace the command in the docs with:

starport relayer configure -a --source-rpc "http://rpc-laozi-testnet2.bandchain.org:26657" --source-faucet "https://laozi-testnet2.bandchain.org/faucet/request" --source-port "oracle" --source-gasprice "0uband" --source-prefix "band" --source-version "bandchain-1" --target-rpc "http://localhost:26657" --target-faucet "http://localhost:4500" --target-port "consuming" --target-gasprice "0.0stake" --target-prefix "cosmos"  --target-version "bandchain-1" --source-gaslimit 5000000 --target-gaslimit 300000

So that it works out of the box with most terminals (including mine 🙂).

And rename oracle.md to band.md.

@Pantani Pantani requested review from lumtis and fadeev July 13, 2021 13:30
fadeev
fadeev previously approved these changes Jul 13, 2021
Copy link
Contributor
@fadeev fadeev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🙌

@lumtis
Copy link
Contributor
lumtis commented Jul 13, 2021

There is one issue when you want to scaffold different queries. Since the dispatch of the result is based on the format of the result response, if you scaffold a second query and you don't change the data format and the script ID, then results for the 1st scaffolded are always stored in the list of results for the second scaffolded query

starport s band toto --module foo
starport s band tata --module foo

If I run later:

marsd tx foo toto-data 37 4 3 --channel channel-0 --symbols "BTC,ETH,XRP,BCH" --multiplier 1000000 --fee-limit 30uband --request-key "random_string" --prepare-gas 200000 --execute-gas 200000 --from alice

I will get the result for the 2nd one:

marsd q foo last-toto-id
request_id: "0"
marsd q foo last-tata-id
request_id: "316506"

This makes sense if I look at oracle.go:

        var tataResult types.TataResult
	if err := obi.Decode(modulePacketData.Result, &tataResult); err == nil {
		am.keeper.SetTataResult(ctx, types.OracleRequestID(modulePacketData.RequestID), tataResult)
		ack = channeltypes.NewResultAcknowledgement(
			types.ModuleCdc.MustMarshalJSON(
				packet.NewOracleRequestPacketAcknowledgement(modulePacketData.RequestID),
			),
		)

		// TODO: Tata oracle data reception logic
	}

	var totoResult types.TotoResult
	if err := obi.Decode(modulePacketData.Result, &totoResult); err == nil {
		am.keeper.SetTotoResult(ctx, types.OracleRequestID(modulePacketData.RequestID), totoResult)
		ack = channeltypes.NewResultAcknowledgement(
			types.ModuleCdc.MustMarshalJSON(
				packet.NewOracleRequestPacketAcknowledgement(modulePacketData.RequestID),
			),
		)

		// TODO: Toto oracle data reception logic
	}

The last scaffolded query result is parsed first

@lumtis
Copy link
Contributor
lumtis commented Jul 13, 2021

However it may be the case that for the response from the oracle, there is no way to differentiate two different queries outside the format of the response.

The issue would be only solved if the developer manually change the format of the queries.

Maybe it would be better to only allow for a single query for this first version?

In the future we could maybe think about a command where you provide the kind of data format you want and you can only scaffold one query with this format:

starport s band my-query [crypto-price | gold-price | soccer-results | ...]

@lumtis
Copy link
Contributor
lumtis commented Jul 13, 2021

Well it seems many script use this multiplier|symbol and rates format. So we should see if there is a way to differentiate two results.
The easiest way would be to allows for only one query but that would be then unfortunate to prevent allowing scaffolding diffrent logic based on the what you want the price for example

@Pantani
Copy link
Collaborator Author
Pantani commented Jul 13, 2021

Well it seems many script use this multiplier|symbol and rates format. So we should see if there is a way to differentiate two results.
The easiest way would be to allows for only one query but that would be then unfortunate to prevent allowing scaffolding diffrent logic based on the what you want the price for example

It should be fixed now. We are using the client id to parse the message types

lumtis
lumtis previously approved these changes Jul 14, 2021
Copy link
Contributor
@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks legit to me

Awesome work @Pantani 👍

Copy link
Contributor
@fadeev fadeev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo! 🦸

@Pantani Pantani merged commit 8ca96f2 into develop Jul 15, 2021
@Pantani Pantani deleted the feat/bandchain-oracle-support branch July 15, 2021 16:08
Jchicode pushed a commit to Jchicode/cli that referenced this pull request Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

oracle bandchain support Update ts-relayer
4 participants
0