Event ignored in a sentinel setup with serverless

I'm using https://github.com/OpenZeppelin/defender-serverless to manage and deploy resources. It's really simplifying our flow, a great tool :clap: However, when deploying a sentinel with a contract event as a condition, it gets ignored and the event is not registered.

My "serverless.yml":

    sentinels:
      watcher-polygon:
        name: Watcher Polygon
        type: BLOCK
        network: matic
        addresses:
          - <ADDRESS>
        paused: false
        autotask-condition: ${self:functions.autotask-polygon}
        autotask-trigger: ${self:functions.autotask-polygon}
        confirm-level: 1
        notify-config:
          channels: []
        conditions:
          event:
            - signature: XCalled(bytes32,address,address,uint256,address,uint256,bytes)

After running "sls deploy":

Hi @bob,

Could you try with the signature as a string, and actually also other values which are non integer, they should be a string also, name, type, etc.

Getting the same result with:

    sentinels:
      watcher-polygon:
        name: "Watcher Polygon"
        type: "BLOCK"
        network: "matic"
        addresses:
          - <ADDR>
        paused: false
        autotask-condition: ${self:functions.autotask-polygon}
        autotask-trigger: ${self:functions.autotask-polygon}
        confirm-level: 1
        notify-config:
          channels: []
        conditions:
          event:
            - expression: null
              signature: "XCalled(bytes32,address,address,uint256,address,uint256,bytes)"

Hi @bob

Thanks for giving that a try. Are you getting any warnings or errors in the output? Can you try running the deploy with the โ€”verbose flag as well?

No errors or warnings except for aws-sdk, here's the output with --verbose:

That looks fine.

Would you mind sending the entire serverless.yml file to
defender-support@openzeppelin.com ?

That would hopefully allow us to replicate the issue and make it slightly easier to debug on our side.

1 Like

Hi @bob

Looks like you're missing the abi property.
The ABI is required for block-type sentinels (as opposed to Forta-type) if you wish to have at least one condition. I've tested this locally, and by adding the ABI you should see the desired result:

watcher-polygon:
    name: Watcher Polygon
    type: BLOCK
    network: matic
    abi: ${file(./abis/connextrouter.json.abi)}
    ....

Hope that helps!

1 Like

Awesome, thank you :star_struck: That resolved it :+1:

Some notes/questions:

  • When I started implementing this, I couldn't find how to set up sentinels with serverless. What I did was set up one manually. Then, I downloaded the serverless config from the UI. The "abi" field wasn't there, so I guess, it needs to be fixed there too.
  • Initially, I created the abi file as ".json" and added it: ${file(./abis/connextrouter.json)} but it didn't work, throwing this error:
Configuration error:                                                                                                                                                         
     at 'resources.Resources.sentinels.watcher-polygon': unsupported string format

It only got to work with ".abi" as an ext. I'm curious why and if there's a special function (smth like "file-json") to read jsons.

Thanks once again, using serverless for this is dope!

Glad to hear :slight_smile:

We auto-generate our documentation based on the JSON schemas. You can find a reference of that in the README or on our documentation page. For block sentinels specifically, you can find the properties here.

We do not export the ABI from the defender export due to response size limitations, similarly for autotask code.

As for the error you're getting when using .json rather than .json.<x> , I'm not 100% sure the reason behind this. However, I believe this might be due to how ${file(...)} interprets files. .json files. I think these are automatically resolved to objects, rather than a string.

1 Like