Difference between relay worker and relay manager

Hi, I just read through the official gsn document, and wondering what’s the difference between relay worker and relay manager, I noticed when I try to stake for the relayer, it also sent 0.3 ether to the relay worker address, what’s the purpose of it?

And I couldn’t find a way to withdraw my ether in relay worker and manager, could you tell me how to do that or point me to the document reference?

Thank you!

The relayManager is the address that gets registered as a relayer, and gets staked.
the relayWorker is the address that is used for actually sending the requests, and has to be registered with the manager.
It is possible that a relayer server will have multiple worker address, and thus will be able to serve clients at a higher rate.
Note that while the contracts are ready for this change, we didn’t implement it yet into our relayer server.

I see, could you also guide me how to withdraw ethers in relayWorker's and relayManager's address? Thanks!

@drortirosh I see, could you also guide me how to withdraw ethers in relayWorker 's and relayManager 's address? Thanks!

If you unstake your relayer, it will automatically withdraw all funds from both worker and manager (after the unstake delay)
note that the worker can’t send its balance before unstaking: any transaction except a valid relayCall() is considered illegal, and make your relayer penalizeable,which means its stake will be burnt. This prevents various attacks from malicious relayers on the system.
Technically, you can withdraw funds from the manager even before unstaking. However, the current relayer doesn’t have the code to do it.
we do want to add a configuration parameter that will cause the manager to send collected funds to its owner once it reaches a configured threshold.
If you want to do it right now, you can look into the relayer’s KeyManager.ts code, and see how it uses the “seed” stored in ./gsnconfig/manager/keystore to create ethereumjs-wallet/hdkey and extract the private key from that.

@drortirosh Got it, thanks! Just want to make sure that is it correct that relayHub will responsible for rebalancing relayWorker? Will relayManager send ethers to relayWorker? and who will trigger this event? I have read through the RelayHub.sol but didn’t find the answer, thank you for the help and guidance.

the manager is responsible to rebalance the worker from it’s funds (and from it’s transaction fees).

to perform the withdraw itself, call the unlockStake(relayManager) method of the StakeManager from the owner’s account.
the stake is locked for the “unstake delay” (8 hours on testnet, about a week on mainnet). After that delay, the relayer will automatically send all funds on the manager’s address.
only then the VM can be stopped and removed.