Skip to content

Feature/add tx filter#15

Open
Tsuyoshi-Ishikawa wants to merge 23 commits intomasterfrom
feature/add_tx_filter
Open

Feature/add tx filter#15
Tsuyoshi-Ishikawa wants to merge 23 commits intomasterfrom
feature/add_tx_filter

Conversation

@Tsuyoshi-Ishikawa
Copy link
Contributor

No description provided.

Copy link
Collaborator

@ironbeer ironbeer left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request, I commented so please check it!

@Tsuyoshi-Ishikawa
Copy link
Contributor Author

Tsuyoshi-Ishikawa commented Feb 21, 2023

Modify address check logic

  • enable to set * to allowList.
  • enable to set address array to allowList.
  • enable to set address array to deniedList.
  • disable to set both allowList and deniedList.
    40870fb


This configuration method is confusing, so we changed to a checking method using isIncludedAddress.
https://github.com/oasysgames/verse-proxy/blob/master/src/services/allowCheck.service.ts#L46-L59

Copy link
Collaborator

@ironbeer ironbeer left a comment

Choose a reason for hiding this comment

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

Thank you for your update! I commented, so please check again.

webhook,
);
if (status >= 400) {
webhookCheck = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should check after Promise.all as the result depends on the order in which the Wenhooks finished.

const statuses = await Promise.all(hooks.map(...))
const result = statuses.every(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.

I modified to checkWebhook to throw an error if there is an error

try {
const res = await lastValueFrom(
this.httpService.post(webhook.url, webhookBody, axiosConfig).pipe(
retry(webhook.retry),
catchError((e) => {
throw e;
}),
),
);
if (res.status < 200 || res.status >= 300)
throw new Error('transaction is not allowed');
} catch (e) {
if (e instanceof Error) {
throw new JsonrpcError(e.message, -32602);
}
throw e;
}


const webhookBody = {
...(webhook.parse ? tx : body),
_meta: { ip, headers: verseHeaders },
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that headers should be passed as it is, but what about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I agree with you.
Set the header of the proxy request in _meta.header.

127031f#diff-95cb68dc1b2fad5c19e602ed7ba97f727c4afdcfa35c27c06697cf93ad8f292cR13-R17

);

if (fromCheck && toCheck && valueCheck) {
let webhookCheck = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Webhooks are expensive, so please continue early.
e.g.

if (!(fromCheck && toCheck && contractCheck && valueCheck)) {
  continue
}

// call webhooks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.
Fixed as well as rate limit.

if (fromCheck && toCheck && contractCheck && valueCheck) {
if (condition.rateLimit)
await this.rateLimitService.checkRateLimit(
from,
to,
methodId,
condition.rateLimit,
);
if (condition.webhooks) {
await this.webhookService.checkWebhook(
webhookArg,
condition.webhooks,
);
}

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