Skip to content

Track entity manager - #3706

Merged
jowlee merged 3 commits into
masterfrom
jowlee-libs-track-entity
Aug 23, 2022
Merged

jowlee merged 3 commits into
masterfrom
jowlee-libs-track-entity

Conversation

@jowlee

@jowlee jowlee commented Aug 17, 2022

Copy link
Copy Markdown
Contributor

Description

Adds the boolean useEntityManager to the libs Tracks service so that the new contract will conditionally be used based on this boolean.
Note, this updates the method parameters:
uploadTrack: Updates arguments to be object detructed
updateTrack: Updates arguments to add a second param for the boolean
deleteTrack: Updates arguments to add a second param for the boolean

Tests

Ran locally against linked like with and without the boolean set

Monitoring - How will this change be monitored? Are there sufficient logs / alerts?

Comment thread libs/src/api/Track.ts Outdated
}

// Minimum track ID, intentionally higher than legacy track ID range
static MIN_TRACK_ID = 1000000

ghost Aug 18, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread libs/src/api/Track.ts
static MIN_TRACK_ID = 1000000

// Maximum track ID, reflects postgres max integer value
static MAX_TRACK_ID = 2147483647

ghost Aug 18, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you confirm that 2147483647 is not too big to cause any sort of collision with our hash id stuff? My best guess is we have 5 letters BqN19 so 62 ^ 5 which is less than 2 billion

ghost Aug 18, 2022 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i think it works! 5 is just min length and 2147483647 encodes to a 7 letter string

There are no collisions because the method is based on integer to hex conversion. As long as you don't change constructor arguments midway, the generated output will stay unique to your salt.

ghost Aug 18, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AMAZING

Comment thread libs/src/api/Track.ts
let trackId: number
if (useEntityManager) {
trackId = Track.generateTrackId()
const response = await this.contracts.EntityManagerClient!.manageEntity(

ghost Aug 19, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

for subsequent changes should we modify existing files like this? maybe entityManager.ts functions should move over to playlist.

ghost Aug 23, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, that was what I was thinking too, can make that change later though

Comment thread libs/src/utils/utils.ts Resolved

ghost left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM but would prefer waiting for next release to merge

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks sweet! main thing is having to update uploadTrack calls in audius-client when this gets merged

Comment thread libs/src/api/Track.ts
trackFile: File,
coverArtFile: File,
metadata: TrackMetadata,
async uploadTrack({

ghost Aug 23, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a way we are tracking these api changes for when we update in audius-client?

ghost Aug 23, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this seemed scary to me in the case that we revert the libs version and not doing it atomically with the client change. I have the client changes out in PR already too. will try to merge together with libs update

Comment thread libs/src/api/Track.ts Outdated
// Associate the track id with the file metadata and block number
await this.creatorNode.associateTrack(
trackId,
trackId!,

ghost Aug 23, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a clean way to avoid using !, like having if checks and error logs if they aren't there?

Comment thread libs/src/api/Track.ts
async addTracksToChainAndCnode(trackMultihashAndUUIDList: ChainInfo[]) {
async addTracksToChainAndCnode(
trackMultihashAndUUIDList: ChainInfo[],
useEntityManager: boolean

ghost Aug 23, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would it make sense adding useEntityManager as a field on the Track api to internally reference on these methods? or do we want to specify this boolean for each method call?

ghost Aug 23, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

could go either way on it, I personally like the ability to use either for testing, but in practice would be easier to set internally.

Comment thread libs/src/api/Track.ts Outdated
if (useEntityManager) {
trackId = Track.generateTrackId()
const response =
await this.contracts.EntityManagerClient!.manageEntity(

ghost Aug 23, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just wondering why it's nullable here and if there is anything clever we can do about it, nbd tho

ghost Aug 23, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because we are adding a new contract, the entity manager addr might not be passed in and is nullable - https://github.com/AudiusProject/audius-protocol/blob/7c68b2a99e1942173664a26a97f2b9432cb60ca3/libs/src/services/dataContracts/AudiusContracts.ts#L48

@jowlee
jowlee force-pushed the jowlee-libs-track-entity branch from 8e01df0 to f88e426 Compare August 23, 2022 18:16
@jowlee
jowlee merged commit 6659cc6 into master Aug 23, 2022
@jowlee
jowlee deleted the jowlee-libs-track-entity branch August 23, 2022 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants