Create the Rich History Database
This topic contains information to help you specify an Oracle database connection and choose channels to create the rich history database. You’ll use this database to make analytics reports and visualizations of your ledger’s activities.
What's the Rich History Database?
The rich history database is external to Oracle Blockchain Platform and contains data about the blockchain ledger’s transactions on the channels you select. You use this database to create analytics reports and visualization about your ledger’s activities.
For example, using the rich history database, you could create analytics to learn the average balance of all of the customers in your bank over some time interval, or how long it took to ship merchandise from a wholesaler to a retailer.
Internally, Oracle Blockchain Platform uses the Hyperledger Fabric history database to manage the ledger and present ledger transaction information to you in the console. Only the chaincodes can access this history database, and you can’t expose the Hyperledger Fabric history database as a data source for analytical queries. The rich history database uses an external Oracle database and contains many details about every transaction committed on a channel. This level of data collection makes the rich history database an excellent data source for analytics. For information about the data that the rich history database collects, see Rich History Database Tables and Columns.
You can only use an Oracle database such as Oracle Autonomous Data Warehouse or Oracle Database Classic Cloud Service with Oracle Cloud Infrastructure to create your rich history database. You use the Oracle Blockchain Platform console to provide the connection string and credentials to access and write to the Oracle database. Note that the credentials you provide are the database’s credentials and Oracle Blockchain Platform doesn’t manage them. After you create the connection, you’ll select the channels that contain the ledger data that you want to include in the rich history database. See Enable and Configure the Rich History Database.
You can use standard tables or blockchain tables to store the rich history database. Blockchain tables are tamperproof append-only tables, which can be used as a secure ledger while also being available for transactions and queries with other tables.
You can use any analytics tool, such as Oracle Analytics Cloud or Oracle Data Visualization Cloud Service, to access the rich history database and create analytics reports or data visualizations.
Create the Oracle Database Classic Cloud Service Connection String
You must collect information from the Oracle Database Classic Cloud Service deployed on Oracle Cloud Infrastructure to build the connection string required by the rich history database. You must also enable access to the database through port 1521.
Find and Record Oracle Database Classic Cloud Service Information
The information you need to create a connection to the Oracle Database Classic Cloud Service is available in the Oracle Cloud Infrastructure Console.
-
From the Infrastructure Console, click the navigation menu in the top left corner, and then click Database.
-
Locate the database that you want to connect to and record the Public IP address.
-
Click the name of the database that you want to connect to and record the values in these fields:
-
Database Unique Name
-
Host Domain Name
-
Port
-
-
Find a user name and password of a database user with permissions to read from this database, and make a note of these. For example, the user SYSTEM.
Enable Database Access Through Port 1521
Add an ingress rule that enables the rich history database to access the database through port 1521.
-
In the Oracle Cloud Infrastructure home page, click the navigation icon and then under Databases click DB Systems.
-
Click the database that you want to connect to.
-
Click the Virtual Cloud Network link.
-
Navigate to the appropriate subnet, and then under Security Lists, click Default Security List For <Target Database>.
The Security List page is displayed.
-
Click Edit All Rules.
-
Add an ingress rule to allow any incoming traffic from the public internet to reach port 1521 on this database node, with the following settings:
-
SOURCE CIDR: 0.0.0.0/0
-
IP PROTOCOL: TCP
-
SOURCE PORT RANGE: All
-
DESTINATION PORT RANGE: 1521
-
Allows: TCP traffic for ports: 1521
-
Build the Connection String
After enabling access to the Oracle database, use the information you collected to build the connection string in the Configure Rich History dialog.
Construct the connection string using the following syntax: <publicIP>:<portNumber>/<database unique name>.<host domain name>
For example, 192.0.2.0:1521/CustDB_iad1vm.sub05031027070.customervcnwith.oraclevcn.example.com
Ensure the Database User has Correct Privileges
grant select on v_$session to <user>;
grant alter system to <user>;
Additionally,
if the rich history database uses Oracle Autonomous Data Warehouse, the database user must have the following
privilege:grant unlimited tablespace to <user>;
If the database
user doesn't have those privileges already, they must be granted by the system database
administrator.Without these privileges Oracle Blockchain Platform can replicate to the database but it cannot recover from situations leading to a damaged database session, which prevents the rich history from catching up with recent transactions for an extended period. Without these privileges on Oracle Autonomous Data Warehouse, no rich history data is saved.
Enable and Configure the Rich History Database
Use the console to provide database connection information and select the channels with the chaincode ledger data that you want to write to the rich history database. By default channels aren’t enabled to write data to the rich history database.
Note the following information:
-
Each blockchain network member configures its own rich history database.
-
You must use an Oracle database. No other database types are supported.
-
Each channel that writes to the rich history database must contain at least one peer node.
- Enter connection and credential information for the Oracle database that you want to use to store rich history information.
- Enable rich history on the channels that contain the chaincode data that you want to write to the rich history database.
Modify the Connection to the Rich History Database
You can change the rich history database’s connection information.
Configure the Channels that Write Data to the Rich History Database
You can enable channels to write chaincode ledger data to the rich history database, and you can stop channels from writing data to the rich history database. You can also configure an individual channel to use a different rich history database configuration than the global setting.
After tables are created in the database for a channel, modifying the rich history configuration for the channel has no effect, even after you click Save, unless you change the user name and password or the connection string. If you change the user name and password, tables are created in the same database. If you change the connection string and credentials, a different database is configured, and tables are created after the next relevant transaction or ledger change. You cannot change a rich history database from standard tables to blockchain tables, and you cannot change retention times, unless you also change the credentials or connection string.
Monitor the Rich History Status
After configuring the rich history database, you can use the console to monitor the rich history replication status.
Limit Access to Rich History
You can use channel policies and access control lists (ACLs) to limit the organizations that can configure the rich history database and retrieve rich history status or configuration information.
Rich History Database Tables and Columns
The rich history database contains three tables for each channel: history, state, and latest height. You’ll query the history and state tables when you create analytics about your chaincodes’ ledger transactions. If you've chosen to select any of the transaction details when enabling the rich history, an additional table will be created with the transaction details.
History Table
The <instanceName><channelName>_hist table contains ledger history. The data in this table tells you the chaincode ID, key used, if the transaction was valid, the value assigned to the key, and so on.
Note that the value and valueJson columns are used in a mutually exclusive way. That is when a key value is valid json, then the value is set into the valueJson column. Otherwise the value is set in the value column. The valueJson column is set up as a json column in the database, which means users can query that column using the usual Oracle JSON specific extensions.
If configured, private data is also stored in this table. For private data, the chaincode ID uses the following format: <chaincodeName>$$<collectionName>.
Column | Datatype |
---|---|
chaincodeId | VARCHAR2 (256) |
key | VARCHAR2 (1024) |
txnIsValid | NUMBER (1) |
value | VARCHAR2 (4000) |
valueJson | CLOB |
blockNo | NUMBER NOT NULL |
txnNo NUMBER | NOT NULL |
txnId | VARCHAR2 (128) |
txnTimestamp | TIMESTAMP |
txnIsDelete | NUMBER (1) |
State Table
The <instanceName><channelName>_state table contains data values replicated from the state database. You’ll query the state table when you create analytics about the state of the ledger.
Note that the value and valueJson columns are used in a mutually exclusive way. That is when a key value is valid json, then the value is set into the valueJson column. Otherwise the value is set in the value column. The valueJson column is set up as a json column in the database, which means users can query that column using the usual Oracle JSON specific extensions.
Column | Datatype |
---|---|
chaincodeId | VARCHAR2 (256) |
key | VARCHAR2 (1024) |
value | VARCHAR2 (4000) |
valueJson | CLOB |
blockNo | NUMBER |
txnNo | NUMBER |
Latest Height Table
The <instanceName><channelName>_last table is used internally by Oracle Blockchain Platform to track the block height recorded in the rich history database. It determines how current the rich history database is and if all of the chaincode transactions were recorded in the rich history database. You can’t query this database for analytics.
Transaction Details Table
The <instanceName><channelName>_more table contains attributes related to committed transactions. When enabling the rich history database, you can select which of these attributes you want to record in this table. The transaction details table only captures information about endorser transactions - not configuration transactions or any other kind of Hyperledger Fabric transactions.
Column | Datatype |
---|---|
CHAINCODEID | VARCHAR2 (256) |
BLOCKNO | NUMBER |
TXNNO | NUMBER |
TXNID | VARCHAR2(128) |
TXNTIMESTAMP | TIMESTAMP |
SUBMITTERCN | VARCHAR2(512) |
SUBMITTERORG | VARCHAR2(512) |
SUBMITTEROU | VARCHAR2(512) |
CHAINCODETYPE | VARCHAR2(32) |
VALIDATIONCODENAME | VARCHAR2(32) |
ENDORSEMENTS | CLOB |
INPUTS | CLOB |
EVENTS | CLOB |
RESPONSESTATUS | NUMBER(0) |
RESPONSEPAYLOAD | VARCHAR2(1024) |
RWSET | CLOB |
BLOCKCREATORCN | VARCHAR2(512) |
BLOCKCREATORORG | VARCHAR2(512) |
BLOCKCREATOROU | VARCHAR2(512) |
CONFIGBLOCKNUMBER | NUMBER(0) |
CONFIGBLOCKCREATORCN | VARCHAR2(512) |
CONFIGBLOCKCREATORORG | VARCHAR2(512) |
CONFIGBLOCKCREATOROU | VARCHAR2(512) |
Note:
- Organization (ORG) and organization unit (OU) are driven by identity certificates, which implies that they may be assigned to multiple values. They are captured as a comma separated list in the table's values.
- For identities, the table includes information only about the "Subject" portion of the certificates, not the "Issuer" one.
- The
RWSET
column contains operations on all chaincodes (in the same ledger) performed during endorsement. As such, you will typically see both lscc read operations and the actual chaincode namespace operations.