Architecture for handling slashing transactions
We want to be able to deploy a slashing transaction that will call into the PoS contract that will call a system process to validate that the slashing transaction is valid. If the slashing transaction is indeed valid, then that validator will be slashed. For example, a block may have an incorrect block number (see https://github.com/rchain/rchain/blob/dev/casper/src/main/scala/coop/rchain/casper/Validate.scala#L340 for how this could be), and so it should be slashed.
Approach 1)
Assume as a validator, we see a block A with an incorrect block number. On the next block we create, we deploy a slashing transaction containing block A's hash and a string saying "incorrect block number". The slashing transaction will call into the PoS contract which will call into a SystemProcess that will call Validate.blockNumber at https://github.com/rchain/rchain/blob/dev/casper/src/main/scala/coop/rchain/casper/Validate.scala#L340 . We know to call into SystemProcess that calls Validate.blockNumber instead of some other Validate.*** as the slashing transaction has a string saying "incorrect block number", so we can match against that. This system call will be similar to SystemProcesses.validateRevAddress https://github.com/rchain/rchain/blob/dev/rholang/src/main/scala/coop/rchain/rholang/interpreter/SystemProcesses.scala#L117 . The system call should take a Seq(blockHash) (this is the block hash of block A) and produce (return) true/false on the ack, so we'll have to do some minor adaptor work from the underlying Validate.blockNumber call. Maybe even change the Validate.blockNumber type signature itself but then we'll have to adjust in Validate.blockSummary and the corresponding tests.
Currently casper depends on Rholang but Rholang doesn't depend on casper in build.sbt . We'll have to figure out how to handle this circular dependency - I don't think sbt/scala automatically handles this for you but I could be wrong. Potentially push the Validate.blockNumber in models...
Approach 2)
Assume as a validator, we see a block A with an incorrect block number. When we validate this block A, we mark it as invalid currently. Inject the set of all invalid block hashes into Runtime from casper just like we do for short leash params (see https://github.com/rchain/rchain/blob/dev/casper/src/main/scala/coop/rchain/casper/util/rholang/RuntimeManager.scala#L219 ). The slashing transaction will call into the PoS contract which will call into a SystemProcess that will obtain the set of all invalid block hashes and see if the passed in block hash for block A is contained. If it is contained, then we mark the slashing transaction as valid as the block is indeed invalid.
This approach doesn't have the same circular dependency issue.