@hyperlane-xyz/core 0.5.0-beta0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/contracts/AbacusConnectionManager.sol +168 -0
- package/contracts/Inbox.sol +148 -0
- package/contracts/InterchainGasPaymaster.sol +67 -0
- package/contracts/Mailbox.sol +93 -0
- package/contracts/MerkleTreeManager.sol +32 -0
- package/contracts/Outbox.sol +191 -0
- package/contracts/libs/Merkle.sol +208 -0
- package/contracts/libs/Message.sol +122 -0
- package/contracts/libs/TypeCasts.sol +34 -0
- package/contracts/mock/MockInbox.sol +49 -0
- package/contracts/mock/MockOutbox.sol +26 -0
- package/contracts/test/MysteryMath.sol +21 -0
- package/contracts/test/MysteryMathV1.sol +22 -0
- package/contracts/test/MysteryMathV2.sol +22 -0
- package/contracts/test/TestInbox.sol +54 -0
- package/contracts/test/TestMailbox.sol +12 -0
- package/contracts/test/TestMerkle.sol +30 -0
- package/contracts/test/TestMessage.sol +64 -0
- package/contracts/test/TestMultisigValidatorManager.sol +26 -0
- package/contracts/test/TestOutbox.sol +46 -0
- package/contracts/test/TestRecipient.sol +18 -0
- package/contracts/test/TestSendReceiver.sol +65 -0
- package/contracts/test/TestValidatorManager.sol +21 -0
- package/contracts/test/bad-recipient/BadRecipient1.sol +16 -0
- package/contracts/test/bad-recipient/BadRecipient2.sol +6 -0
- package/contracts/test/bad-recipient/BadRecipient3.sol +17 -0
- package/contracts/test/bad-recipient/BadRecipient5.sol +14 -0
- package/contracts/test/bad-recipient/BadRecipient6.sol +14 -0
- package/contracts/upgrade/UpgradeBeacon.sol +98 -0
- package/contracts/upgrade/UpgradeBeaconController.sol +48 -0
- package/contracts/upgrade/UpgradeBeaconProxy.sol +176 -0
- package/contracts/upgrade/Versioned.sol +10 -0
- package/contracts/validator-manager/InboxValidatorManager.sol +58 -0
- package/contracts/validator-manager/MultisigValidatorManager.sol +271 -0
- package/contracts/validator-manager/OutboxValidatorManager.sol +244 -0
- package/dist/@openzeppelin/contracts/access/Ownable.d.ts +90 -0
- package/dist/@openzeppelin/contracts/access/Ownable.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts/access/Ownable.js +4 -0
- package/dist/@openzeppelin/contracts/access/Ownable.js.map +1 -0
- package/dist/@openzeppelin/contracts/access/index.d.ts +2 -0
- package/dist/@openzeppelin/contracts/access/index.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts/access/index.js +3 -0
- package/dist/@openzeppelin/contracts/access/index.js.map +1 -0
- package/dist/@openzeppelin/contracts/index.d.ts +3 -0
- package/dist/@openzeppelin/contracts/index.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts/index.js +4 -0
- package/dist/@openzeppelin/contracts/index.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.d.ts +99 -0
- package/dist/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.js +4 -0
- package/dist/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/access/index.d.ts +2 -0
- package/dist/@openzeppelin/contracts-upgradeable/access/index.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/access/index.js +3 -0
- package/dist/@openzeppelin/contracts-upgradeable/access/index.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/index.d.ts +9 -0
- package/dist/@openzeppelin/contracts-upgradeable/index.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/index.js +4 -0
- package/dist/@openzeppelin/contracts-upgradeable/index.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/index.d.ts +3 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/index.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/index.js +4 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/index.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.d.ts +40 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.js +4 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts +2 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/utils/index.js +3 -0
- package/dist/@openzeppelin/contracts-upgradeable/proxy/utils/index.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.d.ts +40 -0
- package/dist/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.js +4 -0
- package/dist/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/security/index.d.ts +2 -0
- package/dist/@openzeppelin/contracts-upgradeable/security/index.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/security/index.js +3 -0
- package/dist/@openzeppelin/contracts-upgradeable/security/index.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.d.ts +40 -0
- package/dist/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.js +4 -0
- package/dist/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.js.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/utils/index.d.ts +2 -0
- package/dist/@openzeppelin/contracts-upgradeable/utils/index.d.ts.map +1 -0
- package/dist/@openzeppelin/contracts-upgradeable/utils/index.js +3 -0
- package/dist/@openzeppelin/contracts-upgradeable/utils/index.js.map +1 -0
- package/dist/@openzeppelin/index.d.ts +5 -0
- package/dist/@openzeppelin/index.d.ts.map +1 -0
- package/dist/@openzeppelin/index.js +4 -0
- package/dist/@openzeppelin/index.js.map +1 -0
- package/dist/common.d.ts +22 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +4 -0
- package/dist/common.js.map +1 -0
- package/dist/contracts/AbacusConnectionManager.d.ts +221 -0
- package/dist/contracts/AbacusConnectionManager.d.ts.map +1 -0
- package/dist/contracts/AbacusConnectionManager.js +4 -0
- package/dist/contracts/AbacusConnectionManager.js.map +1 -0
- package/dist/contracts/Inbox.d.ts +207 -0
- package/dist/contracts/Inbox.d.ts.map +1 -0
- package/dist/contracts/Inbox.js +4 -0
- package/dist/contracts/Inbox.js.map +1 -0
- package/dist/contracts/InterchainGasPaymaster.d.ts +162 -0
- package/dist/contracts/InterchainGasPaymaster.d.ts.map +1 -0
- package/dist/contracts/InterchainGasPaymaster.js +4 -0
- package/dist/contracts/InterchainGasPaymaster.js.map +1 -0
- package/dist/contracts/Mailbox.d.ts +142 -0
- package/dist/contracts/Mailbox.d.ts.map +1 -0
- package/dist/contracts/Mailbox.js +4 -0
- package/dist/contracts/Mailbox.js.map +1 -0
- package/dist/contracts/MerkleTreeManager.d.ts +53 -0
- package/dist/contracts/MerkleTreeManager.d.ts.map +1 -0
- package/dist/contracts/MerkleTreeManager.js +4 -0
- package/dist/contracts/MerkleTreeManager.js.map +1 -0
- package/dist/contracts/Outbox.d.ts +331 -0
- package/dist/contracts/Outbox.d.ts.map +1 -0
- package/dist/contracts/Outbox.js +4 -0
- package/dist/contracts/Outbox.js.map +1 -0
- package/dist/contracts/index.d.ts +15 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +4 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/mock/MockInbox.d.ts +67 -0
- package/dist/contracts/mock/MockInbox.d.ts.map +1 -0
- package/dist/contracts/mock/MockInbox.js +4 -0
- package/dist/contracts/mock/MockInbox.js.map +1 -0
- package/dist/contracts/mock/MockOutbox.d.ts +51 -0
- package/dist/contracts/mock/MockOutbox.d.ts.map +1 -0
- package/dist/contracts/mock/MockOutbox.js +4 -0
- package/dist/contracts/mock/MockOutbox.js.map +1 -0
- package/dist/contracts/mock/index.d.ts +3 -0
- package/dist/contracts/mock/index.d.ts.map +1 -0
- package/dist/contracts/mock/index.js +3 -0
- package/dist/contracts/mock/index.js.map +1 -0
- package/dist/contracts/test/MysteryMath.d.ts +77 -0
- package/dist/contracts/test/MysteryMath.d.ts.map +1 -0
- package/dist/contracts/test/MysteryMath.js +4 -0
- package/dist/contracts/test/MysteryMath.js.map +1 -0
- package/dist/contracts/test/MysteryMathV1.d.ts +85 -0
- package/dist/contracts/test/MysteryMathV1.d.ts.map +1 -0
- package/dist/contracts/test/MysteryMathV1.js +4 -0
- package/dist/contracts/test/MysteryMathV1.js.map +1 -0
- package/dist/contracts/test/MysteryMathV2.d.ts +85 -0
- package/dist/contracts/test/MysteryMathV2.d.ts.map +1 -0
- package/dist/contracts/test/MysteryMathV2.js +4 -0
- package/dist/contracts/test/MysteryMathV2.js.map +1 -0
- package/dist/contracts/test/TestInbox.d.ts +263 -0
- package/dist/contracts/test/TestInbox.d.ts.map +1 -0
- package/dist/contracts/test/TestInbox.js +4 -0
- package/dist/contracts/test/TestInbox.js.map +1 -0
- package/dist/contracts/test/TestMailbox.d.ts +158 -0
- package/dist/contracts/test/TestMailbox.d.ts.map +1 -0
- package/dist/contracts/test/TestMailbox.js +4 -0
- package/dist/contracts/test/TestMailbox.js.map +1 -0
- package/dist/contracts/test/TestMerkle.d.ts +87 -0
- package/dist/contracts/test/TestMerkle.d.ts.map +1 -0
- package/dist/contracts/test/TestMerkle.js +4 -0
- package/dist/contracts/test/TestMerkle.js.map +1 -0
- package/dist/contracts/test/TestMessage.d.ts +103 -0
- package/dist/contracts/test/TestMessage.d.ts.map +1 -0
- package/dist/contracts/test/TestMessage.js +4 -0
- package/dist/contracts/test/TestMessage.js.map +1 -0
- package/dist/contracts/test/TestMultisigValidatorManager.d.ts +247 -0
- package/dist/contracts/test/TestMultisigValidatorManager.d.ts.map +1 -0
- package/dist/contracts/test/TestMultisigValidatorManager.js +4 -0
- package/dist/contracts/test/TestMultisigValidatorManager.js.map +1 -0
- package/dist/contracts/test/TestOutbox.d.ts +371 -0
- package/dist/contracts/test/TestOutbox.d.ts.map +1 -0
- package/dist/contracts/test/TestOutbox.js +4 -0
- package/dist/contracts/test/TestOutbox.js.map +1 -0
- package/dist/contracts/test/TestRecipient.d.ts +67 -0
- package/dist/contracts/test/TestRecipient.d.ts.map +1 -0
- package/dist/contracts/test/TestRecipient.js +4 -0
- package/dist/contracts/test/TestRecipient.js.map +1 -0
- package/dist/contracts/test/TestSendReceiver.d.ts +78 -0
- package/dist/contracts/test/TestSendReceiver.d.ts.map +1 -0
- package/dist/contracts/test/TestSendReceiver.js +4 -0
- package/dist/contracts/test/TestSendReceiver.js.map +1 -0
- package/dist/contracts/test/TestValidatorManager.d.ts +58 -0
- package/dist/contracts/test/TestValidatorManager.d.ts.map +1 -0
- package/dist/contracts/test/TestValidatorManager.js +4 -0
- package/dist/contracts/test/TestValidatorManager.js.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient1.d.ts +43 -0
- package/dist/contracts/test/bad-recipient/BadRecipient1.d.ts.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient1.js +4 -0
- package/dist/contracts/test/bad-recipient/BadRecipient1.js.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient2.d.ts +43 -0
- package/dist/contracts/test/bad-recipient/BadRecipient2.d.ts.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient2.js +4 -0
- package/dist/contracts/test/bad-recipient/BadRecipient2.js.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient3.d.ts +43 -0
- package/dist/contracts/test/bad-recipient/BadRecipient3.d.ts.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient3.js +4 -0
- package/dist/contracts/test/bad-recipient/BadRecipient3.js.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient5.d.ts +43 -0
- package/dist/contracts/test/bad-recipient/BadRecipient5.d.ts.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient5.js +4 -0
- package/dist/contracts/test/bad-recipient/BadRecipient5.js.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient6.d.ts +43 -0
- package/dist/contracts/test/bad-recipient/BadRecipient6.d.ts.map +1 -0
- package/dist/contracts/test/bad-recipient/BadRecipient6.js +4 -0
- package/dist/contracts/test/bad-recipient/BadRecipient6.js.map +1 -0
- package/dist/contracts/test/bad-recipient/index.d.ts +6 -0
- package/dist/contracts/test/bad-recipient/index.d.ts.map +1 -0
- package/dist/contracts/test/bad-recipient/index.js +3 -0
- package/dist/contracts/test/bad-recipient/index.js.map +1 -0
- package/dist/contracts/test/index.d.ts +15 -0
- package/dist/contracts/test/index.d.ts.map +1 -0
- package/dist/contracts/test/index.js +4 -0
- package/dist/contracts/test/index.js.map +1 -0
- package/dist/contracts/upgrade/UpgradeBeacon.d.ts +40 -0
- package/dist/contracts/upgrade/UpgradeBeacon.d.ts.map +1 -0
- package/dist/contracts/upgrade/UpgradeBeacon.js +4 -0
- package/dist/contracts/upgrade/UpgradeBeacon.js.map +1 -0
- package/dist/contracts/upgrade/UpgradeBeaconController.d.ts +119 -0
- package/dist/contracts/upgrade/UpgradeBeaconController.d.ts.map +1 -0
- package/dist/contracts/upgrade/UpgradeBeaconController.js +4 -0
- package/dist/contracts/upgrade/UpgradeBeaconController.js.map +1 -0
- package/dist/contracts/upgrade/UpgradeBeaconProxy.d.ts +28 -0
- package/dist/contracts/upgrade/UpgradeBeaconProxy.d.ts.map +1 -0
- package/dist/contracts/upgrade/UpgradeBeaconProxy.js +4 -0
- package/dist/contracts/upgrade/UpgradeBeaconProxy.js.map +1 -0
- package/dist/contracts/upgrade/Versioned.d.ts +43 -0
- package/dist/contracts/upgrade/Versioned.d.ts.map +1 -0
- package/dist/contracts/upgrade/Versioned.js +4 -0
- package/dist/contracts/upgrade/Versioned.js.map +1 -0
- package/dist/contracts/upgrade/index.d.ts +5 -0
- package/dist/contracts/upgrade/index.d.ts.map +1 -0
- package/dist/contracts/upgrade/index.js +3 -0
- package/dist/contracts/upgrade/index.js.map +1 -0
- package/dist/contracts/validator-manager/InboxValidatorManager.d.ts +263 -0
- package/dist/contracts/validator-manager/InboxValidatorManager.d.ts.map +1 -0
- package/dist/contracts/validator-manager/InboxValidatorManager.js +4 -0
- package/dist/contracts/validator-manager/InboxValidatorManager.js.map +1 -0
- package/dist/contracts/validator-manager/MultisigValidatorManager.d.ts +239 -0
- package/dist/contracts/validator-manager/MultisigValidatorManager.d.ts.map +1 -0
- package/dist/contracts/validator-manager/MultisigValidatorManager.js +4 -0
- package/dist/contracts/validator-manager/MultisigValidatorManager.js.map +1 -0
- package/dist/contracts/validator-manager/OutboxValidatorManager.d.ts +335 -0
- package/dist/contracts/validator-manager/OutboxValidatorManager.d.ts.map +1 -0
- package/dist/contracts/validator-manager/OutboxValidatorManager.js +4 -0
- package/dist/contracts/validator-manager/OutboxValidatorManager.js.map +1 -0
- package/dist/contracts/validator-manager/index.d.ts +4 -0
- package/dist/contracts/validator-manager/index.d.ts.map +1 -0
- package/dist/contracts/validator-manager/index.js +3 -0
- package/dist/contracts/validator-manager/index.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts/access/Ownable__factory.d.ts +43 -0
- package/dist/factories/@openzeppelin/contracts/access/Ownable__factory.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts/access/Ownable__factory.js +70 -0
- package/dist/factories/@openzeppelin/contracts/access/Ownable__factory.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts/access/index.d.ts +2 -0
- package/dist/factories/@openzeppelin/contracts/access/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts/access/index.js +9 -0
- package/dist/factories/@openzeppelin/contracts/access/index.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts/index.d.ts +2 -0
- package/dist/factories/@openzeppelin/contracts/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts/index.js +31 -0
- package/dist/factories/@openzeppelin/contracts/index.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.d.ts +43 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.js +83 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable__factory.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/access/index.d.ts +2 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/access/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/access/index.js +9 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/access/index.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/index.d.ts +5 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/index.js +34 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/index.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/index.d.ts +2 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/index.js +31 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/index.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.d.ts +19 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.js +31 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable__factory.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts +2 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.js +9 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/proxy/utils/index.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable__factory.d.ts +19 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable__factory.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable__factory.js +31 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable__factory.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/security/index.d.ts +2 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/security/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/security/index.js +9 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/security/index.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.d.ts +19 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.js +31 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable__factory.js.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/utils/index.d.ts +2 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/utils/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/utils/index.js +9 -0
- package/dist/factories/@openzeppelin/contracts-upgradeable/utils/index.js.map +1 -0
- package/dist/factories/@openzeppelin/index.d.ts +3 -0
- package/dist/factories/@openzeppelin/index.d.ts.map +1 -0
- package/dist/factories/@openzeppelin/index.js +32 -0
- package/dist/factories/@openzeppelin/index.js.map +1 -0
- package/dist/factories/contracts/AbacusConnectionManager__factory.d.ts +55 -0
- package/dist/factories/contracts/AbacusConnectionManager__factory.d.ts.map +1 -0
- package/dist/factories/contracts/AbacusConnectionManager__factory.js +295 -0
- package/dist/factories/contracts/AbacusConnectionManager__factory.js.map +1 -0
- package/dist/factories/contracts/Inbox__factory.d.ts +59 -0
- package/dist/factories/contracts/Inbox__factory.d.ts.map +1 -0
- package/dist/factories/contracts/Inbox__factory.js +278 -0
- package/dist/factories/contracts/Inbox__factory.js.map +1 -0
- package/dist/factories/contracts/InterchainGasPaymaster__factory.d.ts +62 -0
- package/dist/factories/contracts/InterchainGasPaymaster__factory.d.ts.map +1 -0
- package/dist/factories/contracts/InterchainGasPaymaster__factory.js +173 -0
- package/dist/factories/contracts/InterchainGasPaymaster__factory.js.map +1 -0
- package/dist/factories/contracts/Mailbox__factory.d.ts +43 -0
- package/dist/factories/contracts/Mailbox__factory.d.ts.map +1 -0
- package/dist/factories/contracts/Mailbox__factory.js +135 -0
- package/dist/factories/contracts/Mailbox__factory.js.map +1 -0
- package/dist/factories/contracts/MerkleTreeManager__factory.d.ts +31 -0
- package/dist/factories/contracts/MerkleTreeManager__factory.d.ts.map +1 -0
- package/dist/factories/contracts/MerkleTreeManager__factory.js +67 -0
- package/dist/factories/contracts/MerkleTreeManager__factory.js.map +1 -0
- package/dist/factories/contracts/Outbox__factory.d.ts +59 -0
- package/dist/factories/contracts/Outbox__factory.d.ts.map +1 -0
- package/dist/factories/contracts/Outbox__factory.js +415 -0
- package/dist/factories/contracts/Outbox__factory.js.map +1 -0
- package/dist/factories/contracts/index.d.ts +11 -0
- package/dist/factories/contracts/index.d.ts.map +1 -0
- package/dist/factories/contracts/index.js +46 -0
- package/dist/factories/contracts/index.js.map +1 -0
- package/dist/factories/contracts/mock/MockInbox__factory.d.ts +31 -0
- package/dist/factories/contracts/mock/MockInbox__factory.d.ts.map +1 -0
- package/dist/factories/contracts/mock/MockInbox__factory.js +71 -0
- package/dist/factories/contracts/mock/MockInbox__factory.js.map +1 -0
- package/dist/factories/contracts/mock/MockOutbox__factory.d.ts +41 -0
- package/dist/factories/contracts/mock/MockOutbox__factory.d.ts.map +1 -0
- package/dist/factories/contracts/mock/MockOutbox__factory.js +75 -0
- package/dist/factories/contracts/mock/MockOutbox__factory.js.map +1 -0
- package/dist/factories/contracts/mock/index.d.ts +3 -0
- package/dist/factories/contracts/mock/index.d.ts.map +1 -0
- package/dist/factories/contracts/mock/index.js +11 -0
- package/dist/factories/contracts/mock/index.js.map +1 -0
- package/dist/factories/contracts/test/MysteryMathV1__factory.d.ts +41 -0
- package/dist/factories/contracts/test/MysteryMathV1__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/MysteryMathV1__factory.js +122 -0
- package/dist/factories/contracts/test/MysteryMathV1__factory.js.map +1 -0
- package/dist/factories/contracts/test/MysteryMathV2__factory.d.ts +41 -0
- package/dist/factories/contracts/test/MysteryMathV2__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/MysteryMathV2__factory.js +122 -0
- package/dist/factories/contracts/test/MysteryMathV2__factory.js.map +1 -0
- package/dist/factories/contracts/test/MysteryMath__factory.d.ts +23 -0
- package/dist/factories/contracts/test/MysteryMath__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/MysteryMath__factory.js +81 -0
- package/dist/factories/contracts/test/MysteryMath__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestInbox__factory.d.ts +59 -0
- package/dist/factories/contracts/test/TestInbox__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestInbox__factory.js +371 -0
- package/dist/factories/contracts/test/TestInbox__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestMailbox__factory.d.ts +66 -0
- package/dist/factories/contracts/test/TestMailbox__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestMailbox__factory.js +182 -0
- package/dist/factories/contracts/test/TestMailbox__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestMerkle__factory.d.ts +41 -0
- package/dist/factories/contracts/test/TestMerkle__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestMerkle__factory.js +127 -0
- package/dist/factories/contracts/test/TestMerkle__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestMessage__factory.d.ts +35 -0
- package/dist/factories/contracts/test/TestMessage__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestMessage__factory.js +179 -0
- package/dist/factories/contracts/test/TestMessage__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestMultisigValidatorManager__factory.d.ts +59 -0
- package/dist/factories/contracts/test/TestMultisigValidatorManager__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestMultisigValidatorManager__factory.js +349 -0
- package/dist/factories/contracts/test/TestMultisigValidatorManager__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestOutbox__factory.d.ts +59 -0
- package/dist/factories/contracts/test/TestOutbox__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestOutbox__factory.js +483 -0
- package/dist/factories/contracts/test/TestOutbox__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestRecipient__factory.d.ts +41 -0
- package/dist/factories/contracts/test/TestRecipient__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestRecipient__factory.js +90 -0
- package/dist/factories/contracts/test/TestRecipient__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestSendReceiver__factory.d.ts +44 -0
- package/dist/factories/contracts/test/TestSendReceiver__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestSendReceiver__factory.js +105 -0
- package/dist/factories/contracts/test/TestSendReceiver__factory.js.map +1 -0
- package/dist/factories/contracts/test/TestValidatorManager__factory.d.ts +31 -0
- package/dist/factories/contracts/test/TestValidatorManager__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/TestValidatorManager__factory.js +79 -0
- package/dist/factories/contracts/test/TestValidatorManager__factory.js.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient1__factory.d.ts +31 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient1__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient1__factory.js +64 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient1__factory.js.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient2__factory.d.ts +31 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient2__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient2__factory.js +59 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient2__factory.js.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient3__factory.d.ts +31 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient3__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient3__factory.js +64 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient3__factory.js.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient5__factory.d.ts +31 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient5__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient5__factory.js +64 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient5__factory.js.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient6__factory.d.ts +31 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient6__factory.d.ts.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient6__factory.js +64 -0
- package/dist/factories/contracts/test/bad-recipient/BadRecipient6__factory.js.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/index.d.ts +6 -0
- package/dist/factories/contracts/test/bad-recipient/index.d.ts.map +1 -0
- package/dist/factories/contracts/test/bad-recipient/index.js +17 -0
- package/dist/factories/contracts/test/bad-recipient/index.js.map +1 -0
- package/dist/factories/contracts/test/index.d.ts +14 -0
- package/dist/factories/contracts/test/index.d.ts.map +1 -0
- package/dist/factories/contracts/test/index.js +55 -0
- package/dist/factories/contracts/test/index.js.map +1 -0
- package/dist/factories/contracts/upgrade/UpgradeBeaconController__factory.d.ts +55 -0
- package/dist/factories/contracts/upgrade/UpgradeBeaconController__factory.d.ts.map +1 -0
- package/dist/factories/contracts/upgrade/UpgradeBeaconController__factory.js +130 -0
- package/dist/factories/contracts/upgrade/UpgradeBeaconController__factory.js.map +1 -0
- package/dist/factories/contracts/upgrade/UpgradeBeaconProxy__factory.d.ts +33 -0
- package/dist/factories/contracts/upgrade/UpgradeBeaconProxy__factory.d.ts.map +1 -0
- package/dist/factories/contracts/upgrade/UpgradeBeaconProxy__factory.js +65 -0
- package/dist/factories/contracts/upgrade/UpgradeBeaconProxy__factory.js.map +1 -0
- package/dist/factories/contracts/upgrade/UpgradeBeacon__factory.d.ts +48 -0
- package/dist/factories/contracts/upgrade/UpgradeBeacon__factory.d.ts.map +1 -0
- package/dist/factories/contracts/upgrade/UpgradeBeacon__factory.js +74 -0
- package/dist/factories/contracts/upgrade/UpgradeBeacon__factory.js.map +1 -0
- package/dist/factories/contracts/upgrade/Versioned__factory.d.ts +31 -0
- package/dist/factories/contracts/upgrade/Versioned__factory.d.ts.map +1 -0
- package/dist/factories/contracts/upgrade/Versioned__factory.js +54 -0
- package/dist/factories/contracts/upgrade/Versioned__factory.js.map +1 -0
- package/dist/factories/contracts/upgrade/index.d.ts +5 -0
- package/dist/factories/contracts/upgrade/index.d.ts.map +1 -0
- package/dist/factories/contracts/upgrade/index.js +15 -0
- package/dist/factories/contracts/upgrade/index.js.map +1 -0
- package/dist/factories/contracts/validator-manager/InboxValidatorManager__factory.d.ts +59 -0
- package/dist/factories/contracts/validator-manager/InboxValidatorManager__factory.d.ts.map +1 -0
- package/dist/factories/contracts/validator-manager/InboxValidatorManager__factory.js +373 -0
- package/dist/factories/contracts/validator-manager/InboxValidatorManager__factory.js.map +1 -0
- package/dist/factories/contracts/validator-manager/MultisigValidatorManager__factory.d.ts +36 -0
- package/dist/factories/contracts/validator-manager/MultisigValidatorManager__factory.d.ts.map +1 -0
- package/dist/factories/contracts/validator-manager/MultisigValidatorManager__factory.js +286 -0
- package/dist/factories/contracts/validator-manager/MultisigValidatorManager__factory.js.map +1 -0
- package/dist/factories/contracts/validator-manager/OutboxValidatorManager__factory.d.ts +59 -0
- package/dist/factories/contracts/validator-manager/OutboxValidatorManager__factory.d.ts.map +1 -0
- package/dist/factories/contracts/validator-manager/OutboxValidatorManager__factory.js +560 -0
- package/dist/factories/contracts/validator-manager/OutboxValidatorManager__factory.js.map +1 -0
- package/dist/factories/contracts/validator-manager/index.d.ts +4 -0
- package/dist/factories/contracts/validator-manager/index.d.ts.map +1 -0
- package/dist/factories/contracts/validator-manager/index.js +13 -0
- package/dist/factories/contracts/validator-manager/index.js.map +1 -0
- package/dist/factories/index.d.ts +4 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +33 -0
- package/dist/factories/index.js.map +1 -0
- package/dist/factories/interfaces/IAbacusConnectionManager__factory.d.ts +23 -0
- package/dist/factories/interfaces/IAbacusConnectionManager__factory.d.ts.map +1 -0
- package/dist/factories/interfaces/IAbacusConnectionManager__factory.js +63 -0
- package/dist/factories/interfaces/IAbacusConnectionManager__factory.js.map +1 -0
- package/dist/factories/interfaces/IInbox__factory.d.ts +29 -0
- package/dist/factories/interfaces/IInbox__factory.d.ts.map +1 -0
- package/dist/factories/interfaces/IInbox__factory.js +90 -0
- package/dist/factories/interfaces/IInbox__factory.js.map +1 -0
- package/dist/factories/interfaces/IInterchainGasPaymaster__factory.d.ts +19 -0
- package/dist/factories/interfaces/IInterchainGasPaymaster__factory.d.ts.map +1 -0
- package/dist/factories/interfaces/IInterchainGasPaymaster__factory.js +41 -0
- package/dist/factories/interfaces/IInterchainGasPaymaster__factory.js.map +1 -0
- package/dist/factories/interfaces/IMailbox__factory.d.ts +19 -0
- package/dist/factories/interfaces/IMailbox__factory.d.ts.map +1 -0
- package/dist/factories/interfaces/IMailbox__factory.js +44 -0
- package/dist/factories/interfaces/IMailbox__factory.js.map +1 -0
- package/dist/factories/interfaces/IMessageRecipient__factory.d.ts +19 -0
- package/dist/factories/interfaces/IMessageRecipient__factory.d.ts.map +1 -0
- package/dist/factories/interfaces/IMessageRecipient__factory.js +41 -0
- package/dist/factories/interfaces/IMessageRecipient__factory.js.map +1 -0
- package/dist/factories/interfaces/IMultisigValidatorManager__factory.d.ts +19 -0
- package/dist/factories/interfaces/IMultisigValidatorManager__factory.d.ts.map +1 -0
- package/dist/factories/interfaces/IMultisigValidatorManager__factory.js +57 -0
- package/dist/factories/interfaces/IMultisigValidatorManager__factory.js.map +1 -0
- package/dist/factories/interfaces/IOutbox__factory.d.ts +23 -0
- package/dist/factories/interfaces/IOutbox__factory.d.ts.map +1 -0
- package/dist/factories/interfaces/IOutbox__factory.js +155 -0
- package/dist/factories/interfaces/IOutbox__factory.js.map +1 -0
- package/dist/factories/interfaces/index.d.ts +8 -0
- package/dist/factories/interfaces/index.d.ts.map +1 -0
- package/dist/factories/interfaces/index.js +21 -0
- package/dist/factories/interfaces/index.js.map +1 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +117 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/IAbacusConnectionManager.d.ts +59 -0
- package/dist/interfaces/IAbacusConnectionManager.d.ts.map +1 -0
- package/dist/interfaces/IAbacusConnectionManager.js +4 -0
- package/dist/interfaces/IAbacusConnectionManager.js.map +1 -0
- package/dist/interfaces/IInbox.d.ts +83 -0
- package/dist/interfaces/IInbox.d.ts.map +1 -0
- package/dist/interfaces/IInbox.js +4 -0
- package/dist/interfaces/IInbox.js.map +1 -0
- package/dist/interfaces/IInterchainGasPaymaster.d.ts +51 -0
- package/dist/interfaces/IInterchainGasPaymaster.d.ts.map +1 -0
- package/dist/interfaces/IInterchainGasPaymaster.js +4 -0
- package/dist/interfaces/IInterchainGasPaymaster.js.map +1 -0
- package/dist/interfaces/IMailbox.d.ts +51 -0
- package/dist/interfaces/IMailbox.d.ts.map +1 -0
- package/dist/interfaces/IMailbox.js +4 -0
- package/dist/interfaces/IMailbox.js.map +1 -0
- package/dist/interfaces/IMessageRecipient.d.ts +51 -0
- package/dist/interfaces/IMessageRecipient.d.ts.map +1 -0
- package/dist/interfaces/IMessageRecipient.js +4 -0
- package/dist/interfaces/IMessageRecipient.js.map +1 -0
- package/dist/interfaces/IMultisigValidatorManager.d.ts +59 -0
- package/dist/interfaces/IMultisigValidatorManager.d.ts.map +1 -0
- package/dist/interfaces/IMultisigValidatorManager.js +4 -0
- package/dist/interfaces/IMultisigValidatorManager.js.map +1 -0
- package/dist/interfaces/IOutbox.d.ts +148 -0
- package/dist/interfaces/IOutbox.d.ts.map +1 -0
- package/dist/interfaces/IOutbox.js +4 -0
- package/dist/interfaces/IOutbox.js.map +1 -0
- package/dist/interfaces/index.d.ts +8 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/interfaces/IAbacusConnectionManager.sol +12 -0
- package/interfaces/IInbox.sol +16 -0
- package/interfaces/IInterchainGasPaymaster.sol +15 -0
- package/interfaces/IMailbox.sol +8 -0
- package/interfaces/IMessageRecipient.sol +10 -0
- package/interfaces/IMultisigValidatorManager.sol +11 -0
- package/interfaces/IOutbox.sol +27 -0
- package/package.json +54 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
pragma solidity >=0.8.0;
|
|
3
|
+
|
|
4
|
+
// ============ Internal Imports ============
|
|
5
|
+
import {Versioned} from "./upgrade/Versioned.sol";
|
|
6
|
+
import {Mailbox} from "./Mailbox.sol";
|
|
7
|
+
import {MerkleLib} from "./libs/Merkle.sol";
|
|
8
|
+
import {Message} from "./libs/Message.sol";
|
|
9
|
+
import {TypeCasts} from "./libs/TypeCasts.sol";
|
|
10
|
+
import {MerkleTreeManager} from "./MerkleTreeManager.sol";
|
|
11
|
+
import {IOutbox} from "../interfaces/IOutbox.sol";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @title Outbox
|
|
15
|
+
* @author Celo Labs Inc.
|
|
16
|
+
* @notice Accepts messages to be dispatched to remote chains,
|
|
17
|
+
* constructs a Merkle tree of the messages,
|
|
18
|
+
* and accepts signatures from a bonded Validator
|
|
19
|
+
* which notarize the Merkle tree roots.
|
|
20
|
+
* Accepts submissions of fraudulent signatures
|
|
21
|
+
* by the Validator and slashes the Validator in this case.
|
|
22
|
+
*/
|
|
23
|
+
contract Outbox is IOutbox, Versioned, MerkleTreeManager, Mailbox {
|
|
24
|
+
// ============ Libraries ============
|
|
25
|
+
|
|
26
|
+
using MerkleLib for MerkleLib.Tree;
|
|
27
|
+
using TypeCasts for address;
|
|
28
|
+
|
|
29
|
+
// ============ Constants ============
|
|
30
|
+
|
|
31
|
+
// Maximum bytes per message = 2 KiB
|
|
32
|
+
// (somewhat arbitrarily set to begin)
|
|
33
|
+
uint256 public constant MAX_MESSAGE_BODY_BYTES = 2 * 2**10;
|
|
34
|
+
|
|
35
|
+
// ============ Enums ============
|
|
36
|
+
|
|
37
|
+
// States:
|
|
38
|
+
// 0 - UnInitialized - before initialize function is called
|
|
39
|
+
// note: the contract is initialized at deploy time, so it should never be in this state
|
|
40
|
+
// 1 - Active - as long as the contract has not become fraudulent
|
|
41
|
+
// 2 - Failed - after a valid fraud proof has been submitted;
|
|
42
|
+
// contract will no longer accept updates or new messages
|
|
43
|
+
enum States {
|
|
44
|
+
UnInitialized,
|
|
45
|
+
Active,
|
|
46
|
+
Failed
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ============ Public Storage Variables ============
|
|
50
|
+
|
|
51
|
+
// Cached checkpoints, mapping root => leaf index.
|
|
52
|
+
// Cached checkpoints must have index > 0 as the presence of such
|
|
53
|
+
// a checkpoint cannot be distinguished from its absence.
|
|
54
|
+
mapping(bytes32 => uint256) public cachedCheckpoints;
|
|
55
|
+
// The latest cached root
|
|
56
|
+
bytes32 public latestCachedRoot;
|
|
57
|
+
// Current state of contract
|
|
58
|
+
States public state;
|
|
59
|
+
|
|
60
|
+
// ============ Upgrade Gap ============
|
|
61
|
+
|
|
62
|
+
// gap for upgrade safety
|
|
63
|
+
uint256[47] private __GAP;
|
|
64
|
+
|
|
65
|
+
// ============ Events ============
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @notice Emitted when a checkpoint is cached.
|
|
69
|
+
* @param root Merkle root
|
|
70
|
+
* @param index Leaf index
|
|
71
|
+
*/
|
|
72
|
+
event CheckpointCached(bytes32 indexed root, uint256 indexed index);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @notice Emitted when a new message is dispatched via Abacus
|
|
76
|
+
* @param leafIndex Index of message's leaf in merkle tree
|
|
77
|
+
* @param message Raw bytes of message
|
|
78
|
+
*/
|
|
79
|
+
event Dispatch(uint256 indexed leafIndex, bytes message);
|
|
80
|
+
|
|
81
|
+
event Fail();
|
|
82
|
+
|
|
83
|
+
// ============ Constructor ============
|
|
84
|
+
|
|
85
|
+
constructor(uint32 _localDomain) Mailbox(_localDomain) {} // solhint-disable-line no-empty-blocks
|
|
86
|
+
|
|
87
|
+
// ============ Initializer ============
|
|
88
|
+
|
|
89
|
+
function initialize(address _validatorManager) external initializer {
|
|
90
|
+
__Mailbox_initialize(_validatorManager);
|
|
91
|
+
state = States.Active;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ============ Modifiers ============
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @notice Ensures that contract state != FAILED when the function is called
|
|
98
|
+
*/
|
|
99
|
+
modifier notFailed() {
|
|
100
|
+
require(state != States.Failed, "failed state");
|
|
101
|
+
_;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ============ External Functions ============
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @notice Dispatch the message it to the destination domain & recipient
|
|
108
|
+
* @dev Format the message, insert its hash into Merkle tree,
|
|
109
|
+
* and emit `Dispatch` event with message information.
|
|
110
|
+
* @param _destinationDomain Domain of destination chain
|
|
111
|
+
* @param _recipientAddress Address of recipient on destination chain as bytes32
|
|
112
|
+
* @param _messageBody Raw bytes content of message
|
|
113
|
+
* @return The leaf index of the dispatched message's hash in the Merkle tree.
|
|
114
|
+
*/
|
|
115
|
+
function dispatch(
|
|
116
|
+
uint32 _destinationDomain,
|
|
117
|
+
bytes32 _recipientAddress,
|
|
118
|
+
bytes calldata _messageBody
|
|
119
|
+
) external override notFailed returns (uint256) {
|
|
120
|
+
require(_messageBody.length <= MAX_MESSAGE_BODY_BYTES, "msg too long");
|
|
121
|
+
// The leaf has not been inserted yet at this point
|
|
122
|
+
uint256 _leafIndex = count();
|
|
123
|
+
// format the message into packed bytes
|
|
124
|
+
bytes memory _message = Message.formatMessage(
|
|
125
|
+
localDomain,
|
|
126
|
+
msg.sender.addressToBytes32(),
|
|
127
|
+
_destinationDomain,
|
|
128
|
+
_recipientAddress,
|
|
129
|
+
_messageBody
|
|
130
|
+
);
|
|
131
|
+
// insert the hashed message into the Merkle tree
|
|
132
|
+
bytes32 _messageHash = keccak256(
|
|
133
|
+
abi.encodePacked(_message, _leafIndex)
|
|
134
|
+
);
|
|
135
|
+
tree.insert(_messageHash);
|
|
136
|
+
emit Dispatch(_leafIndex, _message);
|
|
137
|
+
return _leafIndex;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @notice Caches the current merkle root and index.
|
|
142
|
+
* @dev emits CheckpointCached event
|
|
143
|
+
*/
|
|
144
|
+
function cacheCheckpoint() external override notFailed {
|
|
145
|
+
(bytes32 _root, uint256 _index) = latestCheckpoint();
|
|
146
|
+
require(_index > 0, "!index");
|
|
147
|
+
cachedCheckpoints[_root] = _index;
|
|
148
|
+
latestCachedRoot = _root;
|
|
149
|
+
emit CheckpointCached(_root, _index);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @notice Set contract state to FAILED.
|
|
154
|
+
* @dev Called by the validator manager when fraud is proven.
|
|
155
|
+
*/
|
|
156
|
+
function fail() external override onlyValidatorManager {
|
|
157
|
+
// set contract to FAILED
|
|
158
|
+
state = States.Failed;
|
|
159
|
+
emit Fail();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @notice Returns the latest entry in the checkpoint cache.
|
|
164
|
+
* @return root Latest cached root
|
|
165
|
+
* @return index Latest cached index
|
|
166
|
+
*/
|
|
167
|
+
function latestCachedCheckpoint()
|
|
168
|
+
external
|
|
169
|
+
view
|
|
170
|
+
returns (bytes32 root, uint256 index)
|
|
171
|
+
{
|
|
172
|
+
root = latestCachedRoot;
|
|
173
|
+
index = cachedCheckpoints[root];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @notice Returns the number of inserted leaves in the tree
|
|
178
|
+
*/
|
|
179
|
+
function count() public view returns (uint256) {
|
|
180
|
+
return tree.count;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @notice Returns a checkpoint representing the current merkle tree.
|
|
185
|
+
* @return root The root of the Outbox's merkle tree.
|
|
186
|
+
* @return index The index of the last element in the tree.
|
|
187
|
+
*/
|
|
188
|
+
function latestCheckpoint() public view returns (bytes32, uint256) {
|
|
189
|
+
return (root(), count() - 1);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
pragma solidity >=0.6.11;
|
|
3
|
+
|
|
4
|
+
// work based on eth2 deposit contract, which is used under CC0-1.0
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @title MerkleLib
|
|
8
|
+
* @author Celo Labs Inc.
|
|
9
|
+
* @notice An incremental merkle tree modeled on the eth2 deposit contract.
|
|
10
|
+
**/
|
|
11
|
+
library MerkleLib {
|
|
12
|
+
uint256 internal constant TREE_DEPTH = 32;
|
|
13
|
+
uint256 internal constant MAX_LEAVES = 2**TREE_DEPTH - 1;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @notice Struct representing incremental merkle tree. Contains current
|
|
17
|
+
* branch and the number of inserted leaves in the tree.
|
|
18
|
+
**/
|
|
19
|
+
struct Tree {
|
|
20
|
+
bytes32[TREE_DEPTH] branch;
|
|
21
|
+
uint256 count;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @notice Inserts `_node` into merkle tree
|
|
26
|
+
* @dev Reverts if tree is full
|
|
27
|
+
* @param _node Element to insert into tree
|
|
28
|
+
**/
|
|
29
|
+
function insert(Tree storage _tree, bytes32 _node) internal {
|
|
30
|
+
require(_tree.count < MAX_LEAVES, "merkle tree full");
|
|
31
|
+
|
|
32
|
+
_tree.count += 1;
|
|
33
|
+
uint256 size = _tree.count;
|
|
34
|
+
for (uint256 i = 0; i < TREE_DEPTH; i++) {
|
|
35
|
+
if ((size & 1) == 1) {
|
|
36
|
+
_tree.branch[i] = _node;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
_node = keccak256(abi.encodePacked(_tree.branch[i], _node));
|
|
40
|
+
size /= 2;
|
|
41
|
+
}
|
|
42
|
+
// As the loop should always end prematurely with the `return` statement,
|
|
43
|
+
// this code should be unreachable. We assert `false` just to be safe.
|
|
44
|
+
assert(false);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @notice Calculates and returns`_tree`'s current root given array of zero
|
|
49
|
+
* hashes
|
|
50
|
+
* @param _zeroes Array of zero hashes
|
|
51
|
+
* @return _current Calculated root of `_tree`
|
|
52
|
+
**/
|
|
53
|
+
function rootWithCtx(Tree storage _tree, bytes32[TREE_DEPTH] memory _zeroes)
|
|
54
|
+
internal
|
|
55
|
+
view
|
|
56
|
+
returns (bytes32 _current)
|
|
57
|
+
{
|
|
58
|
+
uint256 _index = _tree.count;
|
|
59
|
+
|
|
60
|
+
for (uint256 i = 0; i < TREE_DEPTH; i++) {
|
|
61
|
+
uint256 _ithBit = (_index >> i) & 0x01;
|
|
62
|
+
bytes32 _next = _tree.branch[i];
|
|
63
|
+
if (_ithBit == 1) {
|
|
64
|
+
_current = keccak256(abi.encodePacked(_next, _current));
|
|
65
|
+
} else {
|
|
66
|
+
_current = keccak256(abi.encodePacked(_current, _zeroes[i]));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/// @notice Calculates and returns`_tree`'s current root
|
|
72
|
+
function root(Tree storage _tree) internal view returns (bytes32) {
|
|
73
|
+
return rootWithCtx(_tree, zeroHashes());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// @notice Returns array of TREE_DEPTH zero hashes
|
|
77
|
+
/// @return _zeroes Array of TREE_DEPTH zero hashes
|
|
78
|
+
function zeroHashes()
|
|
79
|
+
internal
|
|
80
|
+
pure
|
|
81
|
+
returns (bytes32[TREE_DEPTH] memory _zeroes)
|
|
82
|
+
{
|
|
83
|
+
_zeroes[0] = Z_0;
|
|
84
|
+
_zeroes[1] = Z_1;
|
|
85
|
+
_zeroes[2] = Z_2;
|
|
86
|
+
_zeroes[3] = Z_3;
|
|
87
|
+
_zeroes[4] = Z_4;
|
|
88
|
+
_zeroes[5] = Z_5;
|
|
89
|
+
_zeroes[6] = Z_6;
|
|
90
|
+
_zeroes[7] = Z_7;
|
|
91
|
+
_zeroes[8] = Z_8;
|
|
92
|
+
_zeroes[9] = Z_9;
|
|
93
|
+
_zeroes[10] = Z_10;
|
|
94
|
+
_zeroes[11] = Z_11;
|
|
95
|
+
_zeroes[12] = Z_12;
|
|
96
|
+
_zeroes[13] = Z_13;
|
|
97
|
+
_zeroes[14] = Z_14;
|
|
98
|
+
_zeroes[15] = Z_15;
|
|
99
|
+
_zeroes[16] = Z_16;
|
|
100
|
+
_zeroes[17] = Z_17;
|
|
101
|
+
_zeroes[18] = Z_18;
|
|
102
|
+
_zeroes[19] = Z_19;
|
|
103
|
+
_zeroes[20] = Z_20;
|
|
104
|
+
_zeroes[21] = Z_21;
|
|
105
|
+
_zeroes[22] = Z_22;
|
|
106
|
+
_zeroes[23] = Z_23;
|
|
107
|
+
_zeroes[24] = Z_24;
|
|
108
|
+
_zeroes[25] = Z_25;
|
|
109
|
+
_zeroes[26] = Z_26;
|
|
110
|
+
_zeroes[27] = Z_27;
|
|
111
|
+
_zeroes[28] = Z_28;
|
|
112
|
+
_zeroes[29] = Z_29;
|
|
113
|
+
_zeroes[30] = Z_30;
|
|
114
|
+
_zeroes[31] = Z_31;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @notice Calculates and returns the merkle root for the given leaf
|
|
119
|
+
* `_item`, a merkle branch, and the index of `_item` in the tree.
|
|
120
|
+
* @param _item Merkle leaf
|
|
121
|
+
* @param _branch Merkle proof
|
|
122
|
+
* @param _index Index of `_item` in tree
|
|
123
|
+
* @return _current Calculated merkle root
|
|
124
|
+
**/
|
|
125
|
+
function branchRoot(
|
|
126
|
+
bytes32 _item,
|
|
127
|
+
bytes32[TREE_DEPTH] memory _branch,
|
|
128
|
+
uint256 _index
|
|
129
|
+
) internal pure returns (bytes32 _current) {
|
|
130
|
+
_current = _item;
|
|
131
|
+
|
|
132
|
+
for (uint256 i = 0; i < TREE_DEPTH; i++) {
|
|
133
|
+
uint256 _ithBit = (_index >> i) & 0x01;
|
|
134
|
+
bytes32 _next = _branch[i];
|
|
135
|
+
if (_ithBit == 1) {
|
|
136
|
+
_current = keccak256(abi.encodePacked(_next, _current));
|
|
137
|
+
} else {
|
|
138
|
+
_current = keccak256(abi.encodePacked(_current, _next));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// keccak256 zero hashes
|
|
144
|
+
bytes32 internal constant Z_0 =
|
|
145
|
+
hex"0000000000000000000000000000000000000000000000000000000000000000";
|
|
146
|
+
bytes32 internal constant Z_1 =
|
|
147
|
+
hex"ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5";
|
|
148
|
+
bytes32 internal constant Z_2 =
|
|
149
|
+
hex"b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30";
|
|
150
|
+
bytes32 internal constant Z_3 =
|
|
151
|
+
hex"21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85";
|
|
152
|
+
bytes32 internal constant Z_4 =
|
|
153
|
+
hex"e58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a19344";
|
|
154
|
+
bytes32 internal constant Z_5 =
|
|
155
|
+
hex"0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d";
|
|
156
|
+
bytes32 internal constant Z_6 =
|
|
157
|
+
hex"887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968";
|
|
158
|
+
bytes32 internal constant Z_7 =
|
|
159
|
+
hex"ffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f83";
|
|
160
|
+
bytes32 internal constant Z_8 =
|
|
161
|
+
hex"9867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756af";
|
|
162
|
+
bytes32 internal constant Z_9 =
|
|
163
|
+
hex"cefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0";
|
|
164
|
+
bytes32 internal constant Z_10 =
|
|
165
|
+
hex"f9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5";
|
|
166
|
+
bytes32 internal constant Z_11 =
|
|
167
|
+
hex"f8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf892";
|
|
168
|
+
bytes32 internal constant Z_12 =
|
|
169
|
+
hex"3490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99c";
|
|
170
|
+
bytes32 internal constant Z_13 =
|
|
171
|
+
hex"c1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb";
|
|
172
|
+
bytes32 internal constant Z_14 =
|
|
173
|
+
hex"5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8becc";
|
|
174
|
+
bytes32 internal constant Z_15 =
|
|
175
|
+
hex"da7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d2";
|
|
176
|
+
bytes32 internal constant Z_16 =
|
|
177
|
+
hex"2733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981f";
|
|
178
|
+
bytes32 internal constant Z_17 =
|
|
179
|
+
hex"e1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a";
|
|
180
|
+
bytes32 internal constant Z_18 =
|
|
181
|
+
hex"5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0";
|
|
182
|
+
bytes32 internal constant Z_19 =
|
|
183
|
+
hex"b46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0";
|
|
184
|
+
bytes32 internal constant Z_20 =
|
|
185
|
+
hex"c65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2";
|
|
186
|
+
bytes32 internal constant Z_21 =
|
|
187
|
+
hex"f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd9";
|
|
188
|
+
bytes32 internal constant Z_22 =
|
|
189
|
+
hex"5a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e377";
|
|
190
|
+
bytes32 internal constant Z_23 =
|
|
191
|
+
hex"4df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652";
|
|
192
|
+
bytes32 internal constant Z_24 =
|
|
193
|
+
hex"cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef";
|
|
194
|
+
bytes32 internal constant Z_25 =
|
|
195
|
+
hex"0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618d";
|
|
196
|
+
bytes32 internal constant Z_26 =
|
|
197
|
+
hex"b8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0";
|
|
198
|
+
bytes32 internal constant Z_27 =
|
|
199
|
+
hex"838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e";
|
|
200
|
+
bytes32 internal constant Z_28 =
|
|
201
|
+
hex"662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e";
|
|
202
|
+
bytes32 internal constant Z_29 =
|
|
203
|
+
hex"388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea322";
|
|
204
|
+
bytes32 internal constant Z_30 =
|
|
205
|
+
hex"93237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d735";
|
|
206
|
+
bytes32 internal constant Z_31 =
|
|
207
|
+
hex"8448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a9";
|
|
208
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
pragma solidity >=0.8.0;
|
|
3
|
+
|
|
4
|
+
import {TypeCasts} from "./TypeCasts.sol";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @title Message Library
|
|
8
|
+
* @author Celo Labs Inc.
|
|
9
|
+
* @notice Library for formatted messages used by Outbox and Replica.
|
|
10
|
+
**/
|
|
11
|
+
library Message {
|
|
12
|
+
using TypeCasts for bytes32;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @notice Returns formatted (packed) message with provided fields
|
|
16
|
+
* @dev This function should only be used in memory message construction.
|
|
17
|
+
* @param _originDomain Domain of home chain
|
|
18
|
+
* @param _sender Address of sender as bytes32
|
|
19
|
+
* @param _destinationDomain Domain of destination chain
|
|
20
|
+
* @param _recipient Address of recipient on destination chain as bytes32
|
|
21
|
+
* @param _messageBody Raw bytes of message body
|
|
22
|
+
* @return Formatted message
|
|
23
|
+
**/
|
|
24
|
+
function formatMessage(
|
|
25
|
+
uint32 _originDomain,
|
|
26
|
+
bytes32 _sender,
|
|
27
|
+
uint32 _destinationDomain,
|
|
28
|
+
bytes32 _recipient,
|
|
29
|
+
bytes calldata _messageBody
|
|
30
|
+
) internal pure returns (bytes memory) {
|
|
31
|
+
return
|
|
32
|
+
abi.encodePacked(
|
|
33
|
+
_originDomain,
|
|
34
|
+
_sender,
|
|
35
|
+
_destinationDomain,
|
|
36
|
+
_recipient,
|
|
37
|
+
_messageBody
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @notice Returns leaf of formatted message with provided fields.
|
|
43
|
+
* @dev hash of abi packed message and leaf index.
|
|
44
|
+
* @param _message Raw bytes of message contents.
|
|
45
|
+
* @param _leafIndex Index of the message in the tree
|
|
46
|
+
* @return Leaf (hash) of formatted message
|
|
47
|
+
*/
|
|
48
|
+
function leaf(bytes calldata _message, uint256 _leafIndex)
|
|
49
|
+
internal
|
|
50
|
+
pure
|
|
51
|
+
returns (bytes32)
|
|
52
|
+
{
|
|
53
|
+
return keccak256(abi.encodePacked(_message, _leafIndex));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @notice Decode raw message bytes into structured message fields.
|
|
58
|
+
* @dev Efficiently slices calldata into structured message fields.
|
|
59
|
+
* @param _message Raw bytes of message contents.
|
|
60
|
+
* @return origin Domain of home chain
|
|
61
|
+
* @return sender Address of sender as bytes32
|
|
62
|
+
* @return destination Domain of destination chain
|
|
63
|
+
* @return recipient Address of recipient on destination chain as bytes32
|
|
64
|
+
* @return body Raw bytes of message body
|
|
65
|
+
*/
|
|
66
|
+
function destructure(bytes calldata _message)
|
|
67
|
+
internal
|
|
68
|
+
pure
|
|
69
|
+
returns (
|
|
70
|
+
uint32 origin,
|
|
71
|
+
bytes32 sender,
|
|
72
|
+
uint32 destination,
|
|
73
|
+
bytes32 recipient,
|
|
74
|
+
bytes calldata body
|
|
75
|
+
)
|
|
76
|
+
{
|
|
77
|
+
return (
|
|
78
|
+
uint32(bytes4(_message[0:4])),
|
|
79
|
+
bytes32(_message[4:36]),
|
|
80
|
+
uint32(bytes4(_message[36:40])),
|
|
81
|
+
bytes32(_message[40:72]),
|
|
82
|
+
bytes(_message[72:])
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @notice Decode raw message bytes into structured message fields.
|
|
88
|
+
* @dev Efficiently slices calldata into structured message fields.
|
|
89
|
+
* @param _message Raw bytes of message contents.
|
|
90
|
+
* @return origin Domain of home chain
|
|
91
|
+
* @return sender Address of sender as address (bytes20)
|
|
92
|
+
* @return destination Domain of destination chain
|
|
93
|
+
* @return recipient Address of recipient on destination chain as address (bytes20)
|
|
94
|
+
* @return body Raw bytes of message body
|
|
95
|
+
*/
|
|
96
|
+
function destructureAddresses(bytes calldata _message)
|
|
97
|
+
internal
|
|
98
|
+
pure
|
|
99
|
+
returns (
|
|
100
|
+
uint32,
|
|
101
|
+
address,
|
|
102
|
+
uint32,
|
|
103
|
+
address,
|
|
104
|
+
bytes calldata
|
|
105
|
+
)
|
|
106
|
+
{
|
|
107
|
+
(
|
|
108
|
+
uint32 _origin,
|
|
109
|
+
bytes32 _sender,
|
|
110
|
+
uint32 destination,
|
|
111
|
+
bytes32 _recipient,
|
|
112
|
+
bytes calldata body
|
|
113
|
+
) = destructure(_message);
|
|
114
|
+
return (
|
|
115
|
+
_origin,
|
|
116
|
+
_sender.bytes32ToAddress(),
|
|
117
|
+
destination,
|
|
118
|
+
_recipient.bytes32ToAddress(),
|
|
119
|
+
body
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
pragma solidity >=0.6.11;
|
|
3
|
+
|
|
4
|
+
library TypeCasts {
|
|
5
|
+
// treat it as a null-terminated string of max 32 bytes
|
|
6
|
+
function coerceString(bytes32 _buf)
|
|
7
|
+
internal
|
|
8
|
+
pure
|
|
9
|
+
returns (string memory _newStr)
|
|
10
|
+
{
|
|
11
|
+
uint8 _slen = 0;
|
|
12
|
+
while (_slen < 32 && _buf[_slen] != 0) {
|
|
13
|
+
_slen++;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// solhint-disable-next-line no-inline-assembly
|
|
17
|
+
assembly {
|
|
18
|
+
_newStr := mload(0x40)
|
|
19
|
+
mstore(0x40, add(_newStr, 0x40)) // may end up with extra
|
|
20
|
+
mstore(_newStr, _slen)
|
|
21
|
+
mstore(add(_newStr, 0x20), _buf)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// alignment preserving cast
|
|
26
|
+
function addressToBytes32(address _addr) internal pure returns (bytes32) {
|
|
27
|
+
return bytes32(uint256(uint160(_addr)));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// alignment preserving cast
|
|
31
|
+
function bytes32ToAddress(bytes32 _buf) internal pure returns (address) {
|
|
32
|
+
return address(uint160(uint256(_buf)));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {TypeCasts} from "../libs/TypeCasts.sol";
|
|
5
|
+
import {IMessageRecipient} from "../../interfaces/IMessageRecipient.sol";
|
|
6
|
+
|
|
7
|
+
contract MockInbox {
|
|
8
|
+
using TypeCasts for bytes32;
|
|
9
|
+
|
|
10
|
+
struct PendingMessage {
|
|
11
|
+
bytes32 sender;
|
|
12
|
+
bytes32 recipient;
|
|
13
|
+
bytes messageBody;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
mapping(uint256 => PendingMessage) pendingMessages;
|
|
17
|
+
uint256 totalMessages = 0;
|
|
18
|
+
uint256 messageProcessed = 0;
|
|
19
|
+
|
|
20
|
+
function addPendingMessage(
|
|
21
|
+
bytes32 _sender,
|
|
22
|
+
bytes32 _recipient,
|
|
23
|
+
bytes memory _messageBody
|
|
24
|
+
) external {
|
|
25
|
+
pendingMessages[totalMessages] = PendingMessage(
|
|
26
|
+
_sender,
|
|
27
|
+
_recipient,
|
|
28
|
+
_messageBody
|
|
29
|
+
);
|
|
30
|
+
totalMessages += 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function processNextPendingMessage() public {
|
|
34
|
+
PendingMessage memory pendingMessage = pendingMessages[
|
|
35
|
+
messageProcessed
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
address recipient = pendingMessage.recipient.bytes32ToAddress();
|
|
39
|
+
|
|
40
|
+
IMessageRecipient(recipient).handle(
|
|
41
|
+
// This is completely arbitrary and consumers should not rely
|
|
42
|
+
// on domain handling in the mock mailbox contracts.
|
|
43
|
+
1,
|
|
44
|
+
pendingMessage.sender,
|
|
45
|
+
pendingMessage.messageBody
|
|
46
|
+
);
|
|
47
|
+
messageProcessed += 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {MockInbox} from "./MockInbox.sol";
|
|
5
|
+
import {TypeCasts} from "../libs/TypeCasts.sol";
|
|
6
|
+
|
|
7
|
+
contract MockOutbox {
|
|
8
|
+
MockInbox inbox;
|
|
9
|
+
using TypeCasts for address;
|
|
10
|
+
|
|
11
|
+
constructor(address _inbox) {
|
|
12
|
+
inbox = MockInbox(_inbox);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function dispatch(
|
|
16
|
+
uint32,
|
|
17
|
+
bytes32 _recipientAddress,
|
|
18
|
+
bytes calldata _messageBody
|
|
19
|
+
) external {
|
|
20
|
+
inbox.addPendingMessage(
|
|
21
|
+
msg.sender.addressToBytes32(),
|
|
22
|
+
_recipientAddress,
|
|
23
|
+
_messageBody
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.8.0;
|
|
4
|
+
|
|
5
|
+
abstract contract MysteryMath {
|
|
6
|
+
uint256 public stateVar;
|
|
7
|
+
|
|
8
|
+
function setState(uint256 _var) external {
|
|
9
|
+
stateVar = _var;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getState() external view returns (uint256) {
|
|
13
|
+
return stateVar;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function doMath(uint256 a, uint256 b)
|
|
17
|
+
external
|
|
18
|
+
pure
|
|
19
|
+
virtual
|
|
20
|
+
returns (uint256 _result);
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.8.0;
|
|
4
|
+
|
|
5
|
+
import "./MysteryMath.sol";
|
|
6
|
+
|
|
7
|
+
contract MysteryMathV1 is MysteryMath {
|
|
8
|
+
uint32 public immutable version;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
version = 1;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function doMath(uint256 a, uint256 b)
|
|
15
|
+
external
|
|
16
|
+
pure
|
|
17
|
+
override
|
|
18
|
+
returns (uint256 _result)
|
|
19
|
+
{
|
|
20
|
+
_result = a + b;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.8.0;
|
|
4
|
+
|
|
5
|
+
import "./MysteryMath.sol";
|
|
6
|
+
|
|
7
|
+
contract MysteryMathV2 is MysteryMath {
|
|
8
|
+
uint32 public immutable version;
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
version = 2;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function doMath(uint256 a, uint256 b)
|
|
15
|
+
external
|
|
16
|
+
pure
|
|
17
|
+
override
|
|
18
|
+
returns (uint256 _result)
|
|
19
|
+
{
|
|
20
|
+
_result = a * b;
|
|
21
|
+
}
|
|
22
|
+
}
|