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: changed tx args transport format to JSON + proof support #58

Merged
merged 21 commits into from
Jan 17, 2024

Conversation

maht0rz
Copy link
Member

@maht0rz maht0rz commented Oct 12, 2023

This PR changes the args transport layer to JSON[] from Field[], fixing encoding/decoding of certain args types such as Struct or Signature.

Proof support will be also possible thanks to this PR - but we need to add proof argsHash support using public input/output in a separate PR

@maht0rz maht0rz changed the title feat: changed tx args transport format to JSON [WIP] feat: changed tx args transport format to JSON + proof support Oct 19, 2023
@maht0rz maht0rz changed the title [WIP] feat: changed tx args transport format to JSON + proof support feat: changed tx args transport format to JSON + proof support Nov 2, 2023
toJSON: (value: unknown) => any;
}

export interface ProofTypes {
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename this to something more verbose?

@@ -150,13 +149,12 @@ export class QueryGraphqlModule<
): GraphQLScalarType | ObjectType {
// This is a temporary workaround until transport-layer has been
Copy link
Member

Choose a reason for hiding this comment

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

I think I wanted this to be changed somehow when doing the json transport layer - but I am not sure anymore how exactly I wanted this to change. So I guess we can remove this comment 🤔

const valueFieldLength = MethodParameterDecoder.fieldSize(valueType);

const dummyValue = valueType.fromFields(
range(0, valueFieldLength).map(() => Field(0))
range(0, valueFieldLength).map(() => Field(0)),
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we use ProvablePureExtended so we can skip the auxilary data input here? Since the input type is of FlexibleProvablePure

@@ -45,6 +45,19 @@ export interface ToFieldable {
toFields: () => Field[];
}

export interface ToFieldableStatic {
Copy link
Member

Choose a reason for hiding this comment

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

What does "static" in this context mean? If it is of the sense of being only used on class-types that implement the interface on a static level, we might add new(..args: unknown[]) => unknown to this signature so that it can't be used on objects

// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const paramtypes = Reflect.getMetadata(
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const paramtypes: ProvableExtended<unknown>[] = Reflect.getMetadata(
Copy link
Member

Choose a reason for hiding this comment

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

We should reflect the possibility of it being undefined in the type

methodName
);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const parameterTypes: ProofTypes[] | ToFieldableStatic[] =
Copy link
Member

Choose a reason for hiding this comment

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

Either use ArgumentTypes[] here if applicable or (ProofTypes | ToFieldableStatic)[]

@@ -222,8 +222,6 @@ export class Runtime<Modules extends RuntimeModulesRecord>
// TODO Remove after changing DFs to type-based approach
public create(childContainerProvider: ChildContainerProvider) {
super.create(childContainerProvider);

this.registerDependencyFactories([MethodIdFactory]);
Copy link
Member

Choose a reason for hiding this comment

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

Have you tested that this works? I am worried that when we move this to the AppChain, we get some dependency cycles though Runtime not being configured yet and MethodIdFactory needing an initialized runtime. I had this once during testing that.
Alternative would be register it both on Runtime & Sequencer

const runtimeModule = this.runtime.resolve(moduleName as any);

// find types of args for the runtime method thats being called
const parameterTypes: FlexibleProvable<unknown>[] = Reflect.getMetadata(
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const parameterTypes:
Copy link
Member

Choose a reason for hiding this comment

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

Again, integrate the types inside the Array (A | B | C)[]

@@ -37,11 +37,6 @@ export class TransactionValidator {
methodPath[1]
);

Copy link
Member

Choose a reason for hiding this comment

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

I guess validation will be a seperate PR? Would be nice to have for IST

@maht0rz maht0rz merged commit e9709ad into develop Jan 17, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants