Skip to content

EVM Contract Callbacks #8335

Open
Open
@AdityaSripal

Description

@AdityaSripal

The callbacks middleware was designed to support arbitrary VMs, thus it should be able to support callbacks to EVM contracts by implementing a custom contract keeper that satisfies the interface expected by the callbacks middleware. Many of the usecases for EVM require that we can support contracts that are already deployed and thus do not need to change.

The callbacks middleware expects a field in the memo with the folllowing data:

// CallbackData is the callback data parsed from the packet.
type CallbackData struct {
	// CallbackAddress is the address of the callback actor.
	CallbackAddress string
	// ExecutionGasLimit is the gas limit which will be used for the callback execution.
	ExecutionGasLimit uint64
	// SenderAddress is the sender of the packet. This is passed to the contract keeper
	// to verify that the packet sender is the same as the callback address if desired.
	// This address is empty during destination callback execution.
	// This address may be empty if the sender is unknown or undefined.
	SenderAddress string
	// CommitGasLimit is the gas needed to commit the callback even if the callback
	// execution fails due to out of gas.
	// This parameter is only used in event emissions, or logging.
	CommitGasLimit uint64
	// ApplicationVersion is the base application version.
	ApplicationVersion string
}

Here there is no place to pass in the data needed for the contract directly. Thus, callbacks was originally designed to have its own unique endpoint on the contract that it could call and pass in the packet data.

Since this is no longer the desired case, we could add in a field that allows us to pass in the custom data to the contract. Then only this data gets passed into the EVM calldata. This will allow us to call any pre-deployed contract function with arbitrary data even if the contract is not aware at all about callbacks.

So one option is to make changes to the callbacks middleware to explicitly do this.

Another option is to allow the custom contract keeper to parse this information from the packet data. The contract keeper can still receive the exact same arguments, but it does not need to send the packet data to the contract. Instead it can parse the packet data to find the contract calldata and send it to the contract. The benefit of this approach is that it requires no changes to the ibc-go callbacks middleware, however it does require another top-level field in the json memo that can provide this additional information.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions