-
Notifications
You must be signed in to change notification settings - Fork 153
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
refactor(core): remove unnecessary accumulatorQueue
in offchain instance
#866
Conversation
574df96
to
2138177
Compare
accumulatorQueue
in offchain instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks neat! left a few comments here and there, any questions lmk. Great work
MaciState, | ||
packProcessMessageSmallVals, | ||
unpackProcessMessageSmallVals, | ||
} from "../"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen you using a mix of ways of importing, for instance within Poll and MaciState you import from the actual file (i.e. import {x} from ./utils/utils) and here you import directly everything from index.ts -> Please make sure it's all consistent (not sure if anyone has a preference here on whether to import from index or from the actual file from within the same package so I'll leave that up to you to decide/find out)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I've been importing directly from the actual path when it's within the same package, but for external packages, I thought referencing from index.ts was the standard approach. I've also treated test files as external, even though they're in the same package directory. However, I'm not entirely certain about the most idiomatic way to handle imports in JS🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0xmad what's your take here on what's the most appropriate way to deal with imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we need to be careful because index import usually produce cycle dependencies. From my experience, we had test forlder for each module/component
and just imported from index file.
172ce79
to
464487f
Compare
@ctrlc03 Thanks for the review! I've made the revisions you suggested. Please take another look |
accumulatorQueue
in offchain instanceaccumulatorQueue
in offchain instance
accumulatorQueue
in offchain instanceaccumulatorQueue
in offchain instance
core/ts/Poll.ts
Outdated
@@ -31,7 +30,6 @@ const blankStateLeafHash = blankStateLeaf.hash(); | |||
interface IPoll { | |||
topupMessage(_message: Message): void; | |||
publishMessage(_message: Message, _encPubKey: PubKey): void; | |||
mergeAllMessages(): void; | |||
hasUnprocessedMessages(): boolean; | |||
processMessages(_pollId: number): unknown; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hadn't noticed this before, but it should not be unknown, it can cause issues on other packages that depend on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also it looks that some functions are set to return void like tallyVotes - for now maybe just add any before we create better typings?
example of what went wrong on another PR due to this:
ts/__tests__/TallyVotes.test.ts(119,63): error TS2339: Property 'length' does not exist on type 'unknown'.
That is using the return value of tallyVotes (the circuit inputs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing
✅ Deploy Preview for maci-typedoc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@ctrlc03 Please take another look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for applying changes, LGTM
This PR removes the accumulatorQueue from our off-chain
MaciState
andPoll
instances. Given the absence of on-chain gas constraints off-chain, this data structure is redundant. The primary mechanism for state management remains the quinary Merkle tree.