remove rolloverchain; now it is just the chain of the first request
This commit is contained in:
parent
a1df44b3ee
commit
34a618d9f6
|
@ -36,7 +36,6 @@ contract CoreRelayer is CoreRelayerGovernance {
|
|||
error NoDeliveryInProcess();
|
||||
error CantRequestMultipleForwards();
|
||||
error RelayProviderDoesNotSupportTargetChain();
|
||||
error RolloverChainNotIncluded(); // Rollover chain was not included in the forwarding request
|
||||
error ChainNotFoundInSends(uint16 chainId); // Required chain not found in the delivery requests
|
||||
error ReentrantCall();
|
||||
error InvalidEmitterInOriginalDeliveryVM(uint8 index);
|
||||
|
@ -66,7 +65,7 @@ contract CoreRelayer is CoreRelayerGovernance {
|
|||
Send[] memory requests = new Send[](1);
|
||||
requests[0] = request;
|
||||
MultichainSend memory container = MultichainSend({relayProviderAddress: address(provider), requests: requests});
|
||||
return multichainForward(container, request.targetChain, nonce);
|
||||
return multichainForward(container, nonce);
|
||||
}
|
||||
|
||||
function resend(ResendByTx memory request, uint32 nonce, IRelayProvider provider)
|
||||
|
@ -191,10 +190,7 @@ contract CoreRelayer is CoreRelayerGovernance {
|
|||
* it checks that the passed nonce is not zero (VAAs with a nonce of zero will not be batched)
|
||||
* it generates a VAA with the encoded DeliveryInstructions
|
||||
*/
|
||||
function multichainForward(MultichainSend memory deliveryRequests, uint16 rolloverChain, uint32 nonce)
|
||||
public
|
||||
payable
|
||||
{
|
||||
function multichainForward(MultichainSend memory deliveryRequests, uint32 nonce) public payable {
|
||||
// Can only forward while a delivery is in process.
|
||||
if (!isContractLocked()) {
|
||||
revert NoDeliveryInProcess();
|
||||
|
@ -204,13 +200,12 @@ contract CoreRelayer is CoreRelayerGovernance {
|
|||
}
|
||||
|
||||
//We want to catch malformed requests in this function, and only underfunded requests when emitting.
|
||||
verifyForwardingRequest(deliveryRequests, rolloverChain, nonce);
|
||||
verifyForwardingRequest(deliveryRequests, nonce);
|
||||
|
||||
bytes memory encodedMultichainSend = encodeMultichainSend(deliveryRequests);
|
||||
setForwardingRequest(
|
||||
ForwardingRequest({
|
||||
deliveryRequestsContainer: encodedMultichainSend,
|
||||
rolloverChain: rolloverChain,
|
||||
nonce: nonce,
|
||||
msgValue: msg.value,
|
||||
sender: msg.sender,
|
||||
|
@ -234,18 +229,17 @@ contract CoreRelayer is CoreRelayerGovernance {
|
|||
//REVISE consider deducting the cost of this process from the refund amount?
|
||||
|
||||
if (funded) {
|
||||
//find the delivery instruction for the rollover chain
|
||||
uint16 rolloverInstructionIndex = findDeliveryIndex(container, forwardingRequest.rolloverChain);
|
||||
// the rollover chain is the chain in the first request
|
||||
|
||||
//calc how much budget is used by chains other than the rollover chain
|
||||
uint256 rolloverChainCostEstimate = container.requests[rolloverInstructionIndex].maxTransactionFee
|
||||
+ container.requests[rolloverInstructionIndex].receiverValue;
|
||||
uint256 rolloverChainCostEstimate =
|
||||
container.requests[0].maxTransactionFee + container.requests[0].receiverValue;
|
||||
//uint256 nonrolloverBudget = totalMinimumFees - rolloverChainCostEstimate; //stack too deep
|
||||
uint256 rolloverBudget = refundAmount - (totalMinimumFees - rolloverChainCostEstimate)
|
||||
- container.requests[rolloverInstructionIndex].receiverValue;
|
||||
uint256 rolloverBudget =
|
||||
refundAmount - (totalMinimumFees - rolloverChainCostEstimate) - container.requests[0].receiverValue;
|
||||
|
||||
//overwrite the gas budget on the rollover chain to the remaining budget amount
|
||||
container.requests[rolloverInstructionIndex].maxTransactionFee = rolloverBudget;
|
||||
container.requests[0].maxTransactionFee = rolloverBudget;
|
||||
}
|
||||
|
||||
//emit forwarding instruction
|
||||
|
@ -267,10 +261,7 @@ contract CoreRelayer is CoreRelayerGovernance {
|
|||
return (sequence, funded);
|
||||
}
|
||||
|
||||
function verifyForwardingRequest(MultichainSend memory container, uint16 rolloverChain, uint32 nonce)
|
||||
internal
|
||||
view
|
||||
{
|
||||
function verifyForwardingRequest(MultichainSend memory container, uint32 nonce) internal view {
|
||||
if (nonce == 0) {
|
||||
revert NonceIsZero();
|
||||
}
|
||||
|
@ -278,23 +269,6 @@ contract CoreRelayer is CoreRelayerGovernance {
|
|||
if (msg.sender != lockedTargetAddress()) {
|
||||
revert ForwardRequestFromWrongAddress();
|
||||
}
|
||||
|
||||
bool foundRolloverChain = false;
|
||||
IRelayProvider selectedProvider = IRelayProvider(container.relayProviderAddress);
|
||||
|
||||
for (uint16 i = 0; i < container.requests.length; i++) {
|
||||
// TODO: Optimization opportunity here by reducing multiple calls to only one with all requested addresses.
|
||||
if (selectedProvider.getDeliveryAddress(container.requests[i].targetChain) == 0) {
|
||||
revert RelayProviderDoesNotSupportTargetChain();
|
||||
}
|
||||
if (container.requests[i].targetChain == rolloverChain) {
|
||||
foundRolloverChain = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundRolloverChain) {
|
||||
revert RolloverChainNotIncluded();
|
||||
}
|
||||
}
|
||||
|
||||
function findDeliveryIndex(MultichainSend memory container, uint16 chainId)
|
||||
|
|
|
@ -118,7 +118,6 @@ abstract contract CoreRelayerStructs {
|
|||
|
||||
struct ForwardingRequest {
|
||||
bytes deliveryRequestsContainer;
|
||||
uint16 rolloverChain;
|
||||
uint32 nonce;
|
||||
address sender;
|
||||
uint256 msgValue;
|
||||
|
|
|
@ -263,13 +263,13 @@ interface IWormholeRelayer {
|
|||
* and let NEEDED_VALUE = (one wormhole message fee) + Sum_(i=0 -> requests.requests.length - 1) [requests.requests[i].maxTransactionFee + requests.requests[i].receiverValue].
|
||||
* The multichainForward will succeed if LEFTOVER_VALUE >= NEEDED_VALUE
|
||||
*
|
||||
* note: If LEFTOVER_VALUE > NEEDED_VALUE, then the maxTransactionFee of the first request in the array of sends will be incremented by 'LEFTOVER_VALUE - NEEDED_VALUE'
|
||||
*
|
||||
* @param requests The MultichainSend struct, containing the array of Send requests, as well as the desired relayProviderAddress
|
||||
* @param rolloverChain If LEFTOVER_VALUE > NEEDED_VALUE, then the maxTransactionFee of one of the requests in the array of sends will be incremented by 'LEFTOVER_VALUE - NEEDED_VALUE'
|
||||
* Specifically, the 'send' that will have it's maxTransactionFee incremented is the first send in the 'requests.requests' array that has targetChain equal to 'rolloverChain'
|
||||
* @param nonce The messages to be relayed are all of the emitted wormhole messages in the current transaction that have nonce 'nonce'
|
||||
*
|
||||
*/
|
||||
function multichainForward(MultichainSend memory requests, uint16 rolloverChain, uint32 nonce) external payable;
|
||||
function multichainForward(MultichainSend memory requests, uint32 nonce) external payable;
|
||||
|
||||
/**
|
||||
* @notice quoteGas tells you how much maxTransactionFee (denominated in current (source) chain currency) must be in order to fund a call to
|
||||
|
@ -362,7 +362,6 @@ interface IWormholeRelayer {
|
|||
error NoDeliveryInProcess(); // Forwards can only be requested within execution of 'receiveWormholeMessages', or when a delivery is in progress
|
||||
error MultipleForwardsRequested(); // Only one forward can be requested in a transaction
|
||||
error RelayProviderDoesNotSupportTargetChain(); // Your relay provider does not support the target chain you specified
|
||||
error RolloverChainNotIncluded(); // None of the Send structs in your multiForward are for the target chain 'rolloverChain'
|
||||
error ChainNotFoundInSends(uint16 chainId); // This should never happen. Post a Github Issue if this occurs
|
||||
error ReentrantCall(); // A delivery cannot occur during another delivery
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ contract MockRelayerIntegration is IWormholeReceiver {
|
|||
relayProviderAddress: relayer.getDefaultRelayProvider()
|
||||
});
|
||||
|
||||
relayer.multichainForward(container, sendRequests[0].targetChain, parsed.nonce);
|
||||
relayer.multichainForward(container, parsed.nonce);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue