user123165: I have set up my custom signet, with my own challenge.
I expected to fail to generate blocks using the 'generatetoaddress' API before importing the private key related to the challenge script in the node wallet, but using bitcoincore 0.21.1 the blocks generation works with just the PoW.
Why?

user48884: generatetoaddress doesn't actually have a restriction on which networks it operates on. You can use it on mainnet, it will just not find any blocks. The way that it is implemented is that it just tries the nonce range for a single block, and if none of those block proposals are valid, then it exits. So if the difficulty is low enough that it is possible to find a block with just the nonce range (rather than needing to change block templates or increment an extra nonce), then generatetoaddress will find blocks.

123165: <p>I have set up my custom signet, with my own challenge.</p>
<p>I expected to fail to generate blocks using the 'generatetoaddress' API before importing the private key related to the challenge script in the node wallet, but using bitcoincore 0.21.1 the blocks generation works with just the PoW.</p>
<p>Why?</p>
 48884: <p><code>generatetoaddress</code> doesn't actually have a restriction on which networks it operates on. You can use it on mainnet, it will just not find any blocks. The way that it is implemented is that it just tries the nonce range for a single block, and if none of those block proposals are valid, then it exits. So if the difficulty is low enough that it is possible to find a block with just the nonce range (rather than needing to change block templates or increment an extra nonce), then <code>generatetoaddress</code> will find blocks.</p>
