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

Add 'Publish Feed' feature #414

Closed
wants to merge 2 commits into
base: omnicore-0.0.10
from

Conversation

Projects
None yet
2 participants
@zathras-crypto
Copy link

zathras-crypto commented Aug 9, 2016

This PR adds the 'Publish Feed' feature to Omni Core.

This is currently a prototype for review, and may need changes or updates depending on whether I've understood the requirements for publishing a feed correctly.

In summary, the feed system allows an address to publish a value (a feed) which may be later referenced.

The feature has been simplified from the original concept of publishing data described in the Omni spec. There appears no need to 'setup' a feed, we are able to simply publish values as needed.

Feeds are identified by two attributes; the publishing address and a feed reference. A feed reference is used to allow an address to publish multiple disparate feeds if so desired.

A new Publish Feed transaction is used to publish. This transaction can be described as follows:


Publish Feed

Transaction type 31 publishes a value which may be later referenced by Omni transactions and exposed by the RPC-API.

Multiple Publish Feed transactions from the same address using the same feed reference may be used to form a feed history.

There are no additional validity constraints other than the the message field datatypes.

Field Type Example Value
Transaction version 16 bit unsigned int 31
Transaction type 16 bit unsigned int 0
Feed reference 16 bit unsigned int 1
Feed Value 64 bit signed int 5000

No transactions currently reference this data, but it is exposed via the RPC-API interface.

Initially supported functions via the RPC-API are:

  • Get the current value of a feed (omni_getfeed address feedref)
  • Get the value of a feed as at block N (omni_getfeed address feedref block)
  • Get the past values (history) of a feed (omni_getfeedhistory address feedref)
  • Get the feeds an address has published (omni_getfeeds address)

Respective internal functions grab this data from the feed database (leveldb), it may be likely that the most useful in the context of smart contracts would be retrieving the value at block N (assuming contracts are settled based on the price at block N).

A set of basic tests is included to validate functionality - these results (included below) can be checked by running the bash script test/test_publishfeed.sh. Note these tests demonstrate basic functionality only and do not look for problems with edge cases etc, that likely needs more thorough testing.

Preparing a test environment...
   * Starting a fresh regtest daemon
   * Preparing some mature testnet BTC
   * Obtaining a master address to work with
   * Funding the address with some testnet BTC for fees
   * Participating in the Exodus crowdsale to obtain some OMNI
   * Master address is mumET8Stvkjsdd16ys8v6v4jyy9gRcJ9y1
   * Generating addresses to use
Confirming publish feed transactions are invalidated before activation...
   * Sending a Publish Feed transaction
     # Checking the transaction was invalid... PASS
Activating the publish feed transaction...
   * Sending the activation
     # Checking the activation transaction was valid... PASS
   * Mining 10 blocks to forward past the activation block
     # Checking the activation went live as expected... PASS
Testing Publish Feed...
   * Sending a Publish Feed transaction (feed 1, value 1000)
     # Checking the transaction was valid... PASS
     # Checking the value for feed 1 at address is now 1000... PASS
     # Getting the block number to use later...
   * Sending several Publish Feed transactions for feed 1, (highest will be 5000 but latest 3000)
     # Checking the value for feed 1 at address is now at latest (3000)... PASS
     # Checking the value for feed 1 at address is 1000 at block 117... PASS
   * Sending Publish Feed transactions for feed refernces 2 and 65
     # Checking the value for feed 2 at address is now 200... PASS
     # Checking the value for feed 65 at address is now 6500... PASS
     # Checking that feeds 1, 2 and 65 are returned in omni_getfeeds... PASS
   * Checking feed history for feed ref 1
     # Checking that values 1000, 2000, 4000, 5000 & 3000 exist in history... PASS
   * Committing feed database to log
Orphaning a block to test Feed DB reorg protection (disconnecting 1 block from tip and mining a replacement)
     # Checking the value for feed 1 at address is still at 3000... PASS
   * Updating the feed to 9000
     # Checking the value for feed 1 at address is now at 9000... PASS
   * Committing feed database to log
   * Executing the rollback
   * Clearing the mempool
   * Verifiying the results
      # Checking the block count has been reduced by 1... PASS
   * Mining a replacement block
   * Committing feed database to log
   * Verifiying the results
      # Checking the block count is the same as before the rollback... PASS
      # Checking the block hash is different from before the rollback... PASS
     # Checking the value for feed 1 at address has been rolled back to 3000... PASS

####################
#  Summary:        #
#    Passed = 17   #
#    Failed = 0    #
####################

zathras-crypto added some commits Aug 9, 2016

Initial Commit of 'Publish Feed' feature
Note: sorry so much is in a single commit, I was experimenting with a few different pieces
@dexX7

This comment has been minimized.

Copy link
Member

dexX7 commented Aug 10, 2016

Just wow, I really like the whole submission! Great description and clean, straightforward code!

Let's check with @patrickdugan, whether this is what he needs, once the time is right. :)

@dexX7

This comment has been minimized.

Copy link
Member

dexX7 commented Jan 30, 2018

Given this PR is outdated and needs further review, it's going to be closed for now.

@dexX7 dexX7 closed this Jan 30, 2018

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