ava-labs / teleporter-token-bridge

Token bridging cross-chain built on top of Teleporter
Other
10 stars 5 forks source link

Include sender identification in sendAndCall interface #99

Closed michaelkaplan13 closed 1 month ago

michaelkaplan13 commented 1 month ago

Thanks for the OpenZeppelin team for suggesting these improvements.

Context and scope The sendAndCall interface allows accounts to bridge tokens and atomically use them in smart contract invocations on the destination chain. The current interface for receiving the bridged tokens is defined by receiveTokens does not allow for the receiving contract to authenticate the original sender of the call.

This level of authentication would be needed to, for example, send a message using an 3rd party messaging protocol. In this type of example, a Subnet could send a message to Ethereum by bridging tokens to the C-Chain using sendAndCall, and then using those tokens to pay for the messaging fee to send the message payload from the C-Chain to Ethereum. The contract on Ethereum would very likely need to authenticate who originally sent the message on the Subnet for many applications.

For this reason, the sourceBlockchainID and the originSenderAddress should be included in the SingleHopCallMessage message type, and the originSenderAddress should be included in the MultiHopCallMessage message type. These values should be passed through to the receiving contracts via the receiveTokens interface.

Discussion and alternatives The multi-hop call case will need to be handled properly by identifying the original source/sender, and not the intermediate bridge contract. This roughly breaks down as follows:

Open Question What's the best way to encapsulate the sourceBlockchainID and originSenderAddress in the receiveTokens interface for both ERC20 and native token receivers? (i.e. wrapped in a struct or as individual params).