From 8d107b0dedf6129032e817db46999fa512e6bb2e Mon Sep 17 00:00:00 2001 From: Darshan K <35736874+darshankabariya@users.noreply.github.com> Date: Mon, 22 Jul 2024 22:28:45 +0530 Subject: [PATCH] fix: handle rln-relay-message-limit (#2867) * fix: enforcing rln-contract max message limit and resolve early --- .../test_rln_group_manager_onchain.nim | 26 ++++++++++++++++++- waku/node/waku_node.nim | 2 ++ waku/waku_rln_relay/contract.nim | 2 +- .../group_manager/group_manager_base.nim | 1 + .../group_manager/on_chain/group_manager.nim | 3 +++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/waku_rln_relay/test_rln_group_manager_onchain.nim b/tests/waku_rln_relay/test_rln_group_manager_onchain.nim index 80c1a2ee3..8d0a48eaa 100644 --- a/tests/waku_rln_relay/test_rln_group_manager_onchain.nim +++ b/tests/waku_rln_relay/test_rln_group_manager_onchain.nim @@ -15,6 +15,9 @@ import eth/keys import waku/[ + waku_node, + node/waku_node, + waku_rln_relay, waku_rln_relay/protocol_types, waku_rln_relay/constants, waku_rln_relay/contract, @@ -22,7 +25,7 @@ import waku_rln_relay/conversion_utils, waku_rln_relay/group_manager/on_chain/group_manager, ], - ../testlib/common, + ../testlib/[wakucore, wakunode, common], ./utils const CHAIN_ID = 1337 @@ -232,6 +235,7 @@ suite "Onchain group manager": manager.wakuRlnContract.isSome() manager.initialized manager.rlnContractDeployedBlockNumber > 0 + manager.rlnRelayMaxMessageLimit == 100 await manager.stop() @@ -775,7 +779,27 @@ suite "Onchain group manager": isReady == true await manager.stop() + + asyncTest "rln-relay-max-message-limit testing": + let + nodekey = generateSecp256k1Key() + node = newTestWakuNode(nodekey, parseIpAddress("0.0.0.0"), Port(0)) + await node.mountRelay(@[DefaultPubsubTopic]) + + let wakuRlnConfig = WakuRlnConfig( + rlnRelayDynamic: false, + rlnRelayCredIndex: some(0.uint), + rlnRelayUserMessageLimit: 111, + rlnRelayTreepath: genTempPath("rln_tree", "wakunode_0"), + ) + + try: + await node.mountRlnRelay(wakuRlnConfig) + except CatchableError as e: + check e.msg == "failed to mount WakuRlnRelay: rln-relay-user-message-limit can't be exceed then MAX_MESSAGE_LIMIT set by rln contract" + + ################################ ## Terminating/removing Anvil ################################ diff --git a/waku/node/waku_node.nim b/waku/node/waku_node.nim index 3a1e0ba45..4be85dc49 100644 --- a/waku/node/waku_node.nim +++ b/waku/node/waku_node.nim @@ -1089,6 +1089,8 @@ proc mountRlnRelay*( raise newException(CatchableError, "failed to mount WakuRlnRelay: " & rlnRelayRes.error) let rlnRelay = rlnRelayRes.get() + if (rlnConf.rlnRelayUserMessageLimit > rlnRelay.groupManager.rlnRelayMaxMessageLimit): + error "rln-relay-user-message-limit can't be exceed then MAX_MESSAGE_LIMIT set by rln contract" let validator = generateRlnValidator(rlnRelay, spamHandler) # register rln validator as default validator diff --git a/waku/waku_rln_relay/contract.nim b/waku/waku_rln_relay/contract.nim index 23bb9ff93..360df6ea7 100644 --- a/waku/waku_rln_relay/contract.nim +++ b/waku/waku_rln_relay/contract.nim @@ -8,7 +8,7 @@ const LazyIMT* = const Erc1967Proxy* = "0x60806040526040516103c73803806103c78339810160408190526100229161025e565b61002c8282610033565b5050610341565b61003c82610091565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a280511561008557610080828261010c565b505050565b61008d61017f565b5050565b806001600160a01b03163b5f036100cb57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516101289190610326565b5f60405180830381855af49150503d805f8114610160576040519150601f19603f3d011682016040523d82523d5f602084013e610165565b606091505b5090925090506101768583836101a0565b95945050505050565b341561019e5760405163b398979f60e01b815260040160405180910390fd5b565b6060826101b5576101b0826101ff565b6101f8565b81511580156101cc57506001600160a01b0384163b155b156101f557604051639996b31560e01b81526001600160a01b03851660048201526024016100c2565b50805b9392505050565b80511561020f5780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b634e487b7160e01b5f52604160045260245ffd5b5f5b8381101561025657818101518382015260200161023e565b50505f910152565b5f806040838503121561026f575f80fd5b82516001600160a01b0381168114610285575f80fd5b60208401519092506001600160401b03808211156102a1575f80fd5b818501915085601f8301126102b4575f80fd5b8151818111156102c6576102c6610228565b604051601f8201601f19908116603f011681019083821181831017156102ee576102ee610228565b81604052828152886020848701011115610306575f80fd5b61031783602083016020880161023c565b80955050505050509250929050565b5f825161033781846020870161023c565b9190910192915050565b607a8061034d5f395ff3fe6080604052600a600c565b005b60186014601a565b605d565b565b5f60587f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b365f80375f80365f845af43d5f803e8080156076573d5ff35b3d5ffd" const Erc1967ProxyContractInput* = - "000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000248d8965bd0000000000000000000000000000000000000000000000000000000000000014" + "000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000248d8965bd0000000000000000000000000000000000000000000000000000000000000064" const WakuRlnV2Contract* = "0x60a06040523060805234801561001457600080fd5b5061001d610022565b6100e1565b600054610100900460ff161561008e5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146100df576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6080516121ca6200011960003960008181610598015281816106330152818161076e01528181610804015261093301526121ca6000f3fe6080604052600436106101805760003560e01c806374e942fa116100d6578063af7b42101161007f578063e493ef8c11610059578063e493ef8c146104e2578063ebf0c71714610516578063f2fde38b1461052b57600080fd5b8063af7b421014610441578063d0383d6814610461578063d90d0ee61461048657600080fd5b806398366e35116100b057806398366e35146103b75780639ac21345146103de578063a45d5e591461042157600080fd5b806374e942fa146103355780638d8965bd146103625780638da5cb5b1461038257600080fd5b80634add651e11610138578063679537f911610112578063679537f9146102d35780636bdcc8ab14610300578063715018a61461032057600080fd5b80634add651e146102805780634f1ef2861461029d57806352d1902d146102b057600080fd5b806322d9730c1161016957806322d9730c146101e55780633659cfe6146102155780633c979b5f1461023757600080fd5b8063037a791a1461018557806309aeb04c146101c8575b600080fd5b34801561019157600080fd5b5060c9546101ae9068010000000000000000900463ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b3480156101d457600080fd5b5060c9546101ae9063ffffffff1681565b3480156101f157600080fd5b50610205610200366004611c81565b61054b565b60405190151581526020016101bf565b34801561022157600080fd5b50610235610230366004611cc3565b610581565b005b34801561024357600080fd5b5060cc546102629064ffffffffff808216916501000000000090041682565b6040805164ffffffffff9384168152929091166020830152016101bf565b34801561028c57600080fd5b5060cb546101ae9063ffffffff1681565b6102356102ab366004611d5c565b610757565b3480156102bc57600080fd5b506102c5610919565b6040519081526020016101bf565b3480156102df57600080fd5b506102f36102ee366004611e34565b6109eb565b6040516101bf9190611e67565b34801561030c57600080fd5b5061020561031b366004611c81565b610b6a565b34801561032c57600080fd5b50610235610b81565b34801561034157600080fd5b50610355610350366004611ebe565b610b95565b6040516101bf9190611edb565b34801561036e57600080fd5b5061023561037d366004611f0d565b610cc4565b34801561038e57600080fd5b5060335460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bf565b3480156103c357600080fd5b506103cc601481565b60405160ff90911681526020016101bf565b3480156103ea57600080fd5b506103fe6103f9366004611c81565b610f5f565b6040805163ffffffff9485168152939092166020840152908201526060016101bf565b34801561042d57600080fd5b5061020561043c366004611f0d565b610fd0565b34801561044d57600080fd5b5061023561045c366004611f28565b610ff5565b34801561046d57600080fd5b5060c9546101ae90640100000000900463ffffffff1681565b34801561049257600080fd5b506104c56104a1366004611c81565b60ca6020526000908152604090205463ffffffff8082169164010000000090041682565b6040805163ffffffff9384168152929091166020830152016101bf565b3480156104ee57600080fd5b506102c57f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000181565b34801561052257600080fd5b506102c5611090565b34801561053757600080fd5b50610235610546366004611cc3565b61112c565b6000811580159061057b57507f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000182105b92915050565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630036106315760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c000000000000000000000000000000000000000060648201526084015b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166106a67f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff161461072f5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610628565b610738816111c6565b60408051600080825260208201909252610754918391906111ce565b50565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001630036108025760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401610628565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166108777f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff16146109005760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401610628565b610909826111c6565b610915828260016111ce565b5050565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146109c65760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610628565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b60608163ffffffff168363ffffffff161115610a43576040517f9ffcd53d00000000000000000000000000000000000000000000000000000000815263ffffffff808516600483015283166024820152604401610628565b60c95463ffffffff6801000000000000000090910481169083161115610aa5576040517f9ffcd53d00000000000000000000000000000000000000000000000000000000815263ffffffff808516600483015283166024820152604401610628565b6000610ab18484611f7a565b610abc906001611f9e565b63ffffffff1667ffffffffffffffff811115610ada57610ada611cde565b604051908082528060200260200182016040528015610b03578160200160208202803683370190505b509050835b8363ffffffff168163ffffffff1611610b6257610b248161139e565b82610b2f8784611f7a565b63ffffffff1681518110610b4557610b45611fbb565b602090810291909101015280610b5a81611fea565b915050610b08565b509392505050565b600080610b7683610f5f565b151595945050505050565b610b8961145c565b610b9360006114c3565b565b610b9d611c62565b610ba5611c62565b6040517f3c251db100000000000000000000000000000000000000000000000000000000815260cc600482015264ffffffffff841660248201526014604482015260009073__$LazyIMT$__90633c251db190606401600060405180830381865af4158015610c25573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610c6b919081019061200d565b905060005b601460ff82161015610cbb57818160ff1681518110610c9157610c91611fbb565b6020026020010151838260ff1660148110610cae57610cae611fbb565b6020020152600101610c70565b50909392505050565b600054610100900460ff1615808015610ce45750600054600160ff909116105b80610cfe5750303b158015610cfe575060005460ff166001145b610d705760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610628565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015610dce57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b610dd661153a565b610dde6115bf565b60c9805463ffffffff8481167fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000009092169190911766100000000000001790915560cb80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000016439092169190911790556040517f61136cec00000000000000000000000000000000000000000000000000000000815260cc60048201526014602482015273__$LazyIMT$__906361136cec9060440160006040518083038186803b158015610eb957600080fd5b505af4158015610ecd573d6000803e3d6000fd5b505060c980547fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff1690555050801561091557600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b600081815260ca6020908152604080832081518083019092525463ffffffff808216808452640100000000909204169282019290925282918291908203610fb157600080600093509350935050610fc9565b80516020820151610fc18161139e565b935093509350505b9193909250565b6000808263ffffffff1611801561057b57505060c95463ffffffff9081169116111590565b81610fff8161054b565b611038576040517f7f3e75af00000000000000000000000000000000000000000000000000000000815260048101829052602401610628565b8161104281610fd0565b611080576040517f6677a0c700000000000000000000000000000000000000000000000000000000815263ffffffff82166004820152602401610628565b61108a848461163c565b50505050565b6040517f39ebe6e300000000000000000000000000000000000000000000000000000000815260cc60048201526014602482015260009073__$LazyIMT$__906339ebe6e390604401602060405180830381865af4158015611103573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112791906120b3565b905090565b61113461145c565b73ffffffffffffffffffffffffffffffffffffffff81166111bd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610628565b610754816114c3565b61075461145c565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156112065761120183611911565b505050565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561128b575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252611288918101906120b3565b60015b6112fd5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401610628565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc81146113925760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401610628565b50611201838383611a01565b6040517f0c26d68300000000000000000000000000000000000000000000000000000000815260006004820181905263ffffffff831660248301529060cd90829073__$LazyIMT$__90630c26d68390604401602060405180830381865af415801561141b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061143f91906120cc565b64ffffffffff168152602001908152602001600020549050919050565b60335473ffffffffffffffffffffffffffffffffffffffff163314610b935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610628565b6033805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166115b75760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610628565b610b93611a26565b600054610100900460ff16610b935760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610628565b61164582610b6a565b1561167b576040517e0a60f700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60c95463ffffffff640100000000820481166801000000000000000090920416106116d2576040517f57f6953100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051808201825283815263ffffffff8316602082015290517f561558fe00000000000000000000000000000000000000000000000000000000815260009173__$PoseidonT3$__9163561558fe9161173a916004016120e9565b602060405180830381865af4158015611757573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061177b91906120b3565b60408051808201825263ffffffff858116825260c95468010000000000000000900416602082015290517f0224ef5e00000000000000000000000000000000000000000000000000000000815260cc6004820152602481018390529192509073__$LazyIMT$__90630224ef5e9060440160006040518083038186803b15801561181157600080fd5b505af4158015611825573d6000803e3d6000fd5b505050600085815260ca6020908152604091829020845181548684015163ffffffff908116640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000909216928116929092171790915560c954835187815268010000000000000000909104909116918101919091527fb84da12e8207adb5ee3e5686338302ffe6634fbb95a9fd52f8a466ea2010152d92500160405180910390a1600160c960088282829054906101000a900463ffffffff166118ed9190611f9e565b92506101000a81548163ffffffff021916908363ffffffff16021790555050505050565b73ffffffffffffffffffffffffffffffffffffffff81163b61199b5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401610628565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b611a0a83611aac565b600082511180611a175750805b156112015761108a8383611af9565b600054610100900460ff16611aa35760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610628565b610b93336114c3565b611ab581611911565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6060611b1e83836040518060600160405280602781526020016121a360279139611b25565b9392505050565b60606000808573ffffffffffffffffffffffffffffffffffffffff1685604051611b4f9190612135565b600060405180830381855af49150503d8060008114611b8a576040519150601f19603f3d011682016040523d82523d6000602084013e611b8f565b606091505b5091509150611ba086838387611baa565b9695505050505050565b60608315611c26578251600003611c1f5773ffffffffffffffffffffffffffffffffffffffff85163b611c1f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610628565b5081611c30565b611c308383611c38565b949350505050565b815115611c485781518083602001fd5b8060405162461bcd60e51b81526004016106289190612151565b6040518061028001604052806014906020820280368337509192915050565b600060208284031215611c9357600080fd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611cbe57600080fd5b919050565b600060208284031215611cd557600080fd5b611b1e82611c9a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611d5457611d54611cde565b604052919050565b60008060408385031215611d6f57600080fd5b611d7883611c9a565b915060208084013567ffffffffffffffff80821115611d9657600080fd5b818601915086601f830112611daa57600080fd5b813581811115611dbc57611dbc611cde565b611dec847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611d0d565b91508082528784828501011115611e0257600080fd5b80848401858401376000848284010152508093505050509250929050565b803563ffffffff81168114611cbe57600080fd5b60008060408385031215611e4757600080fd5b611e5083611e20565b9150611e5e60208401611e20565b90509250929050565b6020808252825182820181905260009190848201906040850190845b81811015611e9f57835183529284019291840191600101611e83565b50909695505050505050565b64ffffffffff8116811461075457600080fd5b600060208284031215611ed057600080fd5b8135611b1e81611eab565b6102808101818360005b6014811015611f04578151835260209283019290910190600101611ee5565b50505092915050565b600060208284031215611f1f57600080fd5b611b1e82611e20565b60008060408385031215611f3b57600080fd5b82359150611e5e60208401611e20565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b63ffffffff828116828216039080821115611f9757611f97611f4b565b5092915050565b63ffffffff818116838216019080821115611f9757611f97611f4b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600063ffffffff80831681810361200357612003611f4b565b6001019392505050565b6000602080838503121561202057600080fd5b825167ffffffffffffffff8082111561203857600080fd5b818501915085601f83011261204c57600080fd5b81518181111561205e5761205e611cde565b8060051b915061206f848301611d0d565b818152918301840191848101908884111561208957600080fd5b938501935b838510156120a75784518252938501939085019061208e565b98975050505050505050565b6000602082840312156120c557600080fd5b5051919050565b6000602082840312156120de57600080fd5b8151611b1e81611eab565b60408101818360005b6002811015611f045781518352602092830192909101906001016120f2565b60005b8381101561212c578181015183820152602001612114565b50506000910152565b60008251612147818460208701612111565b9190910192915050565b6020815260008251806020840152612170816040850160208701612111565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564" diff --git a/waku/waku_rln_relay/group_manager/group_manager_base.nim b/waku/waku_rln_relay/group_manager/group_manager_base.nim index e6d55fb09..b43ab3719 100644 --- a/waku/waku_rln_relay/group_manager/group_manager_base.nim +++ b/waku/waku_rln_relay/group_manager/group_manager_base.nim @@ -33,6 +33,7 @@ type GroupManager* = ref object of RootObj validRoots*: Deque[MerkleNode] onFatalErrorAction*: OnFatalErrorHandler userMessageLimit*: Option[UserMessageLimit] + rlnRelayMaxMessageLimit*: uint64 # This proc is used to initialize the group manager # Any initialization logic should be implemented here diff --git a/waku/waku_rln_relay/group_manager/on_chain/group_manager.nim b/waku/waku_rln_relay/group_manager/on_chain/group_manager.nim index e1dabc22a..70c69b554 100644 --- a/waku/waku_rln_relay/group_manager/on_chain/group_manager.nim +++ b/waku/waku_rln_relay/group_manager/on_chain/group_manager.nim @@ -46,6 +46,8 @@ contract(WakuRlnContract): proc commitmentIndex(): UInt256 {.view.} # this constant describes the block number this contract was deployed on proc deployedBlockNumber(): UInt256 {.view.} + # this constant describes max message limit of rln contract + proc MAX_MESSAGE_LIMIT(): UInt256 {.view.} type WakuRlnContractWithSender = Sender[WakuRlnContract] @@ -617,6 +619,7 @@ method init*(g: OnchainGroupManager): Future[GroupManagerResult[void]] {.async.} debug "using rln contract", deployedBlockNumber, rlnContractAddress = contractAddress g.rlnContractDeployedBlockNumber = cast[BlockNumber](deployedBlockNumber) g.latestProcessedBlock = max(g.latestProcessedBlock, g.rlnContractDeployedBlockNumber) + g.rlnRelayMaxMessageLimit = cast[uint64](await wakuRlnContract.MAX_MESSAGE_LIMIT().call()) proc onDisconnect() {.async.} = error "Ethereum client disconnected"