5.7 KiB
5.7 KiB
DB extension and refactoring for activity
Work in progress
Buy | Swap | Bridge | Send/Receive | |
---|---|---|---|---|
Activity data | API DB | API DB | ||
Raw data | API DB | API DB | ||
Pending data | API DB | API DB |
Legend:
API- not much or at all provided- API - partially provided
- API - complete
Summary
Improve on the identified limitations
- Missing filtering data
- Missing cached (not extracted as a column)
- Extracting the data from the raw data is expensive but might be negligible given that usually we should not expect more than 20 entries per second in the worst case scenario.
- Table extensions
Activity specific info in activity data store (multi_transaction table)- Activity specific info in in the transactions data store (transfers table)
Missing data
Filter requirements
- Activity operation status
pending
: have to aggregate forBuy
,Swap
,Bridge
- already there for
Send
,Receive
- already there for
complete
: only extract and check forstatus
in thereceipt
forSend
,Receive
- For complex operations aggregate the
complete
statusBuy
,Swap
,Bridge
- For complex operations aggregate the
finalized
: similar tocomplete
forSend
,Receive
- all sub-transactions are
complete
forBuy
,Swap
,Bridge
- all sub-transactions are
failed
: extract fromstatus
for all sub-transactions
chainID
: aggregate data for activity entriesBridge
,Buy
,Swap
tokenCode
for activity entriesSend
,Receive
- For
Bridge
its already there andBuy
,Swap
is coming soon
- For
collectibles
: require adding collectible attributes to activity data (probablytoken_address
andtokenId
)
UX requirements
status
: for status icon and labelchainIDs
: for chain icons- Missing for
Bridge
,Buy
,Swap
- Missing for
amount
s: add to the activity.Entry- already in DB
tokenCode
s: add to the activity.Entry- already in DB
to
/from
/owner
: add to the activity.Entry- already in DB, coming soon
tokenIdentity
: collectible is missing (chainId
,address
,tokenId
)tokenCode
should be covering fungible operations
identity
: for all the sourcestype
: for the main icon and labeltime
: timestamp
Refactoring
Extend entry.nim:ActivityEntry
and activity.go:Entry
with presentation layer data
activityType
: instead of the currentMultiTransactionType
status
: for status icon and label
Current state
Transfers Table
The transfers
transactions raw data
- Transaction identity:
network_id
,hash
,address
- Implementation by
sqlite_autoindex_transfers_1
unique index
- Implementation by
multi_transaction_id
:multi_transaction
entries totransfers
entries mapping (one to many)- Raw data:
tx
transactionreceipt
: transfer receipt
Multi-Transaction Table
Represented by multi_transaction
Responsibilities
- UX metadata for transactions originating from our APP.
from_address
,to_address
from_asset
,to_asset
from_amount
,to_amount
(token codes)type
identifies the type (initially only Send and Bridge)timestamp
the timestamp of the execution
- Multi-transaction to sub-transaction mapping
- The
multi_transaction_id
in thetransfers
andpending_transaction
table corresponds to theROWID
in themulti_transactions
.
- The
Pending Transactions Table
The pending_transactions
table represents transactions initiated from the app
- Transaction identity
network_id
,hash
- implemented by the
sqlite_autoindex_pending_transactions_1
index - Note how this is different from the
transfers
table, where theaddress
is also part of the identity.
- implemented by the
timestamp
: The timestamp of the pending transaction.multi_transaction_id
:multi_transaction
entries topending_transactions
entries mapping (one to many)
Schema
Relationships between the tables
erDiagram
multi_transaction ||--o{ transfers : has
multi_transaction ||--o{ pending_transactions : has
transfers {
network_id BIGINT
hash VARCHAR
timestamp BIGINT
multi_transaction_id INT
tx BLOB
receipt BLOB
log BLOB
}
multi_transaction {
ROWID INT
type VARCHAR
}
pending_transactions {
network_id BIGINT
hash VARCHAR
timestamp INT
multi_transaction_id INT
}
Dropped tasks
Dropped the DB refactoring and improvements after further discussion and concerns
- Terminology proposal
- using
transactions
instead oftransfers
for the raw data - using
activity
instead ofmulti-transaction
to better match the new requirements - Convert JSON blobs into structured data
- using
Dropped benchmark performance and move on using theoretical knowledge by adding indexes for what we know only Will leave the performance concerns for the next milestone
- Joining DBs
- One activity DB for all require metadata
- Pros:
- Faster to query (don't know the numbers)
- Simpler query will decrease maintenance
- Cons:
- have to migrate all data, extract and fill the activity on every download of updates for all activities
- Pros:
- Keep only filter specific metadata in the Activity DB
- Pros:
- Less changes to migrate existing data. Still have to maintain activity filtering specific data
- Cons:
- Slower to query (don't know how much yet)
- Complex query increases maintenance
- Pros: