Skip to content
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

feat(cu): add process tags to AoGlobal.process.tags #192 #196

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions servers/cu/src/domain/client/ao-su.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const loadMessagesWith = ({ fetch, SU_URL, logger: _logger, pageSize }) =
return tag.value
}

function mapAoMessage ({ processId, processOwner }) {
function mapAoMessage ({ processId, processOwner, processTags }) {
return async function * (edges) {
for await (const edge of edges) {
yield pipe(
Expand Down Expand Up @@ -185,7 +185,7 @@ export const loadMessagesWith = ({ fetch, SU_URL, logger: _logger, pageSize }) =
timestamp: path(['block', 'timestamp'])
}),
AoGlobal: applySpec({
process: always({ id: processId, owner: processOwner }),
process: always({ id: processId, owner: processOwner, tags: processTags }),
block: applySpec({
height: path(['block', 'height']),
timestamp: path(['block', 'timestamp'])
Expand All @@ -200,10 +200,10 @@ export const loadMessagesWith = ({ fetch, SU_URL, logger: _logger, pageSize }) =
return (args) =>
of(args)
.map(mapBounds)
.map(({ processId, owner: processOwner, from, to }) => {
.map(({ processId, owner: processOwner, tags: processTags, from, to }) => {
return pipeline(
fetchAllPages({ processId, from, to }),
Transform.from(mapAoMessage({ processId, processOwner })),
Transform.from(mapAoMessage({ processId, processOwner, processTags })),
(err) => {
if (err) logger('Encountered err when mapping Sequencer Messages', err)
}
Expand Down
1 change: 1 addition & 0 deletions servers/cu/src/domain/lib/loadMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ function loadSequencedMessagesWith ({ loadMessages, loadBlocksMeta, logger }) {
.chain(args => loadMessages({
processId: args.id,
owner: args.owner,
tags: args.tags,
from: args.from, // could be undefined
to: args.to // could be undefined
}))
Expand Down
17 changes: 12 additions & 5 deletions servers/cu/src/domain/lib/loadProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ function getProcessMetaWith ({ loadProcess, findProcess, saveProcess, logger })
: Rejected(`Tag '${name}' of value '${tags[name]}' was not valid on transaction`)

/**
* Load the process from chain, extracting the metadata,
* Load the process from the SU, extracting the metadata,
* and then saving to the db
*
* TODO: could we eventually load all of this from the SU?
* for now, just loading Block, since that's the only bit that doesn't finalize
*/
function loadFromSu (processId) {
return loadProcess(processId)
Expand Down Expand Up @@ -136,8 +133,18 @@ function loadLatestEvaluationWith ({ findLatestEvaluation, logger }) {
* is always added to context
*/
const ctxSchema = z.object({
/**
* The wallet address of of the process owner
*/
owner: z.string().min(1),
/**
* The tags on the process
*/
tags: z.array(rawTagSchema),
/**
* The block height and timestamp, according to the SU,
* that was most recent when this process was spawned
*/
block: rawBlockSchema,
/**
* The most recent state. This could be the most recent
Expand Down Expand Up @@ -199,7 +206,7 @@ export function loadProcessWith (env) {
.chain(ctx =>
loadLatestEvaluation(ctx)
.map(mergeRight(ctx))
// { id, owner, ..., buffer, result, from, evaluatedAt }
// { id, owner, tags, ..., buffer, result, from, evaluatedAt }
)
.map(ctxSchema.parse)
.map(logger.tap('Loaded process and appended to ctx'))
Expand Down
3 changes: 2 additions & 1 deletion servers/cu/src/domain/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export const messageSchema = z.object({
AoGlobal: z.object({
process: z.object({
id: z.string(),
owner: z.string()
owner: z.string(),
tags: z.array(rawTagSchema)
}),
block: rawBlockSchema
// TODO: more here
Expand Down