SimpleOwnership Predicate¶
Overview¶
The ownership predicate is the one of the simplest useful predicates. It gives an address, specified as the state.data.owner
, the ability to execute a state transition which changes any part of the owned subrange to a new StateObject
by signing an approval transaction.
Predicate API¶
getOwner¶
{
name: "getOwner",
constant: true,
inputs: [],
outputs: [
{
name: "stateOwner",
type: "address"
}
]
}
Description¶
The getOwner
API method allows the client or operator to query the current owner of the state.
Inputs¶
N/A
Outputs¶
- stateOwner - address: the current owner based on the state object. Will equal
data.owner
.
Justification¶
This function allows developers to get the owner without directly dissecting the state object.
send¶
{
name: "send",
constant: false,
inputs: [
{
name: "newStateObject",
type: "StateObject"
},
{
name: "originBlock",
type: "uint"
}
],
outputs: []
}
Description¶
The send
method is used to set the state to a new arbitrary state object, given a signature.
Inputs¶
newStateObject
-StateObject
: the state object that the owner desires to mutate to.originBlock
-uint
: the maximum plasma blocknumber of the ownershipStateUpdate
s from which you are spending.
Outputs¶
N/A
Justification¶
Being able to spend to any new state is the base property of ownership. The targetBlock
may be used to produce replay protection while allowing some level of asynchronicity between the client and operator.
State Object Specification¶
struct ownershipStateData:
owner: address
Fields¶
- owner - address: The Ethereum public address of the person who may mutate the state.
Additional Exit Game Logic¶
N/A
Predicate Contract Logic¶
Transition Execution¶
def verifyTransaction(preState: StateUpdate, transaction: Transaction, witness: bytes postState: StateUpdate)
Requirements¶
- MUST ensure that the
witness
is a signature by thepreState.stateObject.owner
on thetransaction
. - MUST ensure that the
preState.plasmaBlockNumber
is less than theinput.parameters.originBlock
. - MUST ensure that the
postState.range
is the same astransaction.start
andtransaction.end
. - MUST ensure that the
transaction.parameters.newState
is the same as thepostState.state
.
Rationale¶
These conditions allow a signature by the sender to approve only a single output state.
Exit Finalization Logic¶
def onFinalizeExit(owner: address, ERC20Contract: address, amount: uint256)
Parameters¶
owner
-address
: the owner of the exit.ERC20Contract
-address
: The ERC20 contract the ownership is of.amount
-uint256
: the amount of the ERC20 token being redeemed.
Description¶
This function is called internally by the predicate when it needs to handle an exit, whether as a limbo target or as a regular exit.
Requirements¶
- MUST only allow this method to be called internally.
- MUST Send the total
amount
to theowner
.
Rationale¶
The owner of a range gets all of the assets it corresponds to.
Limbo Exit Logic¶
As with all predicates in this spec, the ownership predicate supports limbo exit functionality. As such, it MUST fulfill all the methods and requirements outlined in the limbo standard outlined in the contracts section of this spec. Additional requirements for some of the methods in this predicate are shown below. They are quite simple as the ownership predicate is mostly pure functions.
function onTargetedForLimboExit(
Checkpoint _sourceExit,
StateUpdate _limboTarget
) public
N/A–just return!
There’s no custom exit logic for the ownership predicate if it’s a limbo exit, so no additional functionality needed.
function canReturnLimboExit(
Checkpoint _limboSource,
StateUpdate _limboTarget
bytes _witness
) public returns (bool)
The _witness
is be unused for this predicate.
- MUST ensure that the tx.origin is the
state.data.owner
of thelimboTarget
We require the target owner’s permission to return a limbo exit.
function finalizeExit(
Checkpoint _exit
) public
- MUST fulfill the generic requirements for
finalizeExit
. - MUST make an internal call to
onFinalizeExit
to send the total amount to the_exit.stateUpdate.owner
.
The finalization logic for limbo and non-limbo exits remains the same.
function onFinalizeTargetedExit(
Checkpoint _exit,
StateUpdte _target
) public
Logic for the target of a limbo exit to handle the exit’s finalization.
- MUST make an internal call to
onFinalizeExit
to send the total amount to the_target.stateUpdate.owner
.
The finalization logic for limbo and non-limbo exits remains the same.
Verification Plugin¶
State Transitions¶
def executeStateTransition(preState: StateUpdate, transaction: StandardTransaction)
Requirements¶
- MUST ensure that the
transaction.witness
is a signature by thepreState.stateObject.owner
. - MUST ensure that the
preState.plasmaBlockNumber
is less thana theinput.parameters.originBlock
. - MUST return a
StateUpdate
with a range the same astransaction.start
andtransaction.end
. - MUST return a
StateUpdate
withstate
is the same as thetransaction.parameters.newState
.
Rationale¶
These steps always produce a StateUpdate
which passes the predicate contract’s verifyStateTransition
step.
Guarding Plugin¶
TODO