-
Notifications
You must be signed in to change notification settings - Fork 20
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
Paima events #390
Paima events #390
Conversation
@@ -95,16 +96,18 @@ class BatchedTransactionPoster { | |||
value: '0x' + Number(this.fee).toString(16), | |||
gasLimit: estimateGasLimit(msg.length), | |||
}); | |||
const receipt = (await transaction.extra.wait())!; | |||
// TODO ONLY ACTIVATE IN ASYNC MODE!!!1! |
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.
?
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.
This is something I'm still looking into. Waiting for confirmation adds a couple of seconds.
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 set up an ENV variable for this.
There looks like no great solution, but it can take 3-4 seconds to get the confirmations.
When using the paima-events you want to know the input-hash quickly, and expect to be posted eventually.
await new Promise(resolve => setTimeout(resolve, n)); | ||
|
||
export enum MQTTSystemEvents { | ||
BATCHER_HASH = '/sys/batch_hash', |
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.
what is the rationale for the /sys/
prefix here? What is the naming convention you're following?
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.
for paima events
/system/engine/stf
/system/batcher/hash/{hash}
...
for game events
/game/whatever
let emulated: number | undefined; | ||
let blockNumber: number = chainData.blockNumber; |
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.
Probably better to define these inside the if block instead of up here. Also, I think it's generally safer too use IIFE instead of using let
like this to avoid the variables accidentally going unasigned during refactoring
@@ -14,5 +14,6 @@ | |||
{ "path": "../../paima-sdk/paima-utils/tsconfig.build.json" }, | |||
{ "path": "../../node-sdk/paima-utils-backend" }, | |||
{ "path": "../../paima-sdk/paima-mw-core/tsconfig.json" }, | |||
// { "path": "../../node-sdk/paima-broker/tsconfig.build.json" }, |
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.
Is this meant to be commented out?
{ "path": "../../paima-sdk/paima-utils/tsconfig.build.json" }, | ||
{ "path": "../../node-sdk/paima-db" }, | ||
{ "path": "../paima-rest/tsconfig.build.json" }, | ||
{ "path": "../paima-sm" }, | ||
// { "path": "../../node-sdk/paima-broker/tsconfig.build.json" }, |
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.
Again, is this meant to be commented out?
return parseInt(process.env.MQTT_BROKER_PORT || '8883', 10); | ||
} | ||
static get MQTT_BATCHER_BROKER_PORT(): number { | ||
return parseInt(process.env.MQTT_BROKER_PORT || '8884', 10); |
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.
We have 8883
and 8884
hard-coded in many places despite them being specified here. I think it's because in a lot of places we return undefined
as a possibility even though these config
files are meant to avoid the undefined case
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.
This is the issue with the 'complex' interface.
This module can be called by paima-engine and the batcher.
They do not share a common interface for ENVs so one alternative is:
import type { ENV as ENV1 } from '@paima/batcher-utils';
import type { ENV as ENV2 } from '@paima/paima-utils';
...
constructor(private env: typeof ENV1 | typeof ENV2) {}
...
this.env.I_CAN_USE_METHODS_DEFINED_IN_BOTH
But this made the Interface have to pass the global ENV (not very nice)
* Simplified events draft * Simplify even more * lint fix * make indexed optional, fix exports, rename fields * MQTT async update * move to qos2 by default * eslint & bug fixes * temp fix on packaeg resolution * Create new local SDK packing tool * Add missing packages to local SDK output * more improvements to local SDK setup * add missing @paima/precompiles exports * fix paima-event bugs * small eslint fix * Fix topic generation & parsing bugs * Better 'this' handling for events * More fixes and improvements * Make batcher filter indexable * Fix incorrect casing on BatcherStatus * Restrict event publishing just to localhost * fix batcher localhost startup script * Add localhost package check * document edge-case on BatcherStatus updates
a085293
to
8bc00ce
Compare
New packages
@paima/events
This PR introduces an event system and also sets up the events to use
typebox
so that it is both strongly typed and so that we can later export them as json-schema for documentation purposes and so that it works well with the json-schema we'll use for the log systemHandling shutdowns in event listeners
in Emit event standard for games #373)/
,+
,#
) in event namesDefine an event
Listen to Messages
Listen to an event
Send Messages
Sent an event
@paima/broker
Start MQTT Server
This creates a WebSocket MQTT server
Tarochi Example (with Batcher)
Screen.Recording.2024-07-15.at.12.30.55.mp4
Card-Game (Direct TX)
Screen.Recording.2024-07-15.at.17.20.15.mp4
Overview