diff --git a/abis/0.8.23/OptimismMessenger.json b/abis/0.8.23/OptimismMessenger.json
index 4c727f8..39f99dc 100644
--- a/abis/0.8.23/OptimismMessenger.json
+++ b/abis/0.8.23/OptimismMessenger.json
@@ -12,7 +12,7 @@
},
{
"internalType": "address",
- "name": "_foreignGovernor",
+ "name": "_sourceGovernor",
"type": "address"
}
],
@@ -22,33 +22,12 @@
{
"inputs": [
{
- "internalType": "address",
- "name": "sender",
- "type": "address"
- },
- {
- "internalType": "address",
- "name": "CDMContractProxyHome",
- "type": "address"
+ "internalType": "bytes32",
+ "name": "deliveryHash",
+ "type": "bytes32"
}
],
- "name": "CDMContractProxyHomeOnly",
- "type": "error"
- },
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "sender",
- "type": "address"
- },
- {
- "internalType": "address",
- "name": "foreignGovernor",
- "type": "address"
- }
- ],
- "name": "ForeignGovernorOnly",
+ "name": "AlreadyDelivered",
"type": "error"
},
{
@@ -99,6 +78,38 @@
"name": "SelfCallOnly",
"type": "error"
},
+ {
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "sender",
+ "type": "address"
+ },
+ {
+ "internalType": "address",
+ "name": "sourceGovernor",
+ "type": "address"
+ }
+ ],
+ "name": "SourceGovernorOnly",
+ "type": "error"
+ },
+ {
+ "inputs": [
+ {
+ "internalType": "bytes32",
+ "name": "sender",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "sourceGovernor",
+ "type": "bytes32"
+ }
+ ],
+ "name": "SourceGovernorOnly32",
+ "type": "error"
+ },
{
"inputs": [
{
@@ -121,22 +132,46 @@
"type": "error"
},
{
- "inputs": [],
- "name": "ZeroAddress",
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "sender",
+ "type": "address"
+ },
+ {
+ "internalType": "address",
+ "name": "targetRelayer",
+ "type": "address"
+ }
+ ],
+ "name": "TargetRelayerOnly",
"type": "error"
},
{
- "anonymous": false,
"inputs": [
{
- "indexed": true,
- "internalType": "address",
- "name": "foreignMessageSender",
- "type": "address"
+ "internalType": "uint256",
+ "name": "received",
+ "type": "uint256"
+ },
+ {
+ "internalType": "uint256",
+ "name": "required",
+ "type": "uint256"
}
],
- "name": "ForeignGovernorUpdated",
- "type": "event"
+ "name": "WrongSourceChainId",
+ "type": "error"
+ },
+ {
+ "inputs": [],
+ "name": "ZeroAddress",
+ "type": "error"
+ },
+ {
+ "inputs": [],
+ "name": "ZeroValue",
+ "type": "error"
},
{
"anonymous": false,
@@ -163,7 +198,7 @@
{
"indexed": true,
"internalType": "address",
- "name": "foreignMessageSender",
+ "name": "sourceMessageSender",
"type": "address"
},
{
@@ -176,6 +211,19 @@
"name": "MessageReceived",
"type": "event"
},
+ {
+ "anonymous": false,
+ "inputs": [
+ {
+ "indexed": true,
+ "internalType": "address",
+ "name": "sourceGovernor",
+ "type": "address"
+ }
+ ],
+ "name": "SourceGovernorUpdated",
+ "type": "event"
+ },
{
"inputs": [],
"name": "CDMContractProxyHome",
@@ -206,28 +254,15 @@
"inputs": [
{
"internalType": "address",
- "name": "newForeignGovernor",
+ "name": "newSourceGovernor",
"type": "address"
}
],
- "name": "changeForeignGovernor",
+ "name": "changeSourceGovernor",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
- {
- "inputs": [],
- "name": "foreignGovernor",
- "outputs": [
- {
- "internalType": "address",
- "name": "",
- "type": "address"
- }
- ],
- "stateMutability": "view",
- "type": "function"
- },
{
"inputs": [
{
@@ -236,18 +271,31 @@
"type": "bytes"
}
],
- "name": "processMessageFromForeign",
+ "name": "processMessageFromSource",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
+ {
+ "inputs": [],
+ "name": "sourceGovernor",
+ "outputs": [
+ {
+ "internalType": "address",
+ "name": "",
+ "type": "address"
+ }
+ ],
+ "stateMutability": "view",
+ "type": "function"
+ },
{
"stateMutability": "payable",
"type": "receive"
}
],
- "bytecode": "0x60a060405234801561001057600080fd5b50604051610b85380380610b8583398101604081905261002f916100ae565b6001600160a01b038216158061004c57506001600160a01b038116155b1561006a5760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03918216608052600080546001600160a01b031916919092161790556100e1565b80516001600160a01b03811681146100a957600080fd5b919050565b600080604083850312156100c157600080fd5b6100ca83610092565b91506100d860208401610092565b90509250929050565b608051610a756101106000396000818160d30152818161029a0152818161030201526103780152610a756000f3fe60806040526004361061005e5760003560e01c8063cd9e30d911610043578063cd9e30d91461011f578063dd32a50614610132578063f02fb7741461015f57600080fd5b8063400a2c101461009f578063c8404330146100c157600080fd5b3661009a5760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100ab57600080fd5b506100bf6100ba3660046107a8565b610182565b005b3480156100cd57600080fd5b506100f57f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100bf61012d3660046107fb565b610282565b34801561013e57600080fd5b506000546100f59073ffffffffffffffffffffffffffffffffffffffff1681565b34801561016b57600080fd5b50610174602481565b604051908152602001610116565b3330146101c8576040517f0dbc9bfc0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8116610215576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917ff453e38063153897c0cb53422f7eb5eed0ee1866e8d47fd6b302acbe3b5d221d91a250565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161461032f576040517f9a63be9400000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044016101bf565b60008054604080517f6e296e45000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff92831693927f00000000000000000000000000000000000000000000000000000000000000001691636e296e45916004808301926020929190829003018187875af11580156103c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e891906108ca565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461046f576040517f33527f4900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152831660248201526044016101bf565b825160248110156104ba5783516040517f34c9027a0000000000000000000000000000000000000000000000000000000081526101bf91602491600401918252602082015260400190565b60005b8181101561072e57848101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff831661052c576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff16111561058a576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff831660048201524760248201526044016101bf565b60008163ffffffff1667ffffffffffffffff8111156105ab576105ab6107cc565b6040519080825280601f01601f1916602001820160405280156105d5576020820181803683370190505b50905060005b8263ffffffff1681101561065857896105f482886108e7565b8151811061060457610604610927565b602001015160f81c60f81b82828151811061062157610621610927565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506001016105db565b5061066963ffffffff8316866108e7565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516106a1919061097a565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b5050905080610724578484836040517f6cfc79a50000000000000000000000000000000000000000000000000000000081526004016101bf939291906109e0565b50505050506104bd565b508273ffffffffffffffffffffffffffffffffffffffff167f3c64b439784b3c09eba93acf868463aed0e339a92920e1d8822118261dfc1a7d856040516107759190610a2c565b60405180910390a250505050565b73ffffffffffffffffffffffffffffffffffffffff811681146107a557600080fd5b50565b6000602082840312156107ba57600080fd5b81356107c581610783565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561080d57600080fd5b813567ffffffffffffffff8082111561082557600080fd5b818401915084601f83011261083957600080fd5b81358181111561084b5761084b6107cc565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715610891576108916107cc565b816040528281528760208487010111156108aa57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000602082840312156108dc57600080fd5b81516107c581610783565b80820180821115610921577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60005b83811015610971578181015183820152602001610959565b50506000910152565b6000825161098c818460208701610956565b9190910192915050565b600081518084526109ae816020860160208601610956565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610a236060830184610996565b95945050505050565b6020815260006107c5602083018461099656fea2646970667358221220054f953390cc097af8de869f5684350175af171b5ae32d718e066aaea486c2d064736f6c63430008170033",
- "deployedBytecode": "0x60806040526004361061005e5760003560e01c8063cd9e30d911610043578063cd9e30d91461011f578063dd32a50614610132578063f02fb7741461015f57600080fd5b8063400a2c101461009f578063c8404330146100c157600080fd5b3661009a5760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100ab57600080fd5b506100bf6100ba3660046107a8565b610182565b005b3480156100cd57600080fd5b506100f57f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100bf61012d3660046107fb565b610282565b34801561013e57600080fd5b506000546100f59073ffffffffffffffffffffffffffffffffffffffff1681565b34801561016b57600080fd5b50610174602481565b604051908152602001610116565b3330146101c8576040517f0dbc9bfc0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8116610215576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917ff453e38063153897c0cb53422f7eb5eed0ee1866e8d47fd6b302acbe3b5d221d91a250565b3373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161461032f576040517f9a63be9400000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044016101bf565b60008054604080517f6e296e45000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff92831693927f00000000000000000000000000000000000000000000000000000000000000001691636e296e45916004808301926020929190829003018187875af11580156103c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e891906108ca565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461046f576040517f33527f4900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152831660248201526044016101bf565b825160248110156104ba5783516040517f34c9027a0000000000000000000000000000000000000000000000000000000081526101bf91602491600401918252602082015260400190565b60005b8181101561072e57848101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff831661052c576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff16111561058a576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff831660048201524760248201526044016101bf565b60008163ffffffff1667ffffffffffffffff8111156105ab576105ab6107cc565b6040519080825280601f01601f1916602001820160405280156105d5576020820181803683370190505b50905060005b8263ffffffff1681101561065857896105f482886108e7565b8151811061060457610604610927565b602001015160f81c60f81b82828151811061062157610621610927565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506001016105db565b5061066963ffffffff8316866108e7565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516106a1919061097a565b60006040518083038185875af1925050503d80600081146106de576040519150601f19603f3d011682016040523d82523d6000602084013e6106e3565b606091505b5050905080610724578484836040517f6cfc79a50000000000000000000000000000000000000000000000000000000081526004016101bf939291906109e0565b50505050506104bd565b508273ffffffffffffffffffffffffffffffffffffffff167f3c64b439784b3c09eba93acf868463aed0e339a92920e1d8822118261dfc1a7d856040516107759190610a2c565b60405180910390a250505050565b73ffffffffffffffffffffffffffffffffffffffff811681146107a557600080fd5b50565b6000602082840312156107ba57600080fd5b81356107c581610783565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561080d57600080fd5b813567ffffffffffffffff8082111561082557600080fd5b818401915084601f83011261083957600080fd5b81358181111561084b5761084b6107cc565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908382118183101715610891576108916107cc565b816040528281528760208487010111156108aa57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000602082840312156108dc57600080fd5b81516107c581610783565b80820180821115610921577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60005b83811015610971578181015183820152602001610959565b50506000910152565b6000825161098c818460208701610956565b9190910192915050565b600081518084526109ae816020860160208601610956565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610a236060830184610996565b95945050505050565b6020815260006107c5602083018461099656fea2646970667358221220054f953390cc097af8de869f5684350175af171b5ae32d718e066aaea486c2d064736f6c63430008170033",
+ "bytecode": "0x60a060405234801561001057600080fd5b50604051610b91380380610b9183398101604081905261002f916100ae565b6001600160a01b038216158061004c57506001600160a01b038116155b1561006a5760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03918216608052600080546001600160a01b031916919092161790556100e1565b80516001600160a01b03811681146100a957600080fd5b919050565b600080604083850312156100c157600080fd5b6100ca83610092565b91506100d860208401610092565b90509250929050565b608051610a816101106000396000818160b10152818161019a01528181610202015261027d0152610a816000f3fe60806040526004361061005e5760003560e01c8063e3b94a2311610043578063e3b94a2314610112578063f02fb7741461013f578063f8b4870f1461016257600080fd5b8063c84043301461009f578063d3042d2b146100fd57600080fd5b3661009a5760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100ab57600080fd5b506100d37f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61011061010b3660046107be565b610182565b005b34801561011e57600080fd5b506000546100d39073ffffffffffffffffffffffffffffffffffffffff1681565b34801561014b57600080fd5b50610154602481565b6040519081526020016100f4565b34801561016e57600080fd5b5061011061017d3660046108b2565b6103d0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610234576040517f2f3111fa00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b60008054604080517f6e296e45000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff92831693927f00000000000000000000000000000000000000000000000000000000000000001691636e296e45916004808301926020929190829003018187875af11580156102c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ed91906108d6565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610374576040517f978c830c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528316602482015260440161022b565b61037d836104cb565b8173ffffffffffffffffffffffffffffffffffffffff167f3c64b439784b3c09eba93acf868463aed0e339a92920e1d8822118261dfc1a7d846040516103c39190610961565b60405180910390a2505050565b333014610411576040517f0dbc9bfc00000000000000000000000000000000000000000000000000000000815233600482015230602482015260440161022b565b73ffffffffffffffffffffffffffffffffffffffff811661045e576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917fbbc9d5867fd60faf098cfaa8adb3402dd83501cc76385968ddbb6b2610800f8e91a250565b805160248110156105165781516040517f34c9027a00000000000000000000000000000000000000000000000000000000815261022b91602491600401918252602082015260400190565b60005b8181101561078a57828101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff8316610588576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff1611156105e6576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff8316600482015247602482015260440161022b565b60008163ffffffff1667ffffffffffffffff8111156106075761060761078f565b6040519080825280601f01601f191660200182016040528015610631576020820181803683370190505b50905060005b8263ffffffff168110156106b457876106508288610974565b81518110610660576106606109b4565b602001015160f81c60f81b82828151811061067d5761067d6109b4565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101610637565b506106c563ffffffff831686610974565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516106fd91906109e3565b60006040518083038185875af1925050503d806000811461073a576040519150601f19603f3d011682016040523d82523d6000602084013e61073f565b606091505b5050905080610780578484836040517f6cfc79a500000000000000000000000000000000000000000000000000000000815260040161022b939291906109ff565b5050505050610519565b505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000602082840312156107d057600080fd5b813567ffffffffffffffff808211156107e857600080fd5b818401915084601f8301126107fc57600080fd5b81358181111561080e5761080e61078f565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156108545761085461078f565b8160405282815287602084870101111561086d57600080fd5b826020860160208301376000928101602001929092525095945050505050565b73ffffffffffffffffffffffffffffffffffffffff811681146108af57600080fd5b50565b6000602082840312156108c457600080fd5b81356108cf8161088d565b9392505050565b6000602082840312156108e857600080fd5b81516108cf8161088d565b60005b8381101561090e5781810151838201526020016108f6565b50506000910152565b6000815180845261092f8160208601602086016108f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006108cf6020830184610917565b808201808211156109ae577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082516109f58184602087016108f3565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610a426060830184610917565b9594505050505056fea2646970667358221220c8855bb8d138c809e71ccdac5baac500ad3deb2f38b2e82fe5572138dc23d8d064736f6c63430008170033",
+ "deployedBytecode": "0x60806040526004361061005e5760003560e01c8063e3b94a2311610043578063e3b94a2314610112578063f02fb7741461013f578063f8b4870f1461016257600080fd5b8063c84043301461009f578063d3042d2b146100fd57600080fd5b3661009a5760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100ab57600080fd5b506100d37f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61011061010b3660046107be565b610182565b005b34801561011e57600080fd5b506000546100d39073ffffffffffffffffffffffffffffffffffffffff1681565b34801561014b57600080fd5b50610154602481565b6040519081526020016100f4565b34801561016e57600080fd5b5061011061017d3660046108b2565b6103d0565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610234576040517f2f3111fa00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b60008054604080517f6e296e45000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff92831693927f00000000000000000000000000000000000000000000000000000000000000001691636e296e45916004808301926020929190829003018187875af11580156102c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ed91906108d6565b90508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610374576040517f978c830c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528316602482015260440161022b565b61037d836104cb565b8173ffffffffffffffffffffffffffffffffffffffff167f3c64b439784b3c09eba93acf868463aed0e339a92920e1d8822118261dfc1a7d846040516103c39190610961565b60405180910390a2505050565b333014610411576040517f0dbc9bfc00000000000000000000000000000000000000000000000000000000815233600482015230602482015260440161022b565b73ffffffffffffffffffffffffffffffffffffffff811661045e576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917fbbc9d5867fd60faf098cfaa8adb3402dd83501cc76385968ddbb6b2610800f8e91a250565b805160248110156105165781516040517f34c9027a00000000000000000000000000000000000000000000000000000000815261022b91602491600401918252602082015260400190565b60005b8181101561078a57828101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff8316610588576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff1611156105e6576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff8316600482015247602482015260440161022b565b60008163ffffffff1667ffffffffffffffff8111156106075761060761078f565b6040519080825280601f01601f191660200182016040528015610631576020820181803683370190505b50905060005b8263ffffffff168110156106b457876106508288610974565b81518110610660576106606109b4565b602001015160f81c60f81b82828151811061067d5761067d6109b4565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101610637565b506106c563ffffffff831686610974565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516106fd91906109e3565b60006040518083038185875af1925050503d806000811461073a576040519150601f19603f3d011682016040523d82523d6000602084013e61073f565b606091505b5050905080610780578484836040517f6cfc79a500000000000000000000000000000000000000000000000000000000815260040161022b939291906109ff565b5050505050610519565b505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000602082840312156107d057600080fd5b813567ffffffffffffffff808211156107e857600080fd5b818401915084601f8301126107fc57600080fd5b81358181111561080e5761080e61078f565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156108545761085461078f565b8160405282815287602084870101111561086d57600080fd5b826020860160208301376000928101602001929092525095945050505050565b73ffffffffffffffffffffffffffffffffffffffff811681146108af57600080fd5b50565b6000602082840312156108c457600080fd5b81356108cf8161088d565b9392505050565b6000602082840312156108e857600080fd5b81516108cf8161088d565b60005b8381101561090e5781810151838201526020016108f6565b50506000910152565b6000815180845261092f8160208601602086016108f3565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006108cf6020830184610917565b808201808211156109ae577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082516109f58184602087016108f3565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610a426060830184610917565b9594505050505056fea2646970667358221220c8855bb8d138c809e71ccdac5baac500ad3deb2f38b2e82fe5572138dc23d8d064736f6c63430008170033",
"linkReferences": {},
"deployedLinkReferences": {}
}
diff --git a/abis/0.8.23/WormholeMessenger.json b/abis/0.8.23/WormholeMessenger.json
index 8cc816a..a7a2c25 100644
--- a/abis/0.8.23/WormholeMessenger.json
+++ b/abis/0.8.23/WormholeMessenger.json
@@ -11,9 +11,9 @@
"type": "address"
},
{
- "internalType": "address",
+ "internalType": "bytes32",
"name": "_sourceGovernor",
- "type": "address"
+ "type": "bytes32"
},
{
"internalType": "uint16",
@@ -99,6 +99,22 @@
"name": "SourceGovernorOnly",
"type": "error"
},
+ {
+ "inputs": [
+ {
+ "internalType": "bytes32",
+ "name": "sender",
+ "type": "bytes32"
+ },
+ {
+ "internalType": "bytes32",
+ "name": "sourceGovernor",
+ "type": "bytes32"
+ }
+ ],
+ "name": "SourceGovernorOnly32",
+ "type": "error"
+ },
{
"inputs": [
{
@@ -120,6 +136,22 @@
"name": "TargetExecFailed",
"type": "error"
},
+ {
+ "inputs": [
+ {
+ "internalType": "address",
+ "name": "sender",
+ "type": "address"
+ },
+ {
+ "internalType": "address",
+ "name": "targetRelayer",
+ "type": "address"
+ }
+ ],
+ "name": "TargetRelayerOnly",
+ "type": "error"
+ },
{
"inputs": [
{
@@ -146,22 +178,6 @@
"name": "ZeroValue",
"type": "error"
},
- {
- "inputs": [
- {
- "internalType": "address",
- "name": "sender",
- "type": "address"
- },
- {
- "internalType": "address",
- "name": "wormholeRelayer",
- "type": "address"
- }
- ],
- "name": "wormholeRelayerOnly",
- "type": "error"
- },
{
"anonymous": false,
"inputs": [
@@ -186,9 +202,9 @@
"inputs": [
{
"indexed": true,
- "internalType": "address",
+ "internalType": "bytes32",
"name": "sourceMessageSender",
- "type": "address"
+ "type": "bytes32"
},
{
"indexed": false,
@@ -217,9 +233,9 @@
"inputs": [
{
"indexed": true,
- "internalType": "address",
- "name": "sourceMessageSender",
- "type": "address"
+ "internalType": "bytes32",
+ "name": "sourceGovernor",
+ "type": "bytes32"
}
],
"name": "SourceGovernorUpdated",
@@ -241,9 +257,9 @@
{
"inputs": [
{
- "internalType": "address",
+ "internalType": "bytes32",
"name": "newSourceGovernor",
- "type": "address"
+ "type": "bytes32"
}
],
"name": "changeSourceGovernor",
@@ -308,9 +324,9 @@
"name": "sourceGovernor",
"outputs": [
{
- "internalType": "address",
+ "internalType": "bytes32",
"name": "",
- "type": "address"
+ "type": "bytes32"
}
],
"stateMutability": "view",
@@ -347,8 +363,8 @@
"type": "receive"
}
],
- "bytecode": "0x60c060405234801561001057600080fd5b50604051610e0c380380610e0c83398101604081905261002f916100de565b6001600160a01b038316158061004c57506001600160a01b038216155b1561006a5760405163d92e233d60e01b815260040160405180910390fd5b8061ffff1660000361008f57604051637c946ed760e01b815260040160405180910390fd5b6001600160a01b03928316608052600080546001600160a01b031916929093169190911790915561ffff1660a05261012c565b80516001600160a01b03811681146100d957600080fd5b919050565b6000806000606084860312156100f357600080fd5b6100fc846100c2565b925061010a602085016100c2565b9150604084015161ffff8116811461012157600080fd5b809150509250925092565b60805160a051610c9f61016d6000396000818161010c015281816102d3015261033301526000818161016801528181610237015261029f0152610c9f6000f3fe6080604052600436106100745760003560e01c8063da25b7251161004e578063da25b72514610156578063e3b94a23146101af578063f02fb774146101dc578063f8b4870f146101ff57600080fd5b8063446a9695146100b557806347059760146100fa578063529dca321461014157600080fd5b366100b05760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100c157600080fd5b506100e56100d0366004610875565b60016020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b34801561010657600080fd5b5061012e7f000000000000000000000000000000000000000000000000000000000000000081565b60405161ffff90911681526020016100f1565b61015461014f3660046109b1565b61021f565b005b34801561016257600080fd5b5061018a7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f1565b3480156101bb57600080fd5b5060005461018a9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156101e857600080fd5b506101f1602481565b6040519081526020016100f1565b34801561020b57600080fd5b5061015461021a366004610aba565b61077a565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102d1576040517ffb8d9f7600000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000061ffff168261ffff1614610360576040517fab1e308b00000000000000000000000000000000000000000000000000000000815261ffff80841660048301527f00000000000000000000000000000000000000000000000000000000000000001660248201526044016102c8565b60005473ffffffffffffffffffffffffffffffffffffffff908116908490811682146103d8576040517f978c830c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152831660248201526044016102c8565b60008381526001602052604090205460ff1615610424576040517f56bc34a1000000000000000000000000000000000000000000000000000000008152600481018490526024016102c8565b600083815260016020819052604090912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169091179055865160248110156104a95787516040517f34c9027a0000000000000000000000000000000000000000000000000000000081526102c891602491600401918252602082015260400190565b60005b8181101561071d57888101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff831661051b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff161115610579576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff831660048201524760248201526044016102c8565b60008163ffffffff1667ffffffffffffffff81111561059a5761059a61088e565b6040519080825280601f01601f1916602001820160405280156105c4576020820181803683370190505b50905060005b8263ffffffff16811015610647578d6105e38288610af7565b815181106105f3576105f3610b37565b602001015160f81c60f81b82828151811061061057610610610b37565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506001016105ca565b5061065863ffffffff831686610af7565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516106909190610b8a565b60006040518083038185875af1925050503d80600081146106cd576040519150601f19603f3d011682016040523d82523d6000602084013e6106d2565b606091505b5050905080610713578484836040517f6cfc79a50000000000000000000000000000000000000000000000000000000081526004016102c893929190610bf0565b50505050506104ac565b508273ffffffffffffffffffffffffffffffffffffffff167f538b8a300f32521e3c4b1bc21b3bc8bbc5752f33e4186f78ed3a359aa905adec89868860405161076893929190610c3c565b60405180910390a25050505050505050565b3330146107bb576040517f0dbc9bfc0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044016102c8565b73ffffffffffffffffffffffffffffffffffffffff8116610808576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917fbbc9d5867fd60faf098cfaa8adb3402dd83501cc76385968ddbb6b2610800f8e91a250565b60006020828403121561088757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156109045761090461088e565b604052919050565b600082601f83011261091d57600080fd5b813567ffffffffffffffff8111156109375761093761088e565b61096860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016108bd565b81815284602083860101111561097d57600080fd5b816020850160208301376000918101602001919091529392505050565b803561ffff811681146109ac57600080fd5b919050565b600080600080600060a086880312156109c957600080fd5b853567ffffffffffffffff808211156109e157600080fd5b6109ed89838a0161090c565b9650602091508188013581811115610a0457600080fd5b8801601f81018a13610a1557600080fd5b803582811115610a2757610a2761088e565b8060051b610a368582016108bd565b918252828101850191858101908d841115610a5057600080fd5b86850192505b83831015610a8c57823586811115610a6e5760008081fd5b610a7c8f898389010161090c565b8352509186019190860190610a56565b809a505050505050505060408601359250610aa96060870161099a565b949793965091946080013592915050565b600060208284031215610acc57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610af057600080fd5b9392505050565b80820180821115610b31577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60005b83811015610b81578181015183820152602001610b69565b50506000910152565b60008251610b9c818460208701610b66565b9190910192915050565b60008151808452610bbe816020860160208601610b66565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610c336060830184610ba6565b95945050505050565b606081526000610c4f6060830186610ba6565b905083602083015261ffff8316604083015294935050505056fea2646970667358221220174e1300e4e7fd65e944fe54a874430ebed7ab5db9cfbf2b958133ca6f24796b64736f6c63430008170033",
- "deployedBytecode": "0x6080604052600436106100745760003560e01c8063da25b7251161004e578063da25b72514610156578063e3b94a23146101af578063f02fb774146101dc578063f8b4870f146101ff57600080fd5b8063446a9695146100b557806347059760146100fa578063529dca321461014157600080fd5b366100b05760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100c157600080fd5b506100e56100d0366004610875565b60016020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b34801561010657600080fd5b5061012e7f000000000000000000000000000000000000000000000000000000000000000081565b60405161ffff90911681526020016100f1565b61015461014f3660046109b1565b61021f565b005b34801561016257600080fd5b5061018a7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f1565b3480156101bb57600080fd5b5060005461018a9073ffffffffffffffffffffffffffffffffffffffff1681565b3480156101e857600080fd5b506101f1602481565b6040519081526020016100f1565b34801561020b57600080fd5b5061015461021a366004610aba565b61077a565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102d1576040517ffb8d9f7600000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000061ffff168261ffff1614610360576040517fab1e308b00000000000000000000000000000000000000000000000000000000815261ffff80841660048301527f00000000000000000000000000000000000000000000000000000000000000001660248201526044016102c8565b60005473ffffffffffffffffffffffffffffffffffffffff908116908490811682146103d8576040517f978c830c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152831660248201526044016102c8565b60008381526001602052604090205460ff1615610424576040517f56bc34a1000000000000000000000000000000000000000000000000000000008152600481018490526024016102c8565b600083815260016020819052604090912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169091179055865160248110156104a95787516040517f34c9027a0000000000000000000000000000000000000000000000000000000081526102c891602491600401918252602082015260400190565b60005b8181101561071d57888101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff831661051b576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff161115610579576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff831660048201524760248201526044016102c8565b60008163ffffffff1667ffffffffffffffff81111561059a5761059a61088e565b6040519080825280601f01601f1916602001820160405280156105c4576020820181803683370190505b50905060005b8263ffffffff16811015610647578d6105e38288610af7565b815181106105f3576105f3610b37565b602001015160f81c60f81b82828151811061061057610610610b37565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506001016105ca565b5061065863ffffffff831686610af7565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516106909190610b8a565b60006040518083038185875af1925050503d80600081146106cd576040519150601f19603f3d011682016040523d82523d6000602084013e6106d2565b606091505b5050905080610713578484836040517f6cfc79a50000000000000000000000000000000000000000000000000000000081526004016102c893929190610bf0565b50505050506104ac565b508273ffffffffffffffffffffffffffffffffffffffff167f538b8a300f32521e3c4b1bc21b3bc8bbc5752f33e4186f78ed3a359aa905adec89868860405161076893929190610c3c565b60405180910390a25050505050505050565b3330146107bb576040517f0dbc9bfc0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044016102c8565b73ffffffffffffffffffffffffffffffffffffffff8116610808576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316908117825560405190917fbbc9d5867fd60faf098cfaa8adb3402dd83501cc76385968ddbb6b2610800f8e91a250565b60006020828403121561088757600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156109045761090461088e565b604052919050565b600082601f83011261091d57600080fd5b813567ffffffffffffffff8111156109375761093761088e565b61096860207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016108bd565b81815284602083860101111561097d57600080fd5b816020850160208301376000918101602001919091529392505050565b803561ffff811681146109ac57600080fd5b919050565b600080600080600060a086880312156109c957600080fd5b853567ffffffffffffffff808211156109e157600080fd5b6109ed89838a0161090c565b9650602091508188013581811115610a0457600080fd5b8801601f81018a13610a1557600080fd5b803582811115610a2757610a2761088e565b8060051b610a368582016108bd565b918252828101850191858101908d841115610a5057600080fd5b86850192505b83831015610a8c57823586811115610a6e5760008081fd5b610a7c8f898389010161090c565b8352509186019190860190610a56565b809a505050505050505060408601359250610aa96060870161099a565b949793965091946080013592915050565b600060208284031215610acc57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610af057600080fd5b9392505050565b80820180821115610b31577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60005b83811015610b81578181015183820152602001610b69565b50506000910152565b60008251610b9c818460208701610b66565b9190910192915050565b60008151808452610bbe816020860160208601610b66565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610c336060830184610ba6565b95945050505050565b606081526000610c4f6060830186610ba6565b905083602083015261ffff8316604083015294935050505056fea2646970667358221220174e1300e4e7fd65e944fe54a874430ebed7ab5db9cfbf2b958133ca6f24796b64736f6c63430008170033",
+ "bytecode": "0x60c060405234801561001057600080fd5b50604051610cf6380380610cf683398101604081905261002f916100a0565b6001600160a01b0383166100565760405163d92e233d60e01b815260040160405180910390fd5b811580610065575061ffff8116155b1561008357604051637c946ed760e01b815260040160405180910390fd5b6001600160a01b0390921660805260005561ffff1660a0526100f6565b6000806000606084860312156100b557600080fd5b83516001600160a01b03811681146100cc57600080fd5b60208501516040860151919450925061ffff811681146100eb57600080fd5b809150509250925092565b60805160a051610bbf6101376000396000818161010c015281816102bc015261031c0152600081816101680152818161022001526102880152610bbf6000f3fe6080604052600436106100745760003560e01c8063da25b7251161004e578063da25b72514610156578063e3b94a23146101af578063f02fb774146101d3578063fb9a487e146101e857600080fd5b8063446a9695146100b557806347059760146100fa578063529dca321461014157600080fd5b366100b05760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100c157600080fd5b506100e56100d03660046107d2565b60016020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b34801561010657600080fd5b5061012e7f000000000000000000000000000000000000000000000000000000000000000081565b60405161ffff90911681526020016100f1565b61015461014f36600461090e565b610208565b005b34801561016257600080fd5b5061018a7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f1565b3480156101bb57600080fd5b506101c560005481565b6040519081526020016100f1565b3480156101df57600080fd5b506101c5602481565b3480156101f457600080fd5b506101546102033660046107d2565b610462565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102ba576040517f2f3111fa00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000061ffff168261ffff1614610349576040517fab1e308b00000000000000000000000000000000000000000000000000000000815261ffff80841660048301527f00000000000000000000000000000000000000000000000000000000000000001660248201526044016102b1565b60005483811461038f576040517fe4e8887200000000000000000000000000000000000000000000000000000000815260048101859052602481018290526044016102b1565b60008281526001602052604090205460ff16156103db576040517f56bc34a1000000000000000000000000000000000000000000000000000000008152600481018390526024016102b1565b600082815260016020819052604090912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909117905561041e8661050e565b807fd8cd153bfe87c1532b57496df668459b04cf5517c686a785817278fae362daac87848660405161045293929190610a85565b60405180910390a2505050505050565b3330146104a3576040517f0dbc9bfc0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044016102b1565b60008190036104de576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081815560405182917f5a44f84b9c7ddf51c2fc1ff0026700203679762f67a7425804d9d9801d8d61e691a250565b805160248110156105595781516040517f34c9027a0000000000000000000000000000000000000000000000000000000081526102b191602491600401918252602082015260400190565b60005b818110156107cd57828101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff83166105cb576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff161115610629576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff831660048201524760248201526044016102b1565b60008163ffffffff1667ffffffffffffffff81111561064a5761064a6107eb565b6040519080825280601f01601f191660200182016040528015610674576020820181803683370190505b50905060005b8263ffffffff168110156106f757876106938288610ab2565b815181106106a3576106a3610af2565b602001015160f81c60f81b8282815181106106c0576106c0610af2565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060010161067a565b5061070863ffffffff831686610ab2565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516107409190610b21565b60006040518083038185875af1925050503d806000811461077d576040519150601f19603f3d011682016040523d82523d6000602084013e610782565b606091505b50509050806107c3578484836040517f6cfc79a50000000000000000000000000000000000000000000000000000000081526004016102b193929190610b3d565b505050505061055c565b505050565b6000602082840312156107e457600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610861576108616107eb565b604052919050565b600082601f83011261087a57600080fd5b813567ffffffffffffffff811115610894576108946107eb565b6108c560207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160161081a565b8181528460208386010111156108da57600080fd5b816020850160208301376000918101602001919091529392505050565b803561ffff8116811461090957600080fd5b919050565b600080600080600060a0868803121561092657600080fd5b853567ffffffffffffffff8082111561093e57600080fd5b61094a89838a01610869565b965060209150818801358181111561096157600080fd5b8801601f81018a1361097257600080fd5b803582811115610984576109846107eb565b8060051b61099385820161081a565b918252828101850191858101908d8411156109ad57600080fd5b86850192505b838310156109e9578235868111156109cb5760008081fd5b6109d98f8983890101610869565b83525091860191908601906109b3565b809a505050505050505060408601359250610a06606087016108f7565b949793965091946080013592915050565b60005b83811015610a32578181015183820152602001610a1a565b50506000910152565b60008151808452610a53816020860160208601610a17565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b606081526000610a986060830186610a3b565b905083602083015261ffff83166040830152949350505050565b80820180821115610aec577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008251610b33818460208701610a17565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610b806060830184610a3b565b9594505050505056fea26469706673582212204db311bcff4340e7ff2b45c2409038e5602e521f704ea4b4fc66aa64f9a069c664736f6c63430008170033",
+ "deployedBytecode": "0x6080604052600436106100745760003560e01c8063da25b7251161004e578063da25b72514610156578063e3b94a23146101af578063f02fb774146101d3578063fb9a487e146101e857600080fd5b8063446a9695146100b557806347059760146100fa578063529dca321461014157600080fd5b366100b05760405134815233907f8e47b87b0ef542cdfa1659c551d88bad38aa7f452d2bbb349ab7530dfec8be8f9060200160405180910390a2005b600080fd5b3480156100c157600080fd5b506100e56100d03660046107d2565b60016020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b34801561010657600080fd5b5061012e7f000000000000000000000000000000000000000000000000000000000000000081565b60405161ffff90911681526020016100f1565b61015461014f36600461090e565b610208565b005b34801561016257600080fd5b5061018a7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f1565b3480156101bb57600080fd5b506101c560005481565b6040519081526020016100f1565b3480156101df57600080fd5b506101c5602481565b3480156101f457600080fd5b506101546102033660046107d2565b610462565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146102ba576040517f2f3111fa00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000061ffff168261ffff1614610349576040517fab1e308b00000000000000000000000000000000000000000000000000000000815261ffff80841660048301527f00000000000000000000000000000000000000000000000000000000000000001660248201526044016102b1565b60005483811461038f576040517fe4e8887200000000000000000000000000000000000000000000000000000000815260048101859052602481018290526044016102b1565b60008281526001602052604090205460ff16156103db576040517f56bc34a1000000000000000000000000000000000000000000000000000000008152600481018390526024016102b1565b600082815260016020819052604090912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909117905561041e8661050e565b807fd8cd153bfe87c1532b57496df668459b04cf5517c686a785817278fae362daac87848660405161045293929190610a85565b60405180910390a2505050505050565b3330146104a3576040517f0dbc9bfc0000000000000000000000000000000000000000000000000000000081523360048201523060248201526044016102b1565b60008190036104de576040517f7c946ed700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600081815560405182917f5a44f84b9c7ddf51c2fc1ff0026700203679762f67a7425804d9d9801d8d61e691a250565b805160248110156105595781516040517f34c9027a0000000000000000000000000000000000000000000000000000000081526102b191602491600401918252602082015260400190565b60005b818110156107cd57828101601481015160208201516024928301519290930192909173ffffffffffffffffffffffffffffffffffffffff83166105cb576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b47826bffffffffffffffffffffffff161115610629576040517fcf4791810000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff831660048201524760248201526044016102b1565b60008163ffffffff1667ffffffffffffffff81111561064a5761064a6107eb565b6040519080825280601f01601f191660200182016040528015610674576020820181803683370190505b50905060005b8263ffffffff168110156106f757876106938288610ab2565b815181106106a3576106a3610af2565b602001015160f81c60f81b8282815181106106c0576106c0610af2565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060010161067a565b5061070863ffffffff831686610ab2565b945060008473ffffffffffffffffffffffffffffffffffffffff16846bffffffffffffffffffffffff16836040516107409190610b21565b60006040518083038185875af1925050503d806000811461077d576040519150601f19603f3d011682016040523d82523d6000602084013e610782565b606091505b50509050806107c3578484836040517f6cfc79a50000000000000000000000000000000000000000000000000000000081526004016102b193929190610b3d565b505050505061055c565b505050565b6000602082840312156107e457600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715610861576108616107eb565b604052919050565b600082601f83011261087a57600080fd5b813567ffffffffffffffff811115610894576108946107eb565b6108c560207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160161081a565b8181528460208386010111156108da57600080fd5b816020850160208301376000918101602001919091529392505050565b803561ffff8116811461090957600080fd5b919050565b600080600080600060a0868803121561092657600080fd5b853567ffffffffffffffff8082111561093e57600080fd5b61094a89838a01610869565b965060209150818801358181111561096157600080fd5b8801601f81018a1361097257600080fd5b803582811115610984576109846107eb565b8060051b61099385820161081a565b918252828101850191858101908d8411156109ad57600080fd5b86850192505b838310156109e9578235868111156109cb5760008081fd5b6109d98f8983890101610869565b83525091860191908601906109b3565b809a505050505050505060408601359250610a06606087016108f7565b949793965091946080013592915050565b60005b83811015610a32578181015183820152602001610a1a565b50506000910152565b60008151808452610a53816020860160208601610a17565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b606081526000610a986060830186610a3b565b905083602083015261ffff83166040830152949350505050565b80820180821115610aec577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008251610b33818460208701610a17565b9190910192915050565b73ffffffffffffffffffffffffffffffffffffffff841681526bffffffffffffffffffffffff83166020820152606060408201526000610b806060830184610a3b565b9594505050505056fea26469706673582212204db311bcff4340e7ff2b45c2409038e5602e521f704ea4b4fc66aa64f9a069c664736f6c63430008170033",
"linkReferences": {},
"deployedLinkReferences": {}
}
diff --git a/audits/internal9/README.md b/audits/internal9/README.md
index 6c65e94..ad8e4e0 100644
--- a/audits/internal9/README.md
+++ b/audits/internal9/README.md
@@ -20,6 +20,7 @@ File | % Stmts | % Branch | % Funcs | % Lines |Uncovere
WormholeMessenger.sol | 0 | 0 | 0 | 0 |... 201,202,207 |
```
Pay attention, please! No tests for contract on scope.
+[x] Fixed
#### Wormhole security list
https://docs.wormhole.com/wormhole/quick-start/cross-chain-dev/standard-relayer#other-considerations
@@ -35,6 +36,7 @@ Refunding overpayment of gasLimit - [?] - requires discussion
Refunding overpayment of value sent - [?] - requires discussion
ref: https://github.com/wormhole-foundation/hello-wormhole/blob/main/src/extensions/HelloWormholeRefunds.sol
```
+[x] Good point, need to set up these parameters and call the corresponding function on the L1 Relayer (added to test scripts)
### Security issues
Details in [slither_full](https://github.com/valory-xyz/autonolas-governance/blob/main/audits/internal9/analysis/slither_full.txt)
@@ -56,6 +58,8 @@ so avoid casting bytes32 to address EVM.
}
ref: https://github.com/wormhole-foundation/wormhole-solidity-sdk/blob/main/src/Base.sol#L30C52-L30C74 SDK of Wormhole
```
+[x] Fixed
+
##### Re-design contracts
Part of the code is common and has the nature of a repeatable pattern for all contracts.
It makes sense to separate it into a separate contract and replace magic numbers (20,12,4) with constants.
@@ -109,6 +113,7 @@ It makes sense to separate it into a separate contract and replace magic numbers
}
}
```
+[x] Fixed
diff --git a/contracts/bridges/BridgeMessenger.sol b/contracts/bridges/BridgeMessenger.sol
new file mode 100644
index 0000000..f6578d7
--- /dev/null
+++ b/contracts/bridges/BridgeMessenger.sol
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: MIT
+pragma solidity ^0.8.23;
+
+import {IBridgeErrors} from "../interfaces/IBridgeErrors.sol";
+
+/// @title BridgeMessenger - Abstract smart contract for the bridge communication data processing
+/// @author Aleksandr Kuperman -
+/// @author Andrey Lebedev -
+/// @author Mariapia Moscatiello -
+abstract contract BridgeMessenger is IBridgeErrors {
+ event FundsReceived(address indexed sender, uint256 value);
+
+ // Default payload data length includes the number of bytes of at least one address (20 bytes or 160 bits),
+ // value (12 bytes or 96 bits) and the payload size (4 bytes or 32 bits)
+ uint256 public constant DEFAULT_DATA_LENGTH = 36;
+
+ /// @dev Receives native network token.
+ receive() external payable {
+ emit FundsReceived(msg.sender, msg.value);
+ }
+
+ /// @dev Processes received data.
+ /// @param data Bytes message sent from L2 Relayer contract. The data must be encoded as a set of
+ /// continuous transactions packed into a single buffer, where each transaction is composed as follows:
+ /// - target address of 20 bytes (160 bits);
+ /// - value of 12 bytes (96 bits), as a limit for all of Autonolas ecosystem contracts;
+ /// - payload length of 4 bytes (32 bits), as 2^32 - 1 characters is more than enough to fill a whole block;
+ /// - payload as bytes, with the length equal to the specified payload length.
+ function _processData(bytes memory data) internal virtual {
+ // Check for the correct data length
+ uint256 dataLength = data.length;
+ if (dataLength < DEFAULT_DATA_LENGTH) {
+ revert IncorrectDataLength(DEFAULT_DATA_LENGTH, data.length);
+ }
+
+ // Unpack and process the data
+ for (uint256 i = 0; i < dataLength;) {
+ address target;
+ uint96 value;
+ uint32 payloadLength;
+ // solhint-disable-next-line no-inline-assembly
+ assembly {
+ // First 20 bytes is the address (160 bits)
+ i := add(i, 20)
+ target := mload(add(data, i))
+ // Offset the data by 12 bytes of value (96 bits)
+ i := add(i, 12)
+ value := mload(add(data, i))
+ // Offset the data by 4 bytes of payload length (32 bits)
+ i := add(i, 4)
+ payloadLength := mload(add(data, i))
+ }
+
+ // Check for the zero address
+ if (target == address(0)) {
+ revert ZeroAddress();
+ }
+
+ // Check for the value compared to the contract's balance
+ if (value > address(this).balance) {
+ revert InsufficientBalance(value, address(this).balance);
+ }
+
+ // Get the payload
+ bytes memory payload = new bytes(payloadLength);
+ for (uint256 j = 0; j < payloadLength; ++j) {
+ payload[j] = data[i + j];
+ }
+ // Offset the data by the payload number of bytes
+ i += payloadLength;
+
+ // Call the target with the provided payload
+ (bool success, ) = target.call{value: value}(payload);
+ if (!success) {
+ revert TargetExecFailed(target, value, payload);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/contracts/bridges/OptimismMessenger.sol b/contracts/bridges/OptimismMessenger.sol
index 51ddfbd..7f0468f 100644
--- a/contracts/bridges/OptimismMessenger.sol
+++ b/contracts/bridges/OptimismMessenger.sol
@@ -1,85 +1,44 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
+import {BridgeMessenger} from "./BridgeMessenger.sol";
+
/// @dev Interface to the CrossDomainMessenger (CDM) Contract Proxy.
interface ICrossDomainMessenger {
function xDomainMessageSender() external returns (address);
}
-/// @dev Provided zero address.
-error ZeroAddress();
-
-/// @dev Only self contract is allowed to call the function.
-/// @param sender Sender address.
-/// @param instance Required contract instance address.
-error SelfCallOnly(address sender, address instance);
-
-/// @dev Only `CDMContractProxyHome` is allowed to call the function.
-/// @param sender Sender address.
-/// @param CDMContractProxyHome Required CDM Contract Proxy (Home) address.
-error CDMContractProxyHomeOnly(address sender, address CDMContractProxyHome);
-
-/// @dev Only on behalf of `foreignGovernor` the function is allowed to process the data.
-/// @param sender Sender address.
-/// @param foreignGovernor Required Foreign Governor address.
-error ForeignGovernorOnly(address sender, address foreignGovernor);
-
-/// @dev Provided incorrect data length.
-/// @param expected Expected minimum data length.
-/// @param provided Provided data length.
-error IncorrectDataLength(uint256 expected, uint256 provided);
-
-/// @dev Provided value is bigger than the actual balance.
-/// @param value Provided value.
-/// @param balance Actual balance.
-error InsufficientBalance(uint256 value, uint256 balance);
-
-/// @dev Target execution failed.
-/// @param target Target address.
-/// @param value Provided value.
-/// @param payload Provided payload.
-error TargetExecFailed(address target, uint256 value, bytes payload);
-
/// @title OptimismMessenger - Smart contract for the governor home (Optimism) bridge implementation
/// @author Aleksandr Kuperman -
/// @author Andrey Lebedev -
/// @author Mariapia Moscatiello -
-contract OptimismMessenger {
- event FundsReceived(address indexed sender, uint256 value);
- event ForeignGovernorUpdated(address indexed foreignMessageSender);
- event MessageReceived(address indexed foreignMessageSender, bytes data);
+contract OptimismMessenger is BridgeMessenger {
+ event SourceGovernorUpdated(address indexed sourceGovernor);
+ event MessageReceived(address indexed sourceMessageSender, bytes data);
- // Default payload data length includes the number of bytes of at least one address (20 bytes or 160 bits),
- // value (12 bytes or 96 bits) and the payload size (4 bytes or 32 bits)
- uint256 public constant DEFAULT_DATA_LENGTH = 36;
- // CDM Contract Proxy (Home) address on L2 that receives the message across the bridge from the foreign L1 network
+ // CDM Contract Proxy (Home) address on L2 that receives the message across the bridge from the source L1 network
address public immutable CDMContractProxyHome;
- // Foreign governor address on L1 that is authorized to propagate the transaction execution across the bridge
- address public foreignGovernor;
+ // Source governor address on L1 that is authorized to propagate the transaction execution across the bridge
+ address public sourceGovernor;
/// @dev OptimismMessenger constructor.
/// @param _CDMContractProxyHome CDM Contract Proxy (Home) address (Optimism).
- /// @param _foreignGovernor Foreign Governor address (ETH).
- constructor(address _CDMContractProxyHome, address _foreignGovernor) {
+ /// @param _sourceGovernor Source Governor address (ETH).
+ constructor(address _CDMContractProxyHome, address _sourceGovernor) {
// Check fo zero addresses
- if (_CDMContractProxyHome == address(0) || _foreignGovernor == address(0)) {
+ if (_CDMContractProxyHome == address(0) || _sourceGovernor == address(0)) {
revert ZeroAddress();
}
CDMContractProxyHome = _CDMContractProxyHome;
- foreignGovernor = _foreignGovernor;
+ sourceGovernor = _sourceGovernor;
}
- /// @dev Receives native network token.
- receive() external payable {
- emit FundsReceived(msg.sender, msg.value);
- }
-
- /// @dev Changes the Foreign Governor address (original Timelock).
- /// @notice The only way to change the Foreign Governor address is by the Timelock on L1 to request that change.
- /// This triggers a self-contract transaction of OptimismMessenger that changes the Foreign Governor address.
- /// @param newForeignGovernor New Foreign Governor address.
- function changeForeignGovernor(address newForeignGovernor) external {
+ /// @dev Changes the source governor address (original Timelock).
+ /// @notice The only way to change the source governor address is by the Timelock on L1 to request that change.
+ /// This triggers a self-contract transaction of BridgeMessenger that changes the source governor address.
+ /// @param newSourceGovernor New source governor address.
+ function changeSourceGovernor(address newSourceGovernor) external {
// Check if the change is authorized by the previous governor itself
// This is possible only if all the checks in the message process function pass and the contract calls itself
if (msg.sender != address(this)) {
@@ -87,83 +46,37 @@ contract OptimismMessenger {
}
// Check for the zero address
- if (newForeignGovernor == address(0)) {
+ if (newSourceGovernor == address(0)) {
revert ZeroAddress();
}
- foreignGovernor = newForeignGovernor;
- emit ForeignGovernorUpdated(newForeignGovernor);
+ sourceGovernor = newSourceGovernor;
+ emit SourceGovernorUpdated(newSourceGovernor);
}
/// @dev Processes a message received from the CDM Contract Proxy (Home) contract.
- /// @notice The sender must be the Foreign Governor address (Timelock).
+ /// @notice The sender must be the Source Governor address (Timelock).
/// @param data Bytes message sent from the CDM Contract Proxy (Home) contract. The data must be encoded as a set of
/// continuous transactions packed into a single buffer, where each transaction is composed as follows:
/// - target address of 20 bytes (160 bits);
/// - value of 12 bytes (96 bits), as a limit for all of Autonolas ecosystem contracts;
/// - payload length of 4 bytes (32 bits), as 2^32 - 1 characters is more than enough to fill a whole block;
/// - payload as bytes, with the length equal to the specified payload length.
- function processMessageFromForeign(bytes memory data) external payable {
+ function processMessageFromSource(bytes memory data) external payable {
// Check for the CDM Contract Proxy (Home) address
if (msg.sender != CDMContractProxyHome) {
- revert CDMContractProxyHomeOnly(msg.sender, CDMContractProxyHome);
+ revert TargetRelayerOnly(msg.sender, CDMContractProxyHome);
}
- // Check for the Foreign Governor address
- address governor = foreignGovernor;
+ // Check for the Source Governor address
+ address governor = sourceGovernor;
address bridgeGovernor = ICrossDomainMessenger(CDMContractProxyHome).xDomainMessageSender();
if (bridgeGovernor != governor) {
- revert ForeignGovernorOnly(bridgeGovernor, governor);
- }
-
- // Check for the correct data length
- uint256 dataLength = data.length;
- if (dataLength < DEFAULT_DATA_LENGTH) {
- revert IncorrectDataLength(DEFAULT_DATA_LENGTH, data.length);
+ revert SourceGovernorOnly(bridgeGovernor, governor);
}
- // Unpack and process the data
- for (uint256 i = 0; i < dataLength;) {
- address target;
- uint96 value;
- uint32 payloadLength;
- // solhint-disable-next-line no-inline-assembly
- assembly {
- // First 20 bytes is the address (160 bits)
- i := add(i, 20)
- target := mload(add(data, i))
- // Offset the data by 12 bytes of value (96 bits)
- i := add(i, 12)
- value := mload(add(data, i))
- // Offset the data by 4 bytes of payload length (32 bits)
- i := add(i, 4)
- payloadLength := mload(add(data, i))
- }
-
- // Check for the zero address
- if (target == address(0)) {
- revert ZeroAddress();
- }
-
- // Check for the value compared to the contract's balance
- if (value > address(this).balance) {
- revert InsufficientBalance(value, address(this).balance);
- }
-
- // Get the payload
- bytes memory payload = new bytes(payloadLength);
- for (uint256 j = 0; j < payloadLength; ++j) {
- payload[j] = data[i + j];
- }
- // Offset the data by the payload number of bytes
- i += payloadLength;
-
- // Call the target with the provided payload
- (bool success, ) = target.call{value: value}(payload);
- if (!success) {
- revert TargetExecFailed(target, value, payload);
- }
- }
+ // Process the data
+ _processData(data);
// Emit received message
emit MessageReceived(governor, data);
diff --git a/contracts/bridges/WormholeMessenger.sol b/contracts/bridges/WormholeMessenger.sol
index 376a22f..e0695ef 100644
--- a/contracts/bridges/WormholeMessenger.sol
+++ b/contracts/bridges/WormholeMessenger.sol
@@ -1,85 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
-/// @dev Provided zero address.
-error ZeroAddress();
-
-/// @dev Provided zero value.
-error ZeroValue();
-
-/// @dev Only self contract is allowed to call the function.
-/// @param sender Sender address.
-/// @param instance Required contract instance address.
-error SelfCallOnly(address sender, address instance);
-
-/// @dev Only `wormholeRelayer` is allowed to call the function.
-/// @param sender Sender address.
-/// @param wormholeRelayer Required L2 Wormhole Relayer address.
-error wormholeRelayerOnly(address sender, address wormholeRelayer);
-
-/// @dev Wrong source chain Id.
-/// @param received Chain Id received.
-/// @param required Required chain Id.
-error WrongSourceChainId(uint256 received, uint256 required);
-
-/// @dev Only on behalf of `sourceGovernor` the function is allowed to process the data.
-/// @param sender Sender address.
-/// @param sourceGovernor Required source governor address.
-error SourceGovernorOnly(address sender, address sourceGovernor);
-
-/// @dev The message with a specified hash has already been delivered.
-/// @param deliveryHash Delivery hash.
-error AlreadyDelivered(bytes32 deliveryHash);
-
-/// @dev Provided incorrect data length.
-/// @param expected Expected minimum data length.
-/// @param provided Provided data length.
-error IncorrectDataLength(uint256 expected, uint256 provided);
-
-/// @dev Provided value is bigger than the actual balance.
-/// @param value Provided value.
-/// @param balance Actual balance.
-error InsufficientBalance(uint256 value, uint256 balance);
-
-/// @dev Target execution failed.
-/// @param target Target address.
-/// @param value Provided value.
-/// @param payload Provided payload.
-error TargetExecFailed(address target, uint256 value, bytes payload);
+import {BridgeMessenger} from "./BridgeMessenger.sol";
/// @title WormholeMessenger - Smart contract for the governor bridge communication via wormhole
/// @author Aleksandr Kuperman -
/// @author Andrey Lebedev -
/// @author Mariapia Moscatiello -
-contract WormholeMessenger {
- event FundsReceived(address indexed sender, uint256 value);
- event SourceGovernorUpdated(address indexed sourceMessageSender);
- event MessageReceived(address indexed sourceMessageSender, bytes data, bytes32 deliveryHash, uint256 sourceChain);
+contract WormholeMessenger is BridgeMessenger {
+ event SourceGovernorUpdated(bytes32 indexed sourceGovernor);
+ event MessageReceived(bytes32 indexed sourceMessageSender, bytes data, bytes32 deliveryHash, uint256 sourceChain);
- // Default payload data length includes the number of bytes of at least one address (20 bytes or 160 bits),
- // value (12 bytes or 96 bits) and the payload size (4 bytes or 32 bits)
- uint256 public constant DEFAULT_DATA_LENGTH = 36;
// L2 Wormhole Relayer address that receives the message across the bridge from the source L1 network
address public immutable wormholeRelayer;
// Source governor chain Id
uint16 public immutable sourceGovernorChainId;
// Source governor address on L1 that is authorized to propagate the transaction execution across the bridge
- address public sourceGovernor;
- // Mapping of delivery hashes
+ bytes32 public sourceGovernor;
+ // Source governor address on L1 that is authorized to propagate the transaction execution across the bridge
mapping(bytes32 => bool) public mapDeliveryHashes;
/// @dev WormholeMessenger constructor.
/// @param _wormholeRelayer L2 Wormhole Relayer address.
/// @param _sourceGovernor Source governor address (ETH).
/// @param _sourceGovernorChainId Source governor wormhole format chain Id.
- constructor(address _wormholeRelayer, address _sourceGovernor, uint16 _sourceGovernorChainId) {
+ constructor(address _wormholeRelayer, bytes32 _sourceGovernor, uint16 _sourceGovernorChainId) {
// Check for zero addresses
- if (_wormholeRelayer == address(0) || _sourceGovernor == address(0)) {
+ if (_wormholeRelayer == address(0)) {
revert ZeroAddress();
}
// Check source governor chain Id
- if (_sourceGovernorChainId == 0) {
+ if (_sourceGovernor == 0 || _sourceGovernorChainId == 0) {
revert ZeroValue();
}
@@ -88,16 +40,11 @@ contract WormholeMessenger {
sourceGovernorChainId = _sourceGovernorChainId;
}
- /// @dev Receives native network token.
- receive() external payable {
- emit FundsReceived(msg.sender, msg.value);
- }
-
/// @dev Changes the source governor address (original Timelock).
/// @notice The only way to change the source governor address is by the Timelock on L1 to request that change.
- /// This triggers a self-contract transaction of WormholeMessenger that changes the source governor address.
+ /// This triggers a self-contract transaction of BridgeMessenger that changes the source governor address.
/// @param newSourceGovernor New source governor address.
- function changeSourceGovernor(address newSourceGovernor) external {
+ function changeSourceGovernor(bytes32 newSourceGovernor) external {
// Check if the change is authorized by the previous governor itself
// This is possible only if all the checks in the message process function pass and the contract calls itself
if (msg.sender != address(this)) {
@@ -105,8 +52,8 @@ contract WormholeMessenger {
}
// Check for the zero address
- if (newSourceGovernor == address(0)) {
- revert ZeroAddress();
+ if (newSourceGovernor == 0) {
+ revert ZeroValue();
}
sourceGovernor = newSourceGovernor;
@@ -133,7 +80,7 @@ contract WormholeMessenger {
) external payable {
// Check L2 Wormhole Relayer address
if (msg.sender != wormholeRelayer) {
- revert wormholeRelayerOnly(msg.sender, wormholeRelayer);
+ revert TargetRelayerOnly(msg.sender, wormholeRelayer);
}
// Check the source chain Id
@@ -142,10 +89,9 @@ contract WormholeMessenger {
}
// Check for the source governor address
- address governor = sourceGovernor;
- address bridgeGovernor = address(uint160(uint256(sourceAddress)));
- if (bridgeGovernor != governor) {
- revert SourceGovernorOnly(bridgeGovernor, governor);
+ bytes32 governor = sourceGovernor;
+ if (governor != sourceAddress) {
+ revert SourceGovernorOnly32(sourceAddress, governor);
}
// Check the delivery hash uniqueness
@@ -154,54 +100,8 @@ contract WormholeMessenger {
}
mapDeliveryHashes[deliveryHash] = true;
- // Check for the correct data length
- uint256 dataLength = data.length;
- if (dataLength < DEFAULT_DATA_LENGTH) {
- revert IncorrectDataLength(DEFAULT_DATA_LENGTH, data.length);
- }
-
- // Unpack and process the data
- for (uint256 i = 0; i < dataLength;) {
- address target;
- uint96 value;
- uint32 payloadLength;
- // solhint-disable-next-line no-inline-assembly
- assembly {
- // First 20 bytes is the address (160 bits)
- i := add(i, 20)
- target := mload(add(data, i))
- // Offset the data by 12 bytes of value (96 bits)
- i := add(i, 12)
- value := mload(add(data, i))
- // Offset the data by 4 bytes of payload length (32 bits)
- i := add(i, 4)
- payloadLength := mload(add(data, i))
- }
-
- // Check for the zero address
- if (target == address(0)) {
- revert ZeroAddress();
- }
-
- // Check for the value compared to the contract's balance
- if (value > address(this).balance) {
- revert InsufficientBalance(value, address(this).balance);
- }
-
- // Get the payload
- bytes memory payload = new bytes(payloadLength);
- for (uint256 j = 0; j < payloadLength; ++j) {
- payload[j] = data[i + j];
- }
- // Offset the data by the payload number of bytes
- i += payloadLength;
-
- // Call the target with the provided payload
- (bool success, ) = target.call{value: value}(payload);
- if (!success) {
- revert TargetExecFailed(target, value, payload);
- }
- }
+ // Process the data
+ _processData(data);
// Emit received message
emit MessageReceived(governor, data, deliveryHash, sourceChain);
diff --git a/contracts/bridges/test/MockAMBMediator.sol b/contracts/bridges/test/MockAMBMediator.sol
deleted file mode 100644
index 512924d..0000000
--- a/contracts/bridges/test/MockAMBMediator.sol
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity ^0.8.19;
-
-interface IHomeMediator {
- function processMessageFromForeign(bytes memory data) external;
-}
-
-/// @title MockAMBMediator - Smart contract for mocking the AMBMediator contract on the Gnosis chain
-/// @author Aleksandr Kuperman -
-/// @author AL
-contract MockAMBMediator {
- address public homeMediator;
- address public foreignGovernor;
-
- constructor(address _homeMediator, address _foreignGovernor) {
- homeMediator = _homeMediator;
- foreignGovernor = _foreignGovernor;
- }
-
- function changeHomeMediator(address _homeMediator) external {
- homeMediator = _homeMediator;
- }
-
- function changeForeignGovernor(address _foreignGovernor) external {
- foreignGovernor = _foreignGovernor;
- }
-
- function messageSender() external view returns (address) {
- return foreignGovernor;
- }
-
- function processMessageFromForeign(bytes memory data) external {
- IHomeMediator(homeMediator).processMessageFromForeign(data);
- }
-}
\ No newline at end of file
diff --git a/contracts/bridges/test/MockL2Relayer.sol b/contracts/bridges/test/MockL2Relayer.sol
new file mode 100644
index 0000000..9f77336
--- /dev/null
+++ b/contracts/bridges/test/MockL2Relayer.sol
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: MIT
+pragma solidity ^0.8.23;
+
+interface IBridgeMessenger {
+ function processMessageFromForeign(bytes memory data) external;
+ function processMessageFromSource(bytes memory data) external;
+ function receiveWormholeMessages(
+ bytes memory data,
+ bytes[] memory,
+ bytes32 sourceAddress,
+ uint16 sourceChain,
+ bytes32 deliveryHash
+ ) external;
+}
+
+/// @title MockL2Relayer - Smart contract for mocking the L2 relayer contract
+/// @author Aleksandr Kuperman -
+/// @author Andrey Lebedev -
+/// @author Mariapia Moscatiello -
+contract MockL2Relayer {
+ address public homeMediator;
+ address public foreignGovernor;
+
+ uint16 public sourceChain = 2; // ETH
+ bytes32 public constant DELIVERY_HASH = 0;
+
+ constructor(address _homeMediator, address _foreignGovernor) {
+ homeMediator = _homeMediator;
+ foreignGovernor = _foreignGovernor;
+ }
+
+ function changeBridgeMessenger(address _homeMediator) external {
+ homeMediator = _homeMediator;
+ }
+
+ function changeForeignGovernor(address _foreignGovernor) external {
+ foreignGovernor = _foreignGovernor;
+ }
+
+ function changeSourceGovernor(address _foreignGovernor) external {
+ foreignGovernor = _foreignGovernor;
+ }
+
+ function messageSender() external view returns (address) {
+ return foreignGovernor;
+ }
+
+ function xDomainMessageSender() external view returns (address) {
+ return foreignGovernor;
+ }
+
+ function processMessageFromForeign(bytes memory data) public {
+ IBridgeMessenger(homeMediator).processMessageFromForeign(data);
+ }
+
+ function processMessageFromSource(bytes memory data) external {
+ IBridgeMessenger(homeMediator).processMessageFromSource(data);
+ }
+
+ function changeSourceChain(uint16 chainId) external {
+ sourceChain = chainId;
+ }
+
+ function receiveWormholeMessages(bytes memory data) external {
+ bytes32 sourceAddress = bytes32(uint256(uint160(foreignGovernor)));
+ IBridgeMessenger(homeMediator).receiveWormholeMessages(data, new bytes[](0), sourceAddress, sourceChain, DELIVERY_HASH);
+ }
+}
\ No newline at end of file
diff --git a/contracts/interfaces/IBridgeErrors.sol b/contracts/interfaces/IBridgeErrors.sol
new file mode 100644
index 0000000..113430a
--- /dev/null
+++ b/contracts/interfaces/IBridgeErrors.sol
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: MIT
+pragma solidity ^0.8.23;
+
+/// @dev Bridge errors.
+interface IBridgeErrors {
+ /// @dev Provided zero address.
+ error ZeroAddress();
+
+ /// @dev Provided zero value.
+ error ZeroValue();
+
+ /// @dev Only self contract is allowed to call the function.
+ /// @param sender Sender address.
+ /// @param instance Required contract instance address.
+ error SelfCallOnly(address sender, address instance);
+
+ /// @dev Only L2 relayer is allowed to call the function.
+ /// @param sender Sender address.
+ /// @param targetRelayer Required L2 relayer address.
+ error TargetRelayerOnly(address sender, address targetRelayer);
+
+ /// @dev Wrong source chain Id.
+ /// @param received Chain Id received.
+ /// @param required Required chain Id.
+ error WrongSourceChainId(uint256 received, uint256 required);
+
+ /// @dev Only on behalf of `sourceGovernor` the function is allowed to process the data.
+ /// @param sender Sender address.
+ /// @param sourceGovernor Required source governor address.
+ error SourceGovernorOnly(address sender, address sourceGovernor);
+
+ /// @dev Only on behalf of `sourceGovernor` the function is allowed to process the data.
+ /// @param sender Sender address.
+ /// @param sourceGovernor Required source governor address.
+ error SourceGovernorOnly32(bytes32 sender, bytes32 sourceGovernor);
+
+ /// @dev The message with a specified hash has already been delivered.
+ /// @param deliveryHash Delivery hash.
+ error AlreadyDelivered(bytes32 deliveryHash);
+
+ /// @dev Provided incorrect data length.
+ /// @param expected Expected minimum data length.
+ /// @param provided Provided data length.
+ error IncorrectDataLength(uint256 expected, uint256 provided);
+
+ /// @dev Provided value is bigger than the actual balance.
+ /// @param value Provided value.
+ /// @param balance Actual balance.
+ error InsufficientBalance(uint256 value, uint256 balance);
+
+ /// @dev Target execution failed.
+ /// @param target Target address.
+ /// @param value Provided value.
+ /// @param payload Provided payload.
+ error TargetExecFailed(address target, uint256 value, bytes payload);
+}
diff --git a/scripts/deployment/bridges/wormhole/test/messenger_sepolia_celo_alfajores_governor.js b/scripts/deployment/bridges/wormhole/test/messenger_sepolia_celo_alfajores_governor.js
index dca4a90..cd2edfd 100644
--- a/scripts/deployment/bridges/wormhole/test/messenger_sepolia_celo_alfajores_governor.js
+++ b/scripts/deployment/bridges/wormhole/test/messenger_sepolia_celo_alfajores_governor.js
@@ -102,9 +102,9 @@ async function main() {
const balanceETHBefore = await celoAlfajoresProvider.getBalance(EOAceloAlfajores.address);
// Build the final payload to be passed from the imaginary Timelock
- const sendPayloadSelector = "0x8fecdd02";
+ const sendPayloadSelector = "0x4b5ca6f4";
const timelockPayload = await wormholeRelayer.interface.encodeFunctionData(sendPayloadSelector, [targetChain,
- wormholeMessengerAddress, data, 0, minGasLimit]);
+ wormholeMessengerAddress, data, 0, minGasLimit, targetChain, wormholeMessengerAddress]);
// Send the message to celoAlfajores receiver
tx = await mockTimelock.connect(EOAsepolia).execute(timelockPayload, { value: transferCost.nativePriceQuote });
diff --git a/scripts/deployment/bridges/wormhole/test/messenger_sepolia_polygon_mumbai_governor.js b/scripts/deployment/bridges/wormhole/test/messenger_sepolia_polygon_mumbai_governor.js
index 33288a3..c94a5a5 100644
--- a/scripts/deployment/bridges/wormhole/test/messenger_sepolia_polygon_mumbai_governor.js
+++ b/scripts/deployment/bridges/wormhole/test/messenger_sepolia_polygon_mumbai_governor.js
@@ -102,9 +102,9 @@ async function main() {
const balanceETHBefore = await polygonMumbaiProvider.getBalance(EOApolygonMumbai.address);
// Build the final payload to be passed from the imaginary Timelock
- const sendPayloadSelector = "0x8fecdd02";
+ const sendPayloadSelector = "0x4b5ca6f4";
const timelockPayload = await wormholeRelayer.interface.encodeFunctionData(sendPayloadSelector, [targetChain,
- wormholeMessengerAddress, data, 0, minGasLimit]);
+ wormholeMessengerAddress, data, 0, minGasLimit, targetChain, wormholeMessengerAddress]);
// Send the message to polygonMumbai receiver
tx = await mockTimelock.connect(EOAsepolia).execute(timelockPayload, { value: transferCost.nativePriceQuote });
diff --git a/test/HomeMediator.js b/test/HomeMediator.js
index f98c1c1..b306b85 100644
--- a/test/HomeMediator.js
+++ b/test/HomeMediator.js
@@ -16,7 +16,7 @@ describe("HomeMediator", function () {
deployer = signers[0];
// Deploy the mock of AMBMediator contract
- const AMBMediator = await ethers.getContractFactory("MockAMBMediator");
+ const AMBMediator = await ethers.getContractFactory("MockL2Relayer");
ambMediator = await AMBMediator.deploy(deployer.address, deployer.address);
await ambMediator.deployed();
@@ -26,7 +26,7 @@ describe("HomeMediator", function () {
await homeMediator.deployed();
// Change the HomeMediator contract address in the AMBMediator
- await ambMediator.changeHomeMediator(homeMediator.address);
+ await ambMediator.changeBridgeMessenger(homeMediator.address);
// OLAS represents a contract deployed on L2
const OLAS = await ethers.getContractFactory("OLAS");
diff --git a/test/OptimismMessenger.js b/test/OptimismMessenger.js
new file mode 100644
index 0000000..8147cb7
--- /dev/null
+++ b/test/OptimismMessenger.js
@@ -0,0 +1,271 @@
+/*global describe, context, beforeEach, it*/
+
+const { expect } = require("chai");
+const { ethers } = require("hardhat");
+
+describe("OptimismMessenger", function () {
+ let cdmContractProxy;
+ let optimismMessenger;
+ let olas;
+ let signers;
+ let deployer;
+ const AddressZero = ethers.constants.AddressZero;
+
+ beforeEach(async function () {
+ signers = await ethers.getSigners();
+ deployer = signers[0];
+
+ // Deploy the mock of CDMContractProxy contract
+ const CDMContractProxy = await ethers.getContractFactory("MockL2Relayer");
+ cdmContractProxy = await CDMContractProxy.deploy(deployer.address, deployer.address);
+ await cdmContractProxy.deployed();
+
+ // The deployer is the analogue of the Timelock on L1 and the FxRoot mock on L1 as well
+ const OptimismMessenger = await ethers.getContractFactory("OptimismMessenger");
+ optimismMessenger = await OptimismMessenger.deploy(cdmContractProxy.address, deployer.address);
+ await optimismMessenger.deployed();
+
+ // Change the OptimismMessenger contract address in the CDMContractProxy
+ await cdmContractProxy.changeBridgeMessenger(optimismMessenger.address);
+
+ // OLAS represents a contract deployed on L2
+ const OLAS = await ethers.getContractFactory("OLAS");
+ olas = await OLAS.deploy();
+ await olas.deployed();
+ });
+
+ context("Initialization", async function () {
+ it("Deploying with zero addresses", async function () {
+ const OptimismMessenger = await ethers.getContractFactory("OptimismMessenger");
+ await expect(
+ OptimismMessenger.deploy(AddressZero, AddressZero)
+ ).to.be.revertedWithCustomError(optimismMessenger, "ZeroAddress");
+
+ await expect(
+ OptimismMessenger.deploy(signers[1].address, AddressZero)
+ ).to.be.revertedWithCustomError(optimismMessenger, "ZeroAddress");
+ });
+ });
+
+ context("Process message from source", async function () {
+ it("Should fail when trying to call from incorrect contract addresses", async function () {
+ await expect(
+ optimismMessenger.connect(deployer).processMessageFromSource("0x")
+ ).to.be.revertedWithCustomError(optimismMessenger, "TargetRelayerOnly");
+
+ // Simulate incorrect sourceGovernor address
+ await cdmContractProxy.changeSourceGovernor(AddressZero);
+ await expect(
+ cdmContractProxy.processMessageFromSource("0x")
+ ).to.be.revertedWithCustomError(optimismMessenger, "SourceGovernorOnly");
+ });
+
+ it("Should fail when trying to process message with the incorrect minimal payload length", async function () {
+ await expect(
+ cdmContractProxy.processMessageFromSource("0x")
+ ).to.be.revertedWithCustomError(optimismMessenger, "IncorrectDataLength");
+ });
+
+ it("Should fail when trying to change the source governor from any other contract / EOA", async function () {
+ await expect(
+ optimismMessenger.connect(deployer).changeSourceGovernor(signers[1].address)
+ ).to.be.revertedWithCustomError(optimismMessenger, "SelfCallOnly");
+ });
+
+ it("Should fail when trying to call with the zero address", async function () {
+ const target = AddressZero;
+ const value = 0;
+ const payload = "";
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32"],
+ [target, value, payload.length]
+ );
+
+ await expect(
+ cdmContractProxy.processMessageFromSource(data)
+ ).to.be.revertedWithCustomError(optimismMessenger, "ZeroAddress");
+ });
+
+ it("Should fail when trying to call with the incorrectly provided payload", async function () {
+ const target = olas.address;
+ const value = 0;
+ const rawPayload = "0x" + "abcd".repeat(10);
+ const payload = ethers.utils.arrayify(rawPayload);
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ );
+
+ await expect(
+ cdmContractProxy.processMessageFromSource(data)
+ ).to.be.revertedWithCustomError(optimismMessenger, "TargetExecFailed");
+ });
+
+ it("Unpack the data and call one specified target on the OLAS contract", async function () {
+ // Minter of OLAS must be the optimismMessenger contract
+ await olas.connect(deployer).changeMinter(optimismMessenger.address);
+
+ // OLAS contract across the bridge must mint 100 OLAS for the deployer
+ const amountToMint = 100;
+ const rawPayload = olas.interface.encodeFunctionData("mint", [deployer.address, amountToMint]);
+
+ // Pack the data into one contiguous buffer
+ const target = olas.address;
+ const value = 0;
+ const payload = ethers.utils.arrayify(rawPayload);
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ );
+
+ // Execute the unpacked transaction
+ await cdmContractProxy.processMessageFromSource(data);
+
+ // Check that OLAS tokens were minted to the deployer
+ const balance = Number(await olas.balanceOf(deployer.address));
+ expect(balance).to.equal(amountToMint);
+ });
+
+ it("Unpack the data and call two specified targets on the OLAS contract", async function () {
+ // Minter of OLAS must be the optimismMessenger contract
+ await olas.connect(deployer).changeMinter(optimismMessenger.address);
+ // Change OLAS owner to the optimismMessenger contract
+ await olas.connect(deployer).changeOwner(optimismMessenger.address);
+
+ // FxGivernorTunnel changes the minter to self as being the owner, then mint 100 OLAS for the deployer
+ const amountToMint = 100;
+ const payloads = [olas.interface.encodeFunctionData("changeMinter", [optimismMessenger.address]),
+ olas.interface.encodeFunctionData("mint", [deployer.address, amountToMint])];
+
+ // Pack the data into one contiguous buffer
+ const targets = [olas.address, olas.address];
+ const values = [0, 0];
+ let data = "0x";
+ for (let i = 0; i < targets.length; i++) {
+ const payload = ethers.utils.arrayify(payloads[i]);
+ const encoded = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [targets[i], values[i], payload.length, payload]
+ );
+ data += encoded.slice(2);
+ }
+
+ // Execute the unpacked transaction
+ await cdmContractProxy.processMessageFromSource(data);
+
+ // Check that OLAS tokens were minted to the deployer
+ const balance = Number(await olas.balanceOf(deployer.address));
+ expect(balance).to.equal(amountToMint);
+ });
+
+ it("Change the source governor", async function () {
+ const rawPayload = optimismMessenger.interface.encodeFunctionData("changeSourceGovernor", [signers[1].address]);
+
+ // Pack the data into one contiguous buffer
+ const target = optimismMessenger.address;
+ const value = 0;
+ const payload = ethers.utils.arrayify(rawPayload);
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ );
+
+ // Execute the unpacked transaction
+ await cdmContractProxy.processMessageFromSource(data);
+
+ // Check that the new source governor is signers[1].address
+ const sourceGovernor = await optimismMessenger.sourceGovernor();
+ expect(sourceGovernor).to.equal(signers[1].address);
+ });
+
+ it("Should fail when trying to change the source governor to the zero address", async function () {
+ const rawPayload = optimismMessenger.interface.encodeFunctionData("changeSourceGovernor", [AddressZero]);
+
+ // Pack the data into one contiguous buffer
+ const target = optimismMessenger.address;
+ const value = 0;
+ const payload = ethers.utils.arrayify(rawPayload);
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ );
+
+ // Execute the unpacked transaction
+ await expect(
+ cdmContractProxy.processMessageFromSource(data)
+ ).to.be.revertedWithCustomError(optimismMessenger, "TargetExecFailed");
+ });
+
+ it("Unpack the data and call one specified target to send funds", async function () {
+ const amount = ethers.utils.parseEther("1");
+ // Pack the data into one contiguous buffer
+ const target = deployer.address;
+ const value = amount;
+ const payloadLength = 0;
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32"],
+ [target, value, payloadLength]
+ );
+
+ // Try to execute the unpacked transaction without the contract having enough balance
+ await expect(
+ cdmContractProxy.processMessageFromSource(data)
+ ).to.be.revertedWithCustomError(optimismMessenger, "InsufficientBalance");
+
+ // Send funds to the contract
+ await deployer.sendTransaction({to: optimismMessenger.address, value: amount});
+
+ // Now the funds can be transferred
+ const balanceBefore = await ethers.provider.getBalance(deployer.address);
+ const tx = await cdmContractProxy.processMessageFromSource(data);
+ const receipt = await tx.wait();
+ const gasCost = ethers.BigNumber.from(receipt.gasUsed).mul(ethers.BigNumber.from(tx.gasPrice));
+ const balanceAfter = await ethers.provider.getBalance(deployer.address);
+ const balanceDiff = balanceAfter.sub(balanceBefore).add(gasCost);
+ expect(balanceDiff).to.equal(amount);
+ });
+
+ it("Unpack the data and call one specified target to send funds and to mint OLAS", async function () {
+ const amount = ethers.utils.parseEther("1");
+ const amountToMint = 100;
+ // Minter of OLAS must be the optimismMessenger contract
+ await olas.connect(deployer).changeMinter(optimismMessenger.address);
+
+ // Pack the first part of data with the zero payload
+ let target = deployer.address;
+ let value = amount;
+ const payloadLength = 0;
+ let data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32"],
+ [target, value, payloadLength]
+ );
+
+ // OLAS contract across the bridge must mint 100 OLAS for the deployer
+ const rawPayload = olas.interface.encodeFunctionData("mint", [deployer.address, amountToMint]);
+ // Pack the second part of data
+ target = olas.address;
+ value = 0;
+ const payload = ethers.utils.arrayify(rawPayload);
+ data += ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ ).slice(2);
+
+ // Send funds to the contract
+ await deployer.sendTransaction({to: optimismMessenger.address, value: amount});
+
+ // Execute the function and check for the deployer balance
+ const balanceBefore = await ethers.provider.getBalance(deployer.address);
+ const tx = await cdmContractProxy.processMessageFromSource(data);
+ const receipt = await tx.wait();
+ const gasCost = ethers.BigNumber.from(receipt.gasUsed).mul(ethers.BigNumber.from(tx.gasPrice));
+ const balanceAfter = await ethers.provider.getBalance(deployer.address);
+ const balanceDiff = balanceAfter.sub(balanceBefore).add(gasCost);
+ expect(balanceDiff).to.equal(amount);
+
+ // Check that OLAS tokens were minted to the deployer
+ const olasBalance = Number(await olas.balanceOf(deployer.address));
+ expect(olasBalance).to.equal(amountToMint);
+ });
+ });
+});
diff --git a/test/WormholeMessenger.js b/test/WormholeMessenger.js
new file mode 100644
index 0000000..b488960
--- /dev/null
+++ b/test/WormholeMessenger.js
@@ -0,0 +1,291 @@
+/*global describe, context, beforeEach, it*/
+
+const { expect } = require("chai");
+const { ethers } = require("hardhat");
+
+describe("WormholeMessenger", function () {
+ let targetRelayer;
+ let wormholeMessenger;
+ let olas;
+ let signers;
+ let deployer;
+ const AddressZero = ethers.constants.AddressZero;
+ const Bytes32Zero = "0x" + "0".repeat(64);
+ const sourceChain = 2;
+ const addressPrefix = "0x" + "0".repeat(24);
+
+ beforeEach(async function () {
+ signers = await ethers.getSigners();
+ deployer = signers[0];
+
+ // Deploy the mock of TargetRelayer contract
+ const TargetRelayer = await ethers.getContractFactory("MockL2Relayer");
+ targetRelayer = await TargetRelayer.deploy(deployer.address, deployer.address);
+ await targetRelayer.deployed();
+
+ // The deployer is the analogue of the Timelock on L1 and the FxRoot mock on L1 as well
+ const WormholeMessenger = await ethers.getContractFactory("WormholeMessenger");
+ wormholeMessenger = await WormholeMessenger.deploy(targetRelayer.address,
+ addressPrefix + deployer.address.slice(2), sourceChain);
+ await wormholeMessenger.deployed();
+
+ // Change the WormholeMessenger contract address in the TargetRelayer
+ await targetRelayer.changeBridgeMessenger(wormholeMessenger.address);
+
+ // OLAS represents a contract deployed on L2
+ const OLAS = await ethers.getContractFactory("OLAS");
+ olas = await OLAS.deploy();
+ await olas.deployed();
+ });
+
+ context("Initialization", async function () {
+ it("Deploying with zero addresses", async function () {
+ const WormholeMessenger = await ethers.getContractFactory("WormholeMessenger");
+ await expect(
+ WormholeMessenger.deploy(AddressZero, Bytes32Zero, 0)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "ZeroAddress");
+
+ await expect(
+ WormholeMessenger.deploy(signers[1].address, Bytes32Zero, 0)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "ZeroValue");
+
+ await expect(
+ WormholeMessenger.deploy(signers[1].address, addressPrefix + signers[2].address.slice(2), 0)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "ZeroValue");
+ });
+ });
+
+ context("Process message from source", async function () {
+ it("Should fail when trying to call from incorrect contract addresses and chain Id", async function () {
+ await expect(
+ wormholeMessenger.connect(deployer).receiveWormholeMessages("0x", [], Bytes32Zero, 0, Bytes32Zero)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "TargetRelayerOnly");
+
+ // Simulate incorrect sourceGovernor address
+ await targetRelayer.changeSourceGovernor(AddressZero);
+ await expect(
+ targetRelayer.receiveWormholeMessages("0x")
+ ).to.be.revertedWithCustomError(wormholeMessenger, "SourceGovernorOnly32");
+
+ // Simulate incorrect source chain Id
+ await targetRelayer.changeSourceChain(0);
+ await expect(
+ targetRelayer.receiveWormholeMessages("0x")
+ ).to.be.revertedWithCustomError(wormholeMessenger, "WrongSourceChainId");
+ });
+
+ it("Should fail when trying to process message with the incorrect minimal payload length", async function () {
+ await expect(
+ targetRelayer.receiveWormholeMessages("0x")
+ ).to.be.revertedWithCustomError(wormholeMessenger, "IncorrectDataLength");
+ });
+
+ it("Should fail when trying to change the source governor from any other contract / EOA", async function () {
+ await expect(
+ wormholeMessenger.connect(deployer).changeSourceGovernor(addressPrefix + signers[1].address.slice(2))
+ ).to.be.revertedWithCustomError(wormholeMessenger, "SelfCallOnly");
+ });
+
+ it("Should fail when trying to call with the zero address", async function () {
+ const target = AddressZero;
+ const value = 0;
+ const payload = "";
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32"],
+ [target, value, payload.length]
+ );
+
+ await expect(
+ targetRelayer.receiveWormholeMessages(data)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "ZeroAddress");
+ });
+
+ it("Should fail when trying to call with the incorrectly provided payload", async function () {
+ const target = olas.address;
+ const value = 0;
+ const rawPayload = "0x" + "abcd".repeat(10);
+ const payload = ethers.utils.arrayify(rawPayload);
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ );
+
+ await expect(
+ targetRelayer.receiveWormholeMessages(data)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "TargetExecFailed");
+ });
+
+ it("Unpack the data and call one specified target on the OLAS contract", async function () {
+ // Minter of OLAS must be the wormholeMessenger contract
+ await olas.connect(deployer).changeMinter(wormholeMessenger.address);
+
+ // OLAS contract across the bridge must mint 100 OLAS for the deployer
+ const amountToMint = 100;
+ const rawPayload = olas.interface.encodeFunctionData("mint", [deployer.address, amountToMint]);
+
+ // Pack the data into one contiguous buffer
+ const target = olas.address;
+ const value = 0;
+ const payload = ethers.utils.arrayify(rawPayload);
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ );
+
+ // Execute the unpacked transaction
+ await targetRelayer.receiveWormholeMessages(data);
+
+ // Check that OLAS tokens were minted to the deployer
+ const balance = Number(await olas.balanceOf(deployer.address));
+ expect(balance).to.equal(amountToMint);
+
+ // Try to unpack with the same delivery hash
+ await expect(
+ targetRelayer.receiveWormholeMessages(data)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "AlreadyDelivered");
+ });
+
+ it("Unpack the data and call two specified targets on the OLAS contract", async function () {
+ // Minter of OLAS must be the wormholeMessenger contract
+ await olas.connect(deployer).changeMinter(wormholeMessenger.address);
+ // Change OLAS owner to the wormholeMessenger contract
+ await olas.connect(deployer).changeOwner(wormholeMessenger.address);
+
+ // FxGivernorTunnel changes the minter to self as being the owner, then mint 100 OLAS for the deployer
+ const amountToMint = 100;
+ const payloads = [olas.interface.encodeFunctionData("changeMinter", [wormholeMessenger.address]),
+ olas.interface.encodeFunctionData("mint", [deployer.address, amountToMint])];
+
+ // Pack the data into one contiguous buffer
+ const targets = [olas.address, olas.address];
+ const values = [0, 0];
+ let data = "0x";
+ for (let i = 0; i < targets.length; i++) {
+ const payload = ethers.utils.arrayify(payloads[i]);
+ const encoded = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [targets[i], values[i], payload.length, payload]
+ );
+ data += encoded.slice(2);
+ }
+
+ // Execute the unpacked transaction
+ await targetRelayer.receiveWormholeMessages(data);
+
+ // Check that OLAS tokens were minted to the deployer
+ const balance = Number(await olas.balanceOf(deployer.address));
+ expect(balance).to.equal(amountToMint);
+ });
+
+ it("Change the source governor", async function () {
+ const rawPayload = wormholeMessenger.interface.encodeFunctionData("changeSourceGovernor",
+ [addressPrefix + signers[1].address.slice(2)]);
+
+ // Pack the data into one contiguous buffer
+ const target = wormholeMessenger.address;
+ const value = 0;
+ const payload = ethers.utils.arrayify(rawPayload);
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ );
+
+ // Execute the unpacked transaction
+ await targetRelayer.receiveWormholeMessages(data);
+
+ // Check that the new source governor is signers[1].address
+ const sourceGovernor = await wormholeMessenger.sourceGovernor();
+ expect(sourceGovernor).to.equal((addressPrefix + signers[1].address.slice(2)).toLowerCase());
+ });
+
+ it("Should fail when trying to change the source governor to the zero address", async function () {
+ const rawPayload = wormholeMessenger.interface.encodeFunctionData("changeSourceGovernor", [Bytes32Zero]);
+
+ // Pack the data into one contiguous buffer
+ const target = wormholeMessenger.address;
+ const value = 0;
+ const payload = ethers.utils.arrayify(rawPayload);
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ );
+
+ // Execute the unpacked transaction
+ await expect(
+ targetRelayer.receiveWormholeMessages(data)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "TargetExecFailed");
+ });
+
+ it("Unpack the data and call one specified target to send funds", async function () {
+ const amount = ethers.utils.parseEther("1");
+ // Pack the data into one contiguous buffer
+ const target = deployer.address;
+ const value = amount;
+ const payloadLength = 0;
+ const data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32"],
+ [target, value, payloadLength]
+ );
+
+ // Try to execute the unpacked transaction without the contract having enough balance
+ await expect(
+ targetRelayer.receiveWormholeMessages(data)
+ ).to.be.revertedWithCustomError(wormholeMessenger, "InsufficientBalance");
+
+ // Send funds to the contract
+ await deployer.sendTransaction({to: wormholeMessenger.address, value: amount});
+
+ // Now the funds can be transferred
+ const balanceBefore = await ethers.provider.getBalance(deployer.address);
+ const tx = await targetRelayer.receiveWormholeMessages(data);
+ const receipt = await tx.wait();
+ const gasCost = ethers.BigNumber.from(receipt.gasUsed).mul(ethers.BigNumber.from(tx.gasPrice));
+ const balanceAfter = await ethers.provider.getBalance(deployer.address);
+ const balanceDiff = balanceAfter.sub(balanceBefore).add(gasCost);
+ expect(balanceDiff).to.equal(amount);
+ });
+
+ it("Unpack the data and call one specified target to send funds and to mint OLAS", async function () {
+ const amount = ethers.utils.parseEther("1");
+ const amountToMint = 100;
+ // Minter of OLAS must be the wormholeMessenger contract
+ await olas.connect(deployer).changeMinter(wormholeMessenger.address);
+
+ // Pack the first part of data with the zero payload
+ let target = deployer.address;
+ let value = amount;
+ const payloadLength = 0;
+ let data = ethers.utils.solidityPack(
+ ["address", "uint96", "uint32"],
+ [target, value, payloadLength]
+ );
+
+ // OLAS contract across the bridge must mint 100 OLAS for the deployer
+ const rawPayload = olas.interface.encodeFunctionData("mint", [deployer.address, amountToMint]);
+ // Pack the second part of data
+ target = olas.address;
+ value = 0;
+ const payload = ethers.utils.arrayify(rawPayload);
+ data += ethers.utils.solidityPack(
+ ["address", "uint96", "uint32", "bytes"],
+ [target, value, payload.length, payload]
+ ).slice(2);
+
+ // Send funds to the contract
+ await deployer.sendTransaction({to: wormholeMessenger.address, value: amount});
+
+ // Execute the function and check for the deployer balance
+ const balanceBefore = await ethers.provider.getBalance(deployer.address);
+ const tx = await targetRelayer.receiveWormholeMessages(data);
+ const receipt = await tx.wait();
+ const gasCost = ethers.BigNumber.from(receipt.gasUsed).mul(ethers.BigNumber.from(tx.gasPrice));
+ const balanceAfter = await ethers.provider.getBalance(deployer.address);
+ const balanceDiff = balanceAfter.sub(balanceBefore).add(gasCost);
+ expect(balanceDiff).to.equal(amount);
+
+ // Check that OLAS tokens were minted to the deployer
+ const olasBalance = Number(await olas.balanceOf(deployer.address));
+ expect(olasBalance).to.equal(amountToMint);
+ });
+ });
+});
diff --git a/test/buOLAS.js b/test/buOLAS.js
index 8481d37..13cd271 100644
--- a/test/buOLAS.js
+++ b/test/buOLAS.js
@@ -2,6 +2,7 @@
const { expect } = require("chai");
const { ethers } = require("hardhat");
+const helpers = require("@nomicfoundation/hardhat-network-helpers");
describe("buOLAS", function () {
let olas;
@@ -408,4 +409,27 @@ describe("buOLAS", function () {
).to.be.revertedWithCustomError(bu, "NonTransferable");
});
});
+
+ context("Time sensitive functions.", async function () {
+ it("Should fail when creating a lock after the year of 2106", async function () {
+ // Take a snapshot of the current state of the blockchain
+ const snapshot = await helpers.takeSnapshot();
+
+ const account = signers[1].address;
+ await olas.approve(bu.address, oneOLASBalance);
+
+ // Define 4 years for the lock duration
+ const numSteps = 4;
+
+ // Move time to the year 2106
+ const year2106 = 4291821394;
+ await helpers.time.increase(year2106);
+ await expect(
+ bu.createLockFor(account, oneOLASBalance, numSteps)
+ ).to.be.revertedWithCustomError(bu, "Overflow");
+
+ // Restore to the state of the snapshot
+ await snapshot.restore();
+ });
+ });
});
diff --git a/test/xbuOLAS.js b/test/xbuOLAS.js
deleted file mode 100644
index f020ca8..0000000
--- a/test/xbuOLAS.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/*global describe, context, beforeEach, it*/
-
-const { expect } = require("chai");
-const { ethers } = require("hardhat");
-
-describe("Time shifting buOLAS", function () {
- let olas;
- let bu;
- let signers;
- const initialMint = "1000000000000000000000000"; // 1000000
- const oneOLABalance = ethers.utils.parseEther("1");
- const numSteps = 4;
-
- beforeEach(async function () {
- const OLAS = await ethers.getContractFactory("OLAS");
- olas = await OLAS.deploy();
- await olas.deployed();
-
- signers = await ethers.getSigners();
- await olas.mint(signers[0].address, initialMint);
-
- const BU = await ethers.getContractFactory("buOLAS");
- bu = await BU.deploy(olas.address, "name", "symbol");
- await bu.deployed();
- });
-
- context("Time sensitive functions. This must be the very last test", async function () {
- it("Should fail when creating a lock after the year of 2106", async function () {
- const account = signers[1].address;
- await olas.approve(bu.address, oneOLABalance);
-
- // Move time to the year 2106
- const year2106 = 4291821394;
- ethers.provider.send("evm_increaseTime", [year2106]);
- ethers.provider.send("evm_mine");
- await expect(
- bu.createLockFor(account, oneOLABalance, numSteps)
- ).to.be.revertedWithCustomError(bu, "Overflow");
- });
- });
-});