Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(callbacks): adr8 implementation #3939

Merged
merged 365 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
365 commits
Select commit Hold shift + click to select a range
59d7aac
imp(callbacks.test): added 'TestUnmarshalPacketData'
srdtrk Jul 11, 2023
8e2474c
docs(callbacks): simapp comment for callback stacks updated
srdtrk Jul 11, 2023
d94fd69
imp(callbacks.test): added 'TestOnChanCloseInit'
srdtrk Jul 11, 2023
1dffefc
fix(simapp): passed feeKeeper as channel keeper to callbacks middleware
srdtrk Jul 11, 2023
bc2f7be
imp(callbacks.test): added 'TestSendPacket'
srdtrk Jul 11, 2023
b1a9ca0
imp(callbacks.test): added TestWriteAcknowledgement
srdtrk Jul 11, 2023
4523c48
imp(callbacks.test): added 'TestOnChanCloseConfirm'
srdtrk Jul 11, 2023
fcad9a6
imp(callbacks.test): added 'TestOnAcknowledgementPacketError'
srdtrk Jul 11, 2023
fd57484
imp(callbacks.test): added 'TestOnTimeoutPacketError'
srdtrk Jul 11, 2023
049df73
imp(callbacks.test): added export_test.go
srdtrk Jul 12, 2023
8f2e40e
imp(callbacks.test): added 'TestProcessCallbackDataGetterError'
srdtrk Jul 12, 2023
7ed98a9
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 12, 2023
5f34afb
imp(callbacks.test): added events tests
srdtrk Jul 12, 2023
2a07dc2
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 12, 2023
ddbfd78
imp(callbacks): using PacketDataUnmarshaler to unmarshal instead of t…
srdtrk Jul 12, 2023
a63277a
imp(callbacks): updated the api of getCallbackData functions
srdtrk Jul 12, 2023
aaf99be
imp(callbacks): added TestGetSourceCallbackDataTransfer and TestGetDe…
srdtrk Jul 12, 2023
bb7ee1d
imp(callbacks.test): added export_test for type tests
srdtrk Jul 12, 2023
b9c35b9
imp(callbacks.test): added 'TestGetCallbackDataErrors'
srdtrk Jul 12, 2023
8f19753
imp(fee_test): added 'TestUnmarshalPacketDataError'
srdtrk Jul 12, 2023
70b7a5c
style(adr8): renamed the contract api functions
srdtrk Jul 12, 2023
26d707c
feat(callbacks.test): added incentivized transfer tests
srdtrk Jul 12, 2023
decbae9
imp(callbacks_test): added timeout test case to fee test
srdtrk Jul 12, 2023
d6b8787
style(ica.adr8): updated godocs
srdtrk Jul 12, 2023
835feb0
style(ica.adr8): updated godocs
srdtrk Jul 12, 2023
9090524
feat(adr8): replaced PacketDataUnmarshaller with PacketInfoProvider
srdtrk Jul 13, 2023
58b27ab
imp(callbacks): added sender and receiver addresses to ContractKeeper…
srdtrk Jul 13, 2023
b55be0d
docs(ica): godocs updated
srdtrk Jul 13, 2023
b8c60f7
style(adr8): renamed PacketDataUnmarshaler to PacketInfoProvider
srdtrk Jul 13, 2023
ca20778
style(callbacks): renamed channel to ics4Wrapper
srdtrk Jul 13, 2023
08308b6
docs(callbacks): updated godocs
srdtrk Jul 13, 2023
e244013
imp(adr8_test): tested new GetPacketSender and GetPacketReceiver inte…
srdtrk Jul 13, 2023
5bf8c99
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 13, 2023
8c9d49e
feat(adr8): added IBCSendPacketCallback to ContractKeeper
srdtrk Jul 13, 2023
c7e55b3
imp(testing/mock): added callback counter helpers
srdtrk Jul 13, 2023
4a90b24
imp(ica, transfer): added WithICS4Wrapper api function
srdtrk Jul 13, 2023
2e1bcf2
feat(callbacks_test): SendPacket tests are now passing
srdtrk Jul 14, 2023
5a1782c
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 14, 2023
c42d7e1
imp(fee_test): added more tests to TestPacketInfoProviderInterfaceError
srdtrk Jul 14, 2023
7d7b0d8
style(callbacks): renamed PacketUnmarshalerIBCModule to PacketInfoPro…
srdtrk Jul 14, 2023
f0a3829
feat(callbacks): added maxGas param to middleware
srdtrk Jul 14, 2023
bf60673
fix(callbacks): fixed SendPacket
srdtrk Jul 14, 2023
dd3dac6
feat(callbacks): implemented WriteAcknowledgement callbacks
srdtrk Jul 14, 2023
95e210f
style(mock): updated the name of callback counter
srdtrk Jul 14, 2023
2c53939
fix(callbacks): fixed using channelID instead of portID
srdtrk Jul 14, 2023
43c74da
feat(callbacks): all acknowledgements implemented
srdtrk Jul 17, 2023
594aa55
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 17, 2023
6362719
style(ica.adr8): used more consistent formating in ica and transfer
srdtrk Jul 17, 2023
55ad7a9
docs(ica, transfer): updated 'WithICS4Wrapper's godocs
srdtrk Jul 17, 2023
31417f1
imp(callbacks_test): improved WriteAcknowledgement tests
srdtrk Jul 17, 2023
1509448
tests(mock, callbacks): moved mock PacketUnmarshaller logic to mock m…
srdtrk Jul 17, 2023
ec51b71
tests(callbacks): added mock async ack test
srdtrk Jul 17, 2023
8f95493
ci: CODEOWNERS updated to include callbacks
srdtrk Jul 17, 2023
46b59b8
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 17, 2023
c4267eb
docs(callbacks_test): updated godocs
srdtrk Jul 17, 2023
0f3c66a
imp(callbacks): only handling oog panic in recovery now
srdtrk Jul 17, 2023
86942b6
style(callbacks): fix variable name
srdtrk Jul 17, 2023
7d46a3f
imp(mock): mock panic is now a real oog panic
srdtrk Jul 17, 2023
1c3dd89
tests(adr8): added state reversal test
srdtrk Jul 17, 2023
8b9e373
style(callbacks): renamed hasEnoughGas to remainingGasIsAtGasLimit
srdtrk Jul 18, 2023
db10c16
tests(adr8): moved panic and error treshold to 400k and 500k gas resp…
srdtrk Jul 18, 2023
68dee6b
fix(callbacks): fixed panic handling
srdtrk Jul 18, 2023
4c30873
imp(callbacks_test): added a low relayer gas test
srdtrk Jul 18, 2023
7f11ee8
fix(transfer_test.adr8): fixed a typo in a test case
srdtrk Jul 18, 2023
38184e6
docs(callbacks): improved godocs
srdtrk Jul 18, 2023
69fcf65
imp(callbacks): added CommitGasLimit to CallbackData for events
srdtrk Jul 18, 2023
c1307ec
imp(callbacks): AttributeKeyCallbackCommitGasLimit added to events
srdtrk Jul 18, 2023
c2f168b
fix(callbacks): fixed major gas panic issue
srdtrk Jul 18, 2023
71b1e3e
imp(callbacks_test): improved the oog panic test
srdtrk Jul 18, 2023
8f6f576
style(callbacks): used '.GetData()' instead of '.Data'
srdtrk Jul 19, 2023
d0aa099
docs(adr8): updated some godocs
srdtrk Jul 19, 2023
33f2ed0
style(ica/host_test): fixed test case memo styling
srdtrk Jul 19, 2023
8f310a5
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 19, 2023
5e86213
style(ica/controller): docs and style fixes
srdtrk Jul 20, 2023
0f65c26
imp(ica/host): adr8 removed from icahost
srdtrk Jul 20, 2023
e96b5f3
docs(adr8): updated godocs for withics4wrapper
srdtrk Jul 20, 2023
04dda1e
docs(adr8): updated godocs for gasLimit specs
srdtrk Jul 20, 2023
34ce83d
style(adr8_test): fixed test case naming
srdtrk Jul 20, 2023
35dc6b2
docs(adr8): updated godocs for some interface functions
srdtrk Jul 20, 2023
89f1bf2
style(fee.adr8): renamed unmarshaler to provider in some cases
srdtrk Jul 20, 2023
38368e8
imp(adr8_test): improved mock unmarshaler
srdtrk Jul 20, 2023
b8562a0
docs(transfer.adr8): updated godocs
srdtrk Jul 20, 2023
9e1834a
docs(adr8): updated godocs
srdtrk Jul 20, 2023
ffc51a3
docs(adr8): updated godocs
srdtrk Jul 20, 2023
1633631
docs(callbacks): updated godocs
srdtrk Jul 20, 2023
bcabe69
style(callbacks): moved SendPacket func to top
srdtrk Jul 20, 2023
46b7642
docs(callbacks): updated godocs
srdtrk Jul 20, 2023
3c046db
imp(callbacks): logging to debug instead of info
srdtrk Jul 20, 2023
a2bf305
style(callbacks): renamed remainingGasIsAtGasLimit -> commitTxIfOutOfGas
srdtrk Jul 20, 2023
7009e86
docs(callbacks): updated godocs
srdtrk Jul 20, 2023
9fbf5dc
docs(callbacks): updated event docs
srdtrk Jul 20, 2023
ad56b17
fix(callbacks): added CallbackTypeSendPacket to events
srdtrk Jul 20, 2023
c7ee59a
imp(callbacks): events emit port and channel id based on src vs dest
srdtrk Jul 20, 2023
7eeabfd
docs(callbacks): updated godocs
srdtrk Jul 20, 2023
bf73815
imp(callbacks): changed some event to a log
srdtrk Jul 20, 2023
aa70889
imp(callbacks): improved log
srdtrk Jul 20, 2023
e1e2b7f
docs(callbacks): updated godocs
srdtrk Jul 20, 2023
9504df6
imp(callbacks): unsuccessful ack now bypasses callback in 'OnRecvPacket'
srdtrk Jul 20, 2023
063c682
imp(callbacks_test): added mock logger
srdtrk Jul 20, 2023
c55051c
imp(mock): created mock logger
srdtrk Jul 20, 2023
005ab70
style: ran 'golangci-lint run --fix'
srdtrk Jul 20, 2023
7d582c5
style(callbacks): made code more concise
srdtrk Jul 20, 2023
8a5e94b
style(callbacks): renamed PacketInfoProviderIBCModule to CallbacksCom…
srdtrk Jul 20, 2023
6249fb1
style(callbacks): improved they style of getCallbackData and negated …
srdtrk Jul 20, 2023
ee8f647
style(callbacks): used constants for 'success' and 'failure' attributes
srdtrk Jul 20, 2023
dcc6109
docs(adr8): updated godocs
srdtrk Jul 20, 2023
23c977c
style(ica/controller): added more explicit prefix check
srdtrk Jul 20, 2023
814aa6d
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 20, 2023
98ef145
imp(adr8): moved 'GetPacketSender' and 'GetPacketReceiver' to 'Callba…
srdtrk Jul 21, 2023
7e55af8
style(adr8): renamed PacketInfoProvider to PacketDataUnmarshaler
srdtrk Jul 21, 2023
f6edd8f
imp(callbacks_test): switched hostStack for controllerStack
srdtrk Jul 21, 2023
45914c0
imp(callbacks_test): added missing test case
srdtrk Jul 21, 2023
b7209fb
imp(callbacks): callbacks can now reject SendPacket
srdtrk Jul 21, 2023
7d7f4b3
imp(callbacks_test): added TestSendPacketReject
srdtrk Jul 21, 2023
0cf5b18
style(callbacks_test): using TestCoin instead
srdtrk Jul 21, 2023
db0c3d8
imp(callbacks_test): added TestWriteAcknowledgementOogError and TestO…
srdtrk Jul 21, 2023
d8f8c95
imp(callbacks_test): added TestOnAcknowledgementPacketOogError
srdtrk Jul 21, 2023
7f0d73c
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 21, 2023
13e4e2a
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 25, 2023
117728b
imp(adr8): removed packetReceiver concept
srdtrk Jul 25, 2023
75b65e6
imp(adr8): removed srcChannelID from GetPacketSender interface
srdtrk Jul 25, 2023
18b1997
imp(callbacks): oogError is now simply oogPanic
srdtrk Jul 25, 2023
7dcf002
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 25, 2023
604d92e
imp(callbacks): added more mw initialization notnil checks
srdtrk Jul 25, 2023
1d6bf31
docs(callbacks): updated godocs
srdtrk Jul 26, 2023
70567b3
feat(adr8): moved adr8 logic to callbacks middleware
srdtrk Jul 26, 2023
d36d115
style(callbacks): replaced AuthAddr -> SenderAddr
srdtrk Jul 26, 2023
ca991cd
imp(callbacks_test): increased codecov
srdtrk Jul 26, 2023
fb8625d
docs(adr8): improved some godocs around AdditionalPacketDataProvider …
srdtrk Jul 26, 2023
df722d8
revert(docs): reverted changes to adr8 specs, this needs a seperate PR
srdtrk Jul 26, 2023
f8b105a
imp(callbacks_test): improved tests slightly
srdtrk Jul 26, 2023
cf3d6e2
docs(callbacks): improved godocs for keys.go
srdtrk Jul 26, 2023
3af92d4
docs(mock.adr8): updated godocs for mock logger
srdtrk Jul 26, 2023
a31a348
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 28, 2023
9d74ab9
imp(adr8): changed GetAdditionalData function signature
srdtrk Jul 28, 2023
58a6227
imp(callbacks): split AdditionalPacketDataProvider into two interfaces
srdtrk Jul 28, 2023
caf51e9
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 28, 2023
85eb9fa
merge: branch 'main' into serdar/adr8-middleware
srdtrk Jul 28, 2023
609df9e
style(mock): used interface impl convention
srdtrk Jul 28, 2023
f60594f
tests: removed ErrorMock
srdtrk Jul 28, 2023
86449c6
style(callbacks_test): improved test style
srdtrk Jul 28, 2023
44649b1
style(callbacks_test): improved test name
srdtrk Jul 28, 2023
3db7f89
style(core, apps): renamed PacketSenderRetriever to PacketData
srdtrk Jul 28, 2023
996ad31
merge: branch 'main' into serdar/adr8-middleware
srdtrk Aug 1, 2023
3fa67ec
style(adr8): conforming to revive linter
srdtrk Aug 1, 2023
e0a1593
fix(transfer_test, ica/controller_test): fixed failing tests
srdtrk Aug 1, 2023
b8afa0b
style: conforming to revive linter
srdtrk Aug 1, 2023
6c9233c
merge: branch 'main' into serdar/adr8-middleware
srdtrk Aug 2, 2023
10e4990
nit(ica): removed uneeded diffs
srdtrk Aug 2, 2023
bbb4994
merge: branch 'main' into serdar/adr8-middleware
srdtrk Aug 3, 2023
5e46fa4
style(callbacks): some style updates
srdtrk Aug 3, 2023
72c2041
docs(callbacks): updated godocs
srdtrk Aug 3, 2023
5972db1
imp(callbacks): added 'WithICS4Wrapper'
srdtrk Aug 4, 2023
565f9da
style(callbacks): rename GasLimit -> ExecutionGasLimit
srdtrk Aug 4, 2023
9e22b74
imp(callbacks): allowRetry was removed
srdtrk Aug 4, 2023
78ec500
style(callbacks): moved callbackAddr code block above gas logic
srdtrk Aug 4, 2023
0e354f2
style(callbacks): renamed ContractAddr,SenderAddr ->
srdtrk Aug 4, 2023
997c086
style(callbacks): updated godocs and var names for keys and errors
srdtrk Aug 4, 2023
50898c5
docs(callbacks): updated godocs for contract keeper
srdtrk Aug 4, 2023
aae1ab4
test: remove unnecessary code
colin-axner Aug 7, 2023
c76bc4a
test: apply review code suggestions
colin-axner Aug 7, 2023
202445b
test: move SendPacket test up in layout
colin-axner Aug 7, 2023
b91b6c6
refactor: panic with errors in NewIBCMiddleware
damiannolan Aug 7, 2023
b54318d
test: refactor TestWithICS4Wrapper to simplify and reduce LOC
damiannolan Aug 7, 2023
1de0dc4
chore: rm mock logger and usage in tests
damiannolan Aug 7, 2023
810f595
nit: explicitly return 0 sequence when error is not nil
damiannolan Aug 7, 2023
fee8533
lint: make use of unused test var maxCallbackGas
damiannolan Aug 7, 2023
10db12e
merge: branch 'main' into serdar/adr8-middleware
srdtrk Aug 8, 2023
7c75b51
imp(callbacks): reduced case logic for eventTrigger
srdtrk Aug 8, 2023
2d59da4
style(callbacks): improved event keys
srdtrk Aug 8, 2023
5dffa43
refactor(callbacks): refactored gas logic
srdtrk Aug 8, 2023
a926b02
imp(callbacks): empty address returns an error now
srdtrk Aug 8, 2023
d13eece
style(callbacks): styled function arguments
srdtrk Aug 8, 2023
e0c2f33
refactor: simplify testing setup for callbacks
colin-axner Aug 8, 2023
c093b0e
Merge branch 'serdar/adr8-middleware' of github.com:cosmos/ibc-go int…
colin-axner Aug 8, 2023
59d5333
rename: mock's keeper.go to contract_keeper.go
colin-axner Aug 8, 2023
b33d903
refactor: remove mock keeper, use only mock contract keeper
colin-axner Aug 8, 2023
6a04c2c
rename: StateCounter -> StateEntryCounter
colin-axner Aug 8, 2023
62747d7
nit: simapp in-code docs
colin-axner Aug 8, 2023
e817dbc
merge: remote-tracking branch 'origin/serdar/adr8-middleware' into se…
srdtrk Aug 8, 2023
a04197c
refactor: simplify mock contract keeper process callback
colin-axner Aug 8, 2023
85eafff
test: remove unnecessary test cases in transfer/fee integration tests
colin-axner Aug 8, 2023
de5c1ec
merge: remote-tracking branch 'origin/serdar/adr8-middleware' into se…
srdtrk Aug 9, 2023
39622c0
imp(callbacks): moved 'callbackDataGetter' logic up a level
srdtrk Aug 9, 2023
ee928ea
merge: branch 'main' into serdar/adr8-middleware
srdtrk Aug 9, 2023
a18c877
refactor(callbacks): moved emit event logic up a level
srdtrk Aug 9, 2023
0f6dd17
style(callbacks): styled function arguments
srdtrk Aug 9, 2023
15f9187
docs(callbacks): improved godocs of contract keeper
srdtrk Aug 9, 2023
e534ac1
style: renamed CallbackTypeAcknowledgement -> CallbackTypeAcknowledge…
srdtrk Aug 9, 2023
68fc17a
docs(callbacks): fixed events godocs
srdtrk Aug 9, 2023
cb77b3f
style(callbacks_test): fixed typo
srdtrk Aug 9, 2023
3359e11
style(callbacks): rename timeout -> timeout_packet
srdtrk Aug 9, 2023
e044eff
style(callbacks): rename ContractAddress -> CallbackAddress
srdtrk Aug 9, 2023
54f9c9b
imp(callbacks): don't handle panics for SendPacket
srdtrk Aug 9, 2023
5d7c1cd
style: renamed CallbackTypeWriteAcknowledgement -> CallbackTypeReceiv…
srdtrk Aug 9, 2023
b53514f
style: renamed CallbackType -> CallbackTrigger
srdtrk Aug 9, 2023
87364c6
style(callbacks_test): fixed typo in test case
srdtrk Aug 9, 2023
b093f53
docs(mock.adr8): updated godocs of contract keeper
srdtrk Aug 9, 2023
7964e5c
imp(callbacks): moved logging after possible retry
srdtrk Aug 9, 2023
b0ce5e4
style(callbacks): renamed function argument callbackType -> callbackT…
srdtrk Aug 9, 2023
b215102
imp(callbacks): fixed logger name
srdtrk Aug 9, 2023
c6b603d
imp(callbacks): 'LogDebugWithPacket' added
srdtrk Aug 9, 2023
124640c
refactor(ibc_middleware_test): turn SendPacket into table test
colin-axner Aug 9, 2023
c2d1cb4
test: add test cases for SendPacket table test
colin-axner Aug 9, 2023
f9fe981
refactor(ibc_middleware_test): turn OnAcknowledgementPacket tests int…
colin-axner Aug 9, 2023
848a6d2
test(OnAcknowledgement): add counter and state entry checks
colin-axner Aug 9, 2023
be5813c
merge: remote-tracking branch 'origin/serdar/adr8-middleware' into se…
srdtrk Aug 9, 2023
59209ad
test(ica_test): remove duplicate tests
colin-axner Aug 9, 2023
a7a48ea
testing: fix usage on TimeoutPacket to use counterparty portID/channe…
colin-axner Aug 9, 2023
fa1c993
test(ica_test): simplify timeout logic
colin-axner Aug 9, 2023
5b14987
merge: remote-tracking branch 'origin/serdar/adr8-middleware' into se…
srdtrk Aug 9, 2023
8f7c92e
Merge branch 'main' into serdar/adr8-middleware
colin-axner Aug 9, 2023
da93f5b
test(types/callback_test.go): remove unused testing bool
colin-axner Aug 9, 2023
df6d28d
Merge branch 'serdar/adr8-middleware' of github.com:cosmos/ibc-go int…
colin-axner Aug 9, 2023
f051f9a
merge: remote-tracking branch 'origin/serdar/adr8-middleware' into se…
srdtrk Aug 9, 2023
8a4fb50
style: ran golangci-lint
srdtrk Aug 9, 2023
4b54677
style: renamed CallbackTrigger -> CallbackType
srdtrk Aug 9, 2023
dc325ed
refactor(ibc_middleware_test): turn OnTimeout into a table test
colin-axner Aug 9, 2023
c008f50
Merge branch 'serdar/adr8-middleware' of github.com:cosmos/ibc-go int…
colin-axner Aug 9, 2023
ba0adf0
refactor(ibc_middleware_test): turn OnRecvPacket into a table test
colin-axner Aug 9, 2023
6ab4d2a
style(callbacks_test): added nolint comments
srdtrk Aug 9, 2023
82c83b2
style(callbacks_test): fixed some typos
srdtrk Aug 9, 2023
7df0085
imp(callbacks_test): added table tests for WriteAcknowledgement'
srdtrk Aug 9, 2023
c4905ca
imp(callbacks_test): removed dest_callback test cases for ica as it i…
srdtrk Aug 10, 2023
47fb2d9
fix(callbacks): fixed send_packet panic handling
srdtrk Aug 10, 2023
be12942
fix(callbacks_test): fix failing tests due to SendPacket panic
srdtrk Aug 10, 2023
4fa945b
imp(callbacks): added 'AllowRetry' function
srdtrk Aug 10, 2023
773c0e3
imp(callbacks): processCallback panic recovery logic is simplified
srdtrk Aug 10, 2023
d78ccb8
style(callbacks): updated style of the comment
srdtrk Aug 10, 2023
aee07af
fix(callbacks_test): removed potential premature return
srdtrk Aug 10, 2023
71d5151
docs(callbacks_test): updated inline comment
srdtrk Aug 10, 2023
e133673
imp(callbacks_test): 'TestProcessCallback' added
srdtrk Aug 10, 2023
8f741b0
imp(callbacks): upgraded the panic on timeout logic
srdtrk Aug 10, 2023
d45ae4a
docs(callbacks): added inline comments
srdtrk Aug 10, 2023
5c4703d
merge: branch 'main' into serdar/adr8-middleware
srdtrk Aug 11, 2023
28ac059
imp(callbacks): removed 'LogDebugWithPacket'
srdtrk Aug 11, 2023
1ea7c0d
docs(callbacks): updated godocs and inline comments
srdtrk Aug 11, 2023
01483b1
imp(callbacks): prevent maxCallbackGas from being 0
srdtrk Aug 13, 2023
836d513
imp(callbacks): removed logger
srdtrk Aug 13, 2023
fb156d7
imp(callbacks): added 'ErrCannotUnmarshalPacketData'
srdtrk Aug 13, 2023
57b428a
imp(callbacks_test): created ''TestGetCallbackData
srdtrk Aug 13, 2023
ef639eb
imp(callbacks_test): improved 'TestNewIBCMiddleware'
srdtrk Aug 13, 2023
9558877
imp(callbacks): issue#4323 - add strings.Trimspace
srdtrk Aug 13, 2023
1058d45
docs(callbacks): issue#4325 - inline comment added for explaining why…
srdtrk Aug 13, 2023
70962fe
style(callbacks): passing nil instead of err to events in SendPacket
srdtrk Aug 13, 2023
9a09845
docs(callbacks): issue#4325 - added inline comments explaining why so…
srdtrk Aug 13, 2023
a168006
imp(callbacks_test): added test cases for '0' user defined gas limit
srdtrk Aug 13, 2023
867d9a4
merge: branch 'main' into serdar/adr8-middleware
srdtrk Aug 14, 2023
4e6bc61
imp(simapp): removed unneeded comment
srdtrk Aug 14, 2023
3073c93
imp(callbacks_test): using testAccAddress for transfer tests now
srdtrk Aug 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@

