diff --git a/contracts/evm/library/utils/Types.sol b/contracts/evm/library/utils/Types.sol index 2d5d8e89..2e7f9a71 100644 --- a/contracts/evm/library/utils/Types.sol +++ b/contracts/evm/library/utils/Types.sol @@ -6,7 +6,7 @@ pragma solidity >=0.8.0; */ library Types { // The name of CallService. - string constant NAME = "xcall-multi"; + string constant NAME = "xcallM"; int constant CS_REQUEST = 1; int constant CS_RESPONSE = 2; diff --git a/contracts/evm/test/xcall/CallService.t.sol b/contracts/evm/test/xcall/CallService.t.sol index a9a516d9..5718eb50 100644 --- a/contracts/evm/test/xcall/CallService.t.sol +++ b/contracts/evm/test/xcall/CallService.t.sol @@ -56,8 +56,6 @@ contract CallServiceTest is Test { string[] _baseSource; string[] _baseDestination; - string constant xcallMulti = "xcall-multi"; - event CallMessage( string indexed _from, string indexed _to, diff --git a/contracts/javascore/xcall-lib/src/main/java/foundation/icon/xcall/CallService.java b/contracts/javascore/xcall-lib/src/main/java/foundation/icon/xcall/CallService.java index 67bed5c8..338fb2b0 100644 --- a/contracts/javascore/xcall-lib/src/main/java/foundation/icon/xcall/CallService.java +++ b/contracts/javascore/xcall-lib/src/main/java/foundation/icon/xcall/CallService.java @@ -32,7 +32,7 @@ public interface CallService { /** * The name of CallService. */ - String NAME = "xcall-multi"; + String NAME = "xcallM"; /*======== At the source CALL_BSH ========*/ /** diff --git a/contracts/javascore/xcall/src/test/java/foundation/icon/xcall/CallServiceTest.java b/contracts/javascore/xcall/src/test/java/foundation/icon/xcall/CallServiceTest.java index 2cc58a12..2b430dd3 100644 --- a/contracts/javascore/xcall/src/test/java/foundation/icon/xcall/CallServiceTest.java +++ b/contracts/javascore/xcall/src/test/java/foundation/icon/xcall/CallServiceTest.java @@ -70,7 +70,7 @@ public void sendMessage_singleProtocol() { // Assert CSMessageRequest request = new CSMessageRequest(iconDappAddress.toString(), ethDapp.account.toString(), BigInteger.ONE, false, data, new String[]{baseEthConnection}); CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); - verify(baseConnection.mock).sendMessage(eq(ethNid), eq("xcall-multi"), eq(BigInteger.ZERO), aryEq(msg.toBytes())); + verify(baseConnection.mock).sendMessage(eq(ethNid), eq(CallService.NAME), eq(BigInteger.ZERO), aryEq(msg.toBytes())); verify(xcallSpy).CallMessageSent(dapp.getAddress(), ethDapp.toString(), BigInteger.ONE); } @@ -86,7 +86,7 @@ public void sendMessage_defaultProtocol() { // Assert CSMessageRequest request = new CSMessageRequest(iconDappAddress.toString(), ethDapp.account.toString(), BigInteger.ONE, false, data, null); CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); - verify(baseConnection.mock).sendMessage(eq(ethNid), eq("xcall-multi"), eq(BigInteger.ZERO), aryEq(msg.toBytes())); + verify(baseConnection.mock).sendMessage(eq(ethNid), eq(CallService.NAME), eq(BigInteger.ZERO), aryEq(msg.toBytes())); verify(xcallSpy).CallMessageSent(dapp.getAddress(), ethDapp.toString(), BigInteger.ONE); } @@ -118,8 +118,8 @@ public void sendMessage_multiProtocol() throws Exception { // Assert CSMessageRequest request = new CSMessageRequest(iconDappAddress.toString(), ethDapp.account.toString(), BigInteger.ONE, false, data, destinations); CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); - verify(connection1.mock).sendMessage(eq(ethNid), eq("xcall-multi"), eq(BigInteger.ZERO), aryEq(msg.toBytes())); - verify(connection2.mock).sendMessage(eq(ethNid), eq("xcall-multi"), eq(BigInteger.ZERO), aryEq(msg.toBytes())); + verify(connection1.mock).sendMessage(eq(ethNid), eq(CallService.NAME), eq(BigInteger.ZERO), aryEq(msg.toBytes())); + verify(connection2.mock).sendMessage(eq(ethNid), eq(CallService.NAME), eq(BigInteger.ZERO), aryEq(msg.toBytes())); verify(xcallSpy).CallMessageSent(dapp.getAddress(), ethDapp.toString(), BigInteger.ONE); } @@ -131,7 +131,7 @@ public void handleResponse_singleProtocol() { CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); // Act - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Assert verify(xcallSpy).CallMessage(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, BigInteger.ONE, data); @@ -146,7 +146,7 @@ public void handleResponse_singleProtocol_invalidSender() { CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); // Act - assertThrows(Exception.class, ()->xcall.invoke(otherConnection, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes())); + assertThrows(Exception.class, ()->xcall.invoke(otherConnection, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes())); // Assert verify(xcallSpy, times(0)).CallMessage(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, BigInteger.ONE, data); @@ -161,7 +161,7 @@ public void handleResponse_defaultProtocol() { CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); // Act - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Assert verify(xcallSpy).CallMessage(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, BigInteger.ONE, data); @@ -177,7 +177,7 @@ public void handleResponse_defaultProtocol_invalidSender() { Account invalidConnection = sm.createAccount(); // Act - assertThrows(Exception.class, ()-> xcall.invoke(invalidConnection, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes())); + assertThrows(Exception.class, ()-> xcall.invoke(invalidConnection, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes())); // Assert verify(xcallSpy, times(0)).CallMessage(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, BigInteger.ONE, data); @@ -195,9 +195,9 @@ public void handleResponse_multiProtocol() throws Exception { CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); // Act - xcall.invoke(connection1.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(connection1.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); verify(xcallSpy, times(0)).CallMessage(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, BigInteger.ONE, data); - xcall.invoke(connection2.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(connection2.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Assert verify(xcallSpy, times(1)).CallMessage(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, BigInteger.ONE, data); @@ -209,7 +209,7 @@ public void executeCall_singleProtocol() { byte[] data = "test".getBytes(); CSMessageRequest request = new CSMessageRequest(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, false, data, new String[]{baseConnection.getAddress().toString()}); CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Act xcall.invoke(user, "executeCall", BigInteger.ONE, data); @@ -228,7 +228,7 @@ public void executeCall_defaultProtocol() throws Exception { CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); xcall.invoke(owner, "setDefaultConnection", ethDapp.net(), baseConnection.getAddress()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Act xcall.invoke(user, "executeCall", BigInteger.ONE, data); @@ -248,8 +248,8 @@ public void executeCall_multiProtocol() throws Exception{ CSMessageRequest request = new CSMessageRequest(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, false, data, connections); CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); - xcall.invoke(connection1.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); - xcall.invoke(connection2.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(connection1.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); + xcall.invoke(connection2.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Act xcall.invoke(user, "executeCall", BigInteger.ONE, data); @@ -269,8 +269,8 @@ public void executeCall_multiProtocol_rollback() throws Exception { CSMessageRequest request = new CSMessageRequest(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, true, data, connections); CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); - xcall.invoke(connection1.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); - xcall.invoke(connection2.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(connection1.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); + xcall.invoke(connection2.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Act xcall.invoke(user, "executeCall", BigInteger.ONE, data); @@ -280,8 +280,8 @@ public void executeCall_multiProtocol_rollback() throws Exception { msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); verify(dapp.mock).handleCallMessage(ethDapp.toString(), data, connections); - verify(connection1.mock).sendMessage(ethNid, "xcall-multi", BigInteger.ONE.negate(), msg.toBytes()); - verify(connection2.mock).sendMessage(ethNid, "xcall-multi", BigInteger.ONE.negate(), msg.toBytes()); + verify(connection1.mock).sendMessage(ethNid, CallService.NAME, BigInteger.ONE.negate(), msg.toBytes()); + verify(connection2.mock).sendMessage(ethNid, CallService.NAME, BigInteger.ONE.negate(), msg.toBytes()); verify(xcallSpy).CallExecuted(BigInteger.ONE, 1, ""); } @@ -294,7 +294,7 @@ public void executeCall_defaultProtocol_rollback() throws Exception { CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); xcall.invoke(owner, "setDefaultConnection", ethDapp.net(), baseConnection.getAddress()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Act xcall.invoke(user, "executeCall", BigInteger.ONE, data); @@ -305,7 +305,7 @@ public void executeCall_defaultProtocol_rollback() throws Exception { verify(defaultDapp.mock).handleCallMessage(ethDapp.toString(), data); verify(xcallSpy).CallExecuted(BigInteger.ONE, 1, ""); - verify(baseConnection.mock).sendMessage(ethNid, "xcall-multi", BigInteger.ONE.negate(), msg.toBytes()); + verify(baseConnection.mock).sendMessage(ethNid, CallService.NAME, BigInteger.ONE.negate(), msg.toBytes()); } @Test @@ -314,7 +314,7 @@ public void executeCall_failedExecution() { byte[] data = "test".getBytes(); CSMessageRequest request = new CSMessageRequest(ethDapp.toString(), dapp.getAddress().toString(), BigInteger.ONE, true, data, new String[]{baseConnection.getAddress().toString()}); CSMessage msg = new CSMessage(CSMessage.REQUEST, request.toBytes()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ZERO, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ZERO, msg.toBytes()); // Act doThrow(new UserRevertedException()).when(dapp.mock).handleCallMessage(ethDapp.toString(), data, new String[]{baseConnection.getAddress().toString()}); xcall.invoke(user, "executeCall", BigInteger.ONE, data); @@ -322,7 +322,7 @@ public void executeCall_failedExecution() { // Assert CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.FAILURE); msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - verify(baseConnection.mock).sendMessage(ethNid, "xcall-multi", BigInteger.ONE.negate(), msg.toBytes()); + verify(baseConnection.mock).sendMessage(ethNid, CallService.NAME, BigInteger.ONE.negate(), msg.toBytes()); verify(xcallSpy).CallExecuted(BigInteger.ONE, 0, "score.RevertedException"); } @@ -337,7 +337,7 @@ public void rollback_singleProtocol() { // Act CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.FAILURE); CSMessage msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); // Assert verify(xcallSpy).ResponseMessage(BigInteger.ONE, CSMessageResponse.FAILURE); @@ -356,7 +356,7 @@ public void rollback_defaultProtocol() { // Act CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.FAILURE); CSMessage msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); // Assert verify(xcallSpy).ResponseMessage(BigInteger.ONE, CSMessageResponse.FAILURE); @@ -376,7 +376,7 @@ public void rollback_defaultProtocol_invalidSender() { // Act CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.FAILURE); CSMessage msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - assertThrows(Exception.class, ()-> xcall.invoke(invalidConnection, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes())); + assertThrows(Exception.class, ()-> xcall.invoke(invalidConnection, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes())); // Assert verify(xcallSpy, times(0)).ResponseMessage(BigInteger.ONE, CSMessageResponse.FAILURE); @@ -402,9 +402,9 @@ public void rollback_multiProtocol() throws Exception { // Act CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.FAILURE); CSMessage msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - xcall.invoke(connection1.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); + xcall.invoke(connection1.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); verify(xcallSpy, times(0)).ResponseMessage(BigInteger.ONE, CSMessageResponse.FAILURE); - xcall.invoke(connection2.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); + xcall.invoke(connection2.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); // Assert verify(xcallSpy).ResponseMessage(BigInteger.ONE, CSMessageResponse.FAILURE); @@ -422,7 +422,7 @@ public void rollback_success() throws Exception { // Act CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.SUCCESS); CSMessage msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); // Assert verify(xcallSpy).ResponseMessage(BigInteger.ONE, CSMessageResponse.SUCCESS); @@ -443,7 +443,7 @@ public void executeRollback_singleProtocol() { CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.FAILURE); CSMessage msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); // Act xcall.invoke(user, "executeRollback", BigInteger.ONE); @@ -467,7 +467,7 @@ public void executeRollback_defaultProtocol() throws Exception { CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.FAILURE); CSMessage msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); + xcall.invoke(baseConnection.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); // Act xcall.invoke(user, "executeRollback", BigInteger.ONE); @@ -496,8 +496,8 @@ public void executeRollback_multiProtocol() throws Exception { xcall.invoke(dapp.account, "sendCallMessage", ethDapp.toString(), data, rollback, sources, destinations); CSMessageResponse msgRes = new CSMessageResponse(BigInteger.ONE, CSMessageResponse.FAILURE); CSMessage msg = new CSMessage(CSMessage.RESPONSE, msgRes.toBytes()); - xcall.invoke(connection1.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); - xcall.invoke(connection2.account, "handleBTPMessage", ethNid, "xcall-multi", BigInteger.ONE, msg.toBytes()); + xcall.invoke(connection1.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); + xcall.invoke(connection2.account, "handleBTPMessage", ethNid, CallService.NAME, BigInteger.ONE, msg.toBytes()); // Act xcall.invoke(user, "executeRollback", BigInteger.ONE); diff --git a/docs/adr/xcall.md b/docs/adr/xcall.md index 74036862..0a9ee084 100644 --- a/docs/adr/xcall.md +++ b/docs/adr/xcall.md @@ -396,6 +396,7 @@ CallRequest { MAX_DATA_SIZE: 2048 MAX_ROLLBACK_SIZE: 1024 NID: +SVC_NAME = xcallM sn: reqId: @@ -466,11 +467,11 @@ payable external function sendCallMessage(String _to, if _sources == []: src = defaultConnection[dst.net()] fee = src->getFee(dst.net(), needResponse) - src->sendMessage(fee, dst.net(), "xcall-multi", sendSn, msg) + src->sendMessage(fee, dst.net(), SVC_NAME, sendSn, msg) else: for src in sources: fee = src->getFee(dst.net(), needResponse) - src->sendMessage(fee, dst.net(), "xcall-multi", sendSn, msg) + src->sendMessage(fee, dst.net(), SVC_NAME, sendSn, msg) remaningBalance = getBalance(); @@ -629,10 +630,10 @@ external function executeCall(Integer _reqId, byte[] _data) { msg = CSMessage(CSMessage.RESPONSE, response.toBytes()); if req.protocols == []: protocol = defaultConnection[from.net()] - protocol->sendMessage(from.net(), "xcall-multi", sn, msg.toBytes()) + protocol->sendMessage(from.net(), SVC_NAME, sn, msg.toBytes()) else: for (String protocol : req.protocols): - protocol->sendMessage(from.net(), "xcall-multi", sn, msg.toBytes()) + protocol->sendMessage(from.net(), SVC_NAME, sn, msg.toBytes()) } ```