|
|
|
@ -283,16 +283,22 @@ func (c *crossShardXferPrecompile) RunWriteCapable( |
|
|
|
|
// now do the actual transfer
|
|
|
|
|
// step 1 -> remove funds from the precompile address
|
|
|
|
|
evm.Transfer(evm.StateDB, contract.Address(), toAddress, value, types.SubtractionOnly) |
|
|
|
|
// step 2 -> make a cross link
|
|
|
|
|
// note that the transaction hash is added by state_processor.go to this receipt
|
|
|
|
|
// and that the receiving shard does not care about the `From` but we use the original
|
|
|
|
|
// instead of the precompile address for consistency
|
|
|
|
|
evm.CXReceipt = &types.CXReceipt{ |
|
|
|
|
From: fromAddress, |
|
|
|
|
To: &toAddress, |
|
|
|
|
ShardID: fromShardID, |
|
|
|
|
ToShardID: toShardID, |
|
|
|
|
Amount: value, |
|
|
|
|
// make sure that cxreceipt is already nil to prevent multiple calls to the precompile
|
|
|
|
|
// in the same transaction
|
|
|
|
|
if evm.CXReceipt == nil { |
|
|
|
|
// step 2 -> make a cross link
|
|
|
|
|
// note that the transaction hash is added by state_processor.go to this receipt
|
|
|
|
|
// and that the receiving shard does not care about the `From` but we use the original
|
|
|
|
|
// instead of the precompile address for consistency
|
|
|
|
|
evm.CXReceipt = &types.CXReceipt{ |
|
|
|
|
From: fromAddress, |
|
|
|
|
To: &toAddress, |
|
|
|
|
ShardID: fromShardID, |
|
|
|
|
ToShardID: toShardID, |
|
|
|
|
Amount: value, |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return nil, errors.New("cannot call cross shard precompile again in same tx") |
|
|
|
|
} |
|
|
|
|
return nil, nil |
|
|
|
|
} |
|
|
|
|