# CODEOWNERS for docs
/docs/ @colin-axner @AdityaSripal @crodriguezvega @charleenfei @damiannolan @chatton @DimitrisJim @srdtrk

# CODEOWNERS for callbacks middleware

/modules/apps/callbacks/ @colin-axner @AdityaSripal @damiannolan @srdtrk
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
controllerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper"
"github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
fee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
host "github.com/cosmos/ibc-go/v7/modules/core/24-host"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
)
Expand Down Expand Up @@ -836,7 +836,7 @@ func (suite *InterchainAccountsTestSuite) TestGetAppVersion() {
cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

controllerStack := cbs.(fee.IBCMiddleware)
controllerStack := cbs.(porttypes.Middleware)
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
appVersion, found := controllerStack.GetAppVersion(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
suite.Require().True(found)
suite.Require().Equal(path.EndpointA.ChannelConfig.Version, appVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
genesistypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/genesis/types"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper"
channelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
Expand Down Expand Up @@ -298,11 +297,9 @@ func (suite *KeeperTestSuite) TestGetAuthority() {
func (suite *KeeperTestSuite) TestWithICS4Wrapper() {
suite.SetupTest()

// test if the ics4 wrapper is the fee keeper initially
// test if the ics4 wrapper is the channel keeper initially
ics4Wrapper := suite.chainA.GetSimApp().ICAControllerKeeper.GetICS4Wrapper()

_, isFeeKeeper := ics4Wrapper.(ibcfeekeeper.Keeper)
suite.Require().True(isFeeKeeper)
_, isChannelKeeper := ics4Wrapper.(channelkeeper.Keeper)
suite.Require().False(isChannelKeeper)

Expand All @@ -312,6 +309,4 @@ func (suite *KeeperTestSuite) TestWithICS4Wrapper() {

_, isChannelKeeper = ics4Wrapper.(channelkeeper.Keeper)
suite.Require().True(isChannelKeeper)
_, isFeeKeeper = ics4Wrapper.(ibcfeekeeper.Keeper)
suite.Require().False(isFeeKeeper)
}
2 changes: 1 addition & 1 deletion modules/apps/29-fee/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ func (suite *FeeTestSuite) TestGetAppVersion() {
cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

feeModule := cbs.(ibcfee.IBCMiddleware)
feeModule := cbs.(porttypes.Middleware)

appVersion, found := feeModule.GetAppVersion(suite.chainA.GetContext(), portID, channelID)

Expand Down
242 changes: 242 additions & 0 deletions modules/apps/callbacks/callbacks_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
package ibccallbacks_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/suite"

sdkmath "cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

icacontrollertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
"github.com/cosmos/ibc-go/v7/modules/apps/callbacks/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
ibcmock "github.com/cosmos/ibc-go/v7/testing/mock"
)

const maxCallbackGas = uint64(1000000)

// CallbacksTestSuite defines the needed instances and methods to test callbacks
type CallbacksTestSuite struct {
suite.Suite

coordinator *ibctesting.Coordinator

chainA *ibctesting.TestChain
chainB *ibctesting.TestChain

path *ibctesting.Path
}

// setupChains sets up a coordinator with 2 test chains.
func (s *CallbacksTestSuite) setupChains() {
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
s.coordinator = ibctesting.NewCoordinator(s.T(), 2)
s.chainA = s.coordinator.GetChain(ibctesting.GetChainID(1))
s.chainB = s.coordinator.GetChain(ibctesting.GetChainID(2))
s.path = ibctesting.NewPath(s.chainA, s.chainB)
}

// SetupTransferTest sets up a transfer channel between chainA and chainB
func (s *CallbacksTestSuite) SetupTransferTest() {
s.setupChains()

s.path.EndpointA.ChannelConfig.PortID = ibctesting.TransferPort
s.path.EndpointB.ChannelConfig.PortID = ibctesting.TransferPort
s.path.EndpointA.ChannelConfig.Version = transfertypes.Version
s.path.EndpointB.ChannelConfig.Version = transfertypes.Version

s.coordinator.Setup(s.path)
}

// SetupFeeTransferTest sets up a fee middleware enabled transfer channel between chainA and chainB
func (s *CallbacksTestSuite) SetupFeeTransferTest() {
s.setupChains()

feeTransferVersion := string(feetypes.ModuleCdc.MustMarshalJSON(&feetypes.Metadata{FeeVersion: feetypes.Version, AppVersion: transfertypes.Version}))
s.path.EndpointA.ChannelConfig.Version = feeTransferVersion
s.path.EndpointB.ChannelConfig.Version = feeTransferVersion
s.path.EndpointA.ChannelConfig.PortID = transfertypes.PortID
s.path.EndpointB.ChannelConfig.PortID = transfertypes.PortID

s.coordinator.Setup(s.path)
}

func (s *CallbacksTestSuite) SetupMockFeeTest() {
s.setupChains()

mockFeeVersion := string(feetypes.ModuleCdc.MustMarshalJSON(&feetypes.Metadata{FeeVersion: feetypes.Version, AppVersion: ibcmock.Version}))
s.path.EndpointA.ChannelConfig.Version = mockFeeVersion
s.path.EndpointB.ChannelConfig.Version = mockFeeVersion
s.path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort
s.path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort
}

// SetupICATest sets up an interchain accounts channel between chainA (controller) and chainB (host).
// It funds and returns the interchain account address owned by chainA's SenderAccount.
func (s *CallbacksTestSuite) SetupICATest() string {
s.setupChains()
s.coordinator.SetupConnections(s.path)

icaOwner := s.chainA.SenderAccount.GetAddress().String()
// ICAVersion defines a interchain accounts version string
icaVersion := icatypes.NewDefaultMetadataString(s.path.EndpointA.ConnectionID, s.path.EndpointB.ConnectionID)
icaControllerPortID, err := icatypes.NewControllerPortID(icaOwner)
s.Require().NoError(err)

s.path.SetChannelOrdered()
s.path.EndpointA.ChannelConfig.PortID = icaControllerPortID
s.path.EndpointB.ChannelConfig.PortID = icatypes.HostPortID
s.path.EndpointA.ChannelConfig.Version = icaVersion
s.path.EndpointB.ChannelConfig.Version = icaVersion

s.RegisterInterchainAccount(icaOwner)
// open chan init must be skipped. So we cannot use .CreateChannels()
err = s.path.EndpointB.ChanOpenTry()
s.Require().NoError(err)
err = s.path.EndpointA.ChanOpenAck()
s.Require().NoError(err)
err = s.path.EndpointB.ChanOpenConfirm()
s.Require().NoError(err)

interchainAccountAddr, found := s.chainB.GetSimApp().ICAHostKeeper.GetInterchainAccountAddress(s.chainB.GetContext(), s.path.EndpointA.ConnectionID, s.path.EndpointA.ChannelConfig.PortID)
s.Require().True(found)

// fund the interchain account on chainB
msgBankSend := &banktypes.MsgSend{
FromAddress: s.chainB.SenderAccount.GetAddress().String(),
ToAddress: interchainAccountAddr,
Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100000))),
}
res, err := s.chainB.SendMsgs(msgBankSend)
s.Require().NotEmpty(res)
s.Require().NoError(err)

return interchainAccountAddr
}

// RegisterInterchainAccount submits a MsgRegisterInterchainAccount and updates the controller endpoint with the
// channel created.
func (s *CallbacksTestSuite) RegisterInterchainAccount(owner string) {
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
msgRegister := icacontrollertypes.NewMsgRegisterInterchainAccount(s.path.EndpointA.ConnectionID, owner, s.path.EndpointA.ChannelConfig.Version)

res, err := s.chainA.SendMsgs(msgRegister)
s.Require().NotEmpty(res)
s.Require().NoError(err)

channelID, err := ibctesting.ParseChannelIDFromEvents(res.Events)
s.Require().NoError(err)

s.path.EndpointA.ChannelID = channelID
}

// AssertHasExecutedExpectedCallback checks if only the expected type of callback has been executed.
// It assumes that the source chain is chainA and the destination chain is chainB.
//
// The callbackType can be one of the following:
// - types.CallbackTypeAcknowledgement
// - types.CallbackTypeWriteAcknowledgement
// - types.CallbackTypeTimeout
// - "none" (no callback should be executed)
func (s *CallbacksTestSuite) AssertHasExecutedExpectedCallback(callbackType types.CallbackType, isSuccessful bool) {
successCount := uint64(0)
if isSuccessful {
successCount = 1
}
switch callbackType {
case types.CallbackTypeAcknowledgement:
s.Require().Equal(successCount, s.chainA.GetSimApp().MockKeeper.AckCallbackCounter.Success)
s.Require().Equal(1-successCount, s.chainA.GetSimApp().MockKeeper.AckCallbackCounter.Failure)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like these two calls can be combined yea? A method on each of the counters that just contains these two predicates (AckCallBackCounter.Success == successCount and AckCallBackCounter.Failure == 1 - sucessCount) would suffice to indicate this no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see testing code changes e0c2f33

s.Require().Equal(successCount, s.chainA.GetSimApp().MockKeeper.SendPacketCallbackCounter.Success)
s.Require().Equal(1-successCount, s.chainA.GetSimApp().MockKeeper.SendPacketCallbackCounter.Failure)
s.Require().Equal(uint8(2*successCount), s.chainA.GetSimApp().MockKeeper.GetStateCounter(s.chainA.GetContext()))
s.Require().Equal(uint8(0), s.chainB.GetSimApp().MockKeeper.GetStateCounter(s.chainB.GetContext()))
s.Require().True(s.chainA.GetSimApp().MockKeeper.TimeoutCallbackCounter.IsZero())
s.Require().True(s.chainB.GetSimApp().MockKeeper.WriteAcknowledgementCallbackCounter.IsZero())
case types.CallbackTypeWriteAcknowledgement:
s.Require().Equal(successCount, s.chainB.GetSimApp().MockKeeper.WriteAcknowledgementCallbackCounter.Success)
s.Require().Equal(1-successCount, s.chainB.GetSimApp().MockKeeper.WriteAcknowledgementCallbackCounter.Failure)
s.Require().Equal(uint8(successCount), s.chainB.GetSimApp().MockKeeper.GetStateCounter(s.chainB.GetContext()))
s.Require().Equal(uint8(0), s.chainA.GetSimApp().MockKeeper.GetStateCounter(s.chainA.GetContext()))
s.Require().True(s.chainA.GetSimApp().MockKeeper.SendPacketCallbackCounter.IsZero())
s.Require().True(s.chainA.GetSimApp().MockKeeper.TimeoutCallbackCounter.IsZero())
s.Require().True(s.chainB.GetSimApp().MockKeeper.AckCallbackCounter.IsZero())
case types.CallbackTypeTimeoutPacket:
s.Require().Equal(successCount, s.chainA.GetSimApp().MockKeeper.TimeoutCallbackCounter.Success)
s.Require().Equal(1-successCount, s.chainA.GetSimApp().MockKeeper.TimeoutCallbackCounter.Failure)
s.Require().Equal(successCount, s.chainA.GetSimApp().MockKeeper.SendPacketCallbackCounter.Success)
s.Require().Equal(1-successCount, s.chainA.GetSimApp().MockKeeper.SendPacketCallbackCounter.Failure)
s.Require().Equal(uint8(2*successCount), s.chainA.GetSimApp().MockKeeper.GetStateCounter(s.chainA.GetContext()))
s.Require().Equal(uint8(0), s.chainB.GetSimApp().MockKeeper.GetStateCounter(s.chainB.GetContext()))
s.Require().True(s.chainA.GetSimApp().MockKeeper.AckCallbackCounter.IsZero())
s.Require().True(s.chainB.GetSimApp().MockKeeper.WriteAcknowledgementCallbackCounter.IsZero())
case "none":
s.Require().True(s.chainA.GetSimApp().MockKeeper.AckCallbackCounter.IsZero())
s.Require().True(s.chainA.GetSimApp().MockKeeper.TimeoutCallbackCounter.IsZero())
s.Require().True(s.chainB.GetSimApp().MockKeeper.WriteAcknowledgementCallbackCounter.IsZero())
s.Require().True(s.chainA.GetSimApp().MockKeeper.SendPacketCallbackCounter.IsZero())
s.Require().Equal(uint8(0), s.chainA.GetSimApp().MockKeeper.GetStateCounter(s.chainA.GetContext()))
s.Require().Equal(uint8(0), s.chainB.GetSimApp().MockKeeper.GetStateCounter(s.chainB.GetContext()))
default:
s.FailNow(fmt.Sprintf("invalid callback type %s", callbackType))
}
s.Require().True(s.chainB.GetSimApp().MockKeeper.AckCallbackCounter.IsZero())
s.Require().True(s.chainB.GetSimApp().MockKeeper.TimeoutCallbackCounter.IsZero())
s.Require().True(s.chainA.GetSimApp().MockKeeper.WriteAcknowledgementCallbackCounter.IsZero())
}

func TestIBCCallbacksTestSuite(t *testing.T) {
suite.Run(t, new(CallbacksTestSuite))
}

// AssertHasExecutedExpectedCallbackWithFee checks if only the expected type of callback has been executed
// and that the expected ics-29 fee has been paid.
func (s *CallbacksTestSuite) AssertHasExecutedExpectedCallbackWithFee(
callbackType types.CallbackType, isSuccessful bool, isTimeout bool,
originalSenderBalance sdk.Coins, fee feetypes.Fee,
) {
// Recall that:
// - the source chain is chainA
// - forward relayer is chainB.SenderAccount
// - reverse relayer is chainA.SenderAccount
// - The counterparty payee of the forward relayer in chainA is chainB.SenderAccount (as a chainA account)

if !isTimeout {
// check forward relay balance
s.Require().Equal(
fee.RecvFee,
sdk.NewCoins(s.chainA.GetSimApp().BankKeeper.GetBalance(s.chainA.GetContext(), s.chainB.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)),
)

s.Require().Equal(
fee.AckFee.Add(fee.TimeoutFee...), // ack fee paid, timeout fee refunded
sdk.NewCoins(
s.chainA.GetSimApp().BankKeeper.GetBalance(
s.chainA.GetContext(), s.chainA.SenderAccount.GetAddress(),
ibctesting.TestCoin.Denom),
).Sub(originalSenderBalance[0]),
)
} else {
// forwad relay balance should be 0
srdtrk marked this conversation as resolved.
Show resolved Hide resolved
s.Require().Equal(
sdk.NewCoin(ibctesting.TestCoin.Denom, sdkmath.ZeroInt()),
s.chainA.GetSimApp().BankKeeper.GetBalance(s.chainA.GetContext(), s.chainB.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom),
)

// all fees should be returned as sender is the reverse relayer
s.Require().Equal(
fee.Total(),
sdk.NewCoins(
s.chainA.GetSimApp().BankKeeper.GetBalance(
s.chainA.GetContext(), s.chainA.SenderAccount.GetAddress(),
ibctesting.TestCoin.Denom),
).Sub(originalSenderBalance[0]),
)
}
s.AssertHasExecutedExpectedCallback(callbackType, isSuccessful)
}
27 changes: 27 additions & 0 deletions modules/apps/callbacks/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ibccallbacks

/*
This file is to allow for unexported functions and fields to be accessible to the testing package.
*/

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v7/modules/apps/callbacks/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
)

// ProcessCallback is a wrapper around processCallback to allow the function to be directly called in tests.
func (im IBCMiddleware) ProcessCallback(
ctx sdk.Context, packet channeltypes.Packet, callbackType types.CallbackType,
callbackDataGetter func() (types.CallbackData, error),
callbackExecutor func(sdk.Context, string, string) error,
) error {
return im.processCallback(ctx, packet, callbackType, callbackDataGetter, callbackExecutor)
}

// GetICS4Wrapper is a getter for the IBCMiddleware's ICS4Wrapper.
func (im *IBCMiddleware) GetICS4Wrapper() porttypes.ICS4Wrapper {
return im.ics4Wrapper
}
Loading