Commit Graph

90 Commits

Author SHA1 Message Date
derpy-duck 9e282508f7
Improve forge test coverage + Seperate tests into individual tests (#119)
* fast tests

* forge fmt

* Remove parameter from forge test generic relayer

* WIP

* WIP

* Move Forge Mock Generic Relayer to seperate file

* Split revert redelivery tests into first few seperate tests

* redelivery test changes

* WIP

* tests pass

* Redelivery tests less D.R.Y and seperated into individual tests

* Delivery tests less D.R.Y and seperated into individual tests

* Resend checks in seperate tests

* Forward test coverage!

* 100% test coverage in CoreRelayer and CoreRelayerDelivery!

* remove test coverage files

* Governance tests

* governance stack

* forge fmt

* removed console.sol
2023-03-23 14:14:48 -05:00
Joe Howarth eff19d28aa
Continuously send messages to create load (#118)
* save

* Continuously send messages to create load

* add metrics
2023-03-14 10:45:03 -07:00
derpy-duck 92dbc20c8b
Forge tests faster (#117)
* fast tests

* forge fmt

* add --via-ir to build

* remove forge test-fast; just run forge test for the same effect

* remove outdated and unused folder
2023-03-10 10:41:12 -05:00
derpy-duck db355a2f1d
Revert if delivery address is 0, and add forge tests testing this (#115)
* Revert if delivery address is 0, and add forge tests testing this

* Test passes
2023-03-02 13:37:12 -05:00
derpy-duck 27cbbc7804 forge fmt' 2023-03-02 10:02:46 -05:00
derpy-duck 81cb32981a Nice CoreRelayerDelivery comments 2023-03-02 10:02:46 -05:00
derpy-duck dab942c980 WIP 2023-03-02 10:02:46 -05:00
derpy-duck c2117b6ef1 deliverSingle is nice 2023-03-02 10:02:46 -05:00
derpy-duck 6fee6ba1e4
Nice comments in the code (#111)
* resend doesn't take nonce as parameter

* Replace 'delivery failure' with 'receiver failure' in specs

* helper send method

* Fix interface to match not having nonce for resend

* Fix forge tests to not have nonce as a parameter

* fix redeliveryTest

* Split CoreRelayer into CoreRelayer and CoreRelayerDelivery

* fix build error

* forge fmt

* fix interface of getdefaultrelayprovider

* Nice comments for main functions in CoreRelayer.sol

* Nice comments for CoreRelayerMessages

* forge fmt

* merge

* Removes wormholeMessageFee from storage to avoid excessive gas costs.

---------

Co-authored-by: Sebastián Claudio Nale <sebinale@gmail.com>
2023-02-28 10:09:01 -05:00
Sebastián Nale a292dc253d Adds `AssetConversion` struct to avoid multiple reads or stores. 2023-02-27 21:20:51 -03:00
derpy-duck 7b384caadc
Remove TODO comment, correct 10^-6 (#108) 2023-02-27 18:49:58 -05:00
derpy-duck 7416880825
Miscellaneous fixes (#104)
* resend doesn't take nonce as parameter

* Replace 'delivery failure' with 'receiver failure' in specs

* helper send method

* Fix interface to match not having nonce for resend

* Fix forge tests to not have nonce as a parameter

* fix redeliveryTest

* fix build error

* forge fmt

* fix interface of getdefaultrelayprovider
2023-02-27 18:49:38 -05:00
scnale 24d682bca4
Mark assembly as `memory safe` (#107)
* Adds `memory-safe` tag to assembly sections in `BytesLib`.

This improves codegen in the compiler and reduces the chance of
untraceable internal codegen errors when dealing with stack variables
that can't be referenced with an instruction.

Also, it removes unused functions in `BytesLib` to reduce code surface.

* Renames functions and contracts in reentrancy negative test.

* Adds `unchecked` block for overflow check.
2023-02-27 15:59:00 -07:00
derpy-duck f7de3d649d
Code cleanup (#109)
* DRY: Remove duplicate structs

* Move encode/decode/convert-request-to-instruction related files to CoreRelayerMessages

* remove rolloverchain; now it is just the chain of the first request

* forge test fix to accomdoate for removing two getters

* DRY: Remove repeated error messages

* Remove miscellaneous comments

* DRY send and forward

* replace relayprovider interface with address to match the IWormholeRelayer interface

* forge fmt

* Remove byteslib from CoreRelayer

* Remove the encoding and decoding of the delivery request -> just store the struct itself!

* forge fmt

* Rewriting of checks in send/resend/forward

* test passes

* DRY - Emit only one event

* DRY

* forge fmt

* Fix typescript error

* using IWormholeRelayer

* Consistent naming

* call wormhole.messageFee() once

* Remove unnecessary line

* Compute the length once, not every iteration

* forge tests pass
2023-02-27 14:32:57 -05:00
Sebastián Claudio Nale 004e1b3059 `forge fmt` run. 2023-02-21 12:56:07 -03:00
Sebastián Claudio Nale 01bd5540a1 Reuse `wormhole()` and `wormhole.messageFee()` expressions. 2023-02-21 12:56:07 -03:00
Sebastián Claudio Nale 315f0909c7 Comment a couple of optimization opportunities. 2023-02-21 12:56:07 -03:00
Sebastián Claudio Nale a2bdeaffea Optimize `convertToEncodedRedeliveryByTxHashInstruction`.
This reduces code size and gas used.
2023-02-21 12:56:07 -03:00
Sebastián Claudio Nale a2bca1782c Optimize `appendDeliveryInstruction`.
This simplification allows the compiler to emit less code.
2023-02-21 12:56:07 -03:00
Sebastián Claudio Nale 958d964ad5 Avoid call if the value sent is zero. 2023-02-21 12:56:07 -03:00
Sebastián Claudio Nale a5427bb177 Make refund and reward addresses `payable`. 2023-02-21 12:56:07 -03:00
Sebastián Claudio Nale 9acc9fcbd6 Cleans up `validateRedeliverySingle`. 2023-02-21 12:56:07 -03:00
Sebastián Claudio Nale 1003717cdb Adds `receive()` function in `MockRelayerIntegration`. 2023-02-21 12:43:33 -03:00
Sebastián Claudio Nale 3f713d7efc Adds `MockWormhole` contract for unit tests.
Also adds a `WormholeSimulator` interface for signing and non-signing
mocks. The signing mock can be useful when writing a test for a
specific testnet fork with a real wormhole deployment. In the unit tests,
only the non signing mock is used.
2023-02-21 12:43:33 -03:00
derpy-duck 45021b4691 forge fmt 2023-02-21 10:43:13 -05:00
derpy-duck a7bda1a057 Nice specs for IWormholeRelayer 2023-02-21 10:43:13 -05:00
Sebastián Claudio Nale 1cae1ba324 Fixes relayer reward to take into account forward publish fee. 2023-02-17 19:57:28 -03:00
Sebastián Claudio Nale 0b10f9e2a5 Puts enum type in the `Delivery` event. 2023-02-17 19:54:26 -03:00
Sebastián Claudio Nale f7174f2084 Adds named parameters to `Delivery` events. 2023-02-17 19:54:26 -03:00
Sebastián Claudio Nale eced885877 `forge fmt` run. 2023-02-17 19:54:26 -03:00
Sebastián Claudio Nale a41490cc38 Uses `abi.encodeCall` to typecheck some encoded calls. 2023-02-17 19:54:26 -03:00
derpy-duck 785ba82080 Revert "Adds `memory-safe` tag to assembly sections in `BytesLib`."
This reverts commit 2cbbf25d74.
2023-02-14 14:08:21 -05:00
derpy-duck b803184a8d forge fmt 2023-02-14 14:08:21 -05:00
derpy-duck 46d276e37e Rebase completed! 2023-02-14 14:08:21 -05:00
derpy-duck f5c1fe3a7b Multidelivery, forwarding tests work + Relayer engine fix! 2023-02-14 14:08:21 -05:00
derpy-duck 249145af86 Forwarding test passes! 2023-02-14 14:08:21 -05:00
derpy-duck 1401c88038 forge fmt 2023-02-14 14:08:21 -05:00
derpy-duck 7d9012660e Remove overload in MockRelayerIntegration 2023-02-14 14:08:21 -05:00
derpy-duck 69b476646d fix typescript errors pt 1 2023-02-14 14:08:21 -05:00
derpy-duck d157e1fe0f New MockRelayerIntegration contract, and modified forge tests to still pass! (literal hours of debugging :'( ) 2023-02-14 14:08:21 -05:00
scnale 0f7c0a0c69 Negative test for a reentrant attack on the core relayer forward mechanism (#83)
* Modifies the relayer simulation to be easier to use in negative tests.

* Adds negative test for a reentrancy attack on the forward mechanism.

* `forge fmt` run.
2023-02-14 14:08:21 -05:00
Sebastián Claudio Nale 302a0e07fe Adds `memory-safe` tag to assembly sections in `BytesLib`.
This improves codegen in the compiler and reduces the chance of
untraceable internal codegen errors when dealing with stack variables
that can't be referenced with an instruction.
2023-02-14 14:08:21 -05:00
derpy-duck 991e88eac2 Bugfixes 2023-02-14 14:08:21 -05:00
derpy-duck 4e05c4a007 work in progress for editing mockrelayintegration 2023-02-14 14:08:21 -05:00
derpy-duck ba8a09d6f7
save target address in state and use it to verify forwarding request (#75)
* save target address in state and use it to verify forwarding request

* Fix to Multideliveries/Multiforwards

* complete merge
2023-02-14 10:33:55 -05:00
derpy-duck e8637b2b01 Remove unused error messages 2023-02-13 17:13:42 -05:00
derpy-duck 346df2e017 Most forge tests pass 2023-02-13 17:13:42 -05:00
derpy-duck 1f69c238d7 forge builds! 2023-02-13 17:13:42 -05:00
chase-45 67ff0b3baa interface refinement 2023-02-13 17:13:42 -05:00
derpy-duck e3c4ea0088
Add error messages to interface (#80)
* Add error messages to interface

* Make getDefaultRelayProvider view
2023-02-07 16:43:32 -05:00