GasMASk Annotation-based Code Generator as an Embedded Domain-Specific Language in Collaborative

Page 1

GasMASkAnnotation-basedCodeGenerator asanEmbeddedDomain-SpecificLanguagein

CollaborativeMulti-AgentSystems

Or¸cunOru¸c,UweAßmann

TUDresden,SoftwareTechnologyGroup,N¨othnitzerStraße46,01187, Dresden

Abstract. Multi-agentsystemshaveevolvedwiththeirapplicationframework,analysisapproaches anddesigncomplexitiesoverthepastfewdecades.Inorderforprogrammingsoftwareagents,you needtohandleanalysis,designandimplementationtogether;furthermore,privacyandtrustshould beintegratedexternallyintotheagent-orientedapplications.Currentframeworksdonotconsider privacy,trust,anddataintegrityinagentapplications.

Inthisstudy,weproposeadomain-specificlanguagethatcanbeusedforagentbehaviorsthat consistofroles,organizationalentity,goalsthroughannotationprocessingwithtemplates.Smart contractscanbegeneratedtodecreasethetimefordeploymentanddevelopmentstages.Templates andannotationsarepopulartechniquestoreduceboilerplatecodebasesfromagent-orientedprogramming.Thesetechniquescanalsobeusedformodel-drivensoftwareengineering.Thisstudy willtakethesoftwareagentdevelopmentasawholewithanalysis,design,anddevelopmentwith embeddeddomain-specificlanguagedevelopmentintermsofsmartcontractapplications.Furthermore,wewouldliketorefertomethodology,resultsoftheresearch,andcasestudytoenlighten readersinabetterway.Finally,wesummarizefindingsandhighlightthemainresearchpointsby inferencingintheconclusionsection.

Keywords: Softwareagents,Domain-specificlanguages,Blockchaintechnology,Smartcontracts, Role-basedprogramminglanguages,CodeGeneration,Template-basedcodegeneration

1Introduction

Agent-orientedprogramming(AOP)canbeconsideredasasubjectofobjectorientedprogrammingbyshowingthestateofanobjectwithhuman-likefeatures suchasbelief,desire,intentions,andgoals.Moreover,anagentshouldbeintheinteractionwithotheragents,inthisway,agentsareabletoplayrolesashuman-being does.AOPspecializestheobject-orientedprogrammingmethodologybyfixingstate andmodules,whicharecalledagents,toconsistoffeaturesthatcomefromagent behaviors.Besides,anagentcanhandlethemessagepassingbetweenotheragents internally.

Agent-basedsystemshavechangedtheircharacteristicsoverthepastfewdecades aspectofdesign,analysis,andimplementation.Althoughonecanfindoutthedif-

International
10, No 2, May 2021 1 DOI : 10.5121/ijsptm.2021.10201
Journal of Security, Privacy and Trust Management (IJSPTM) Vol

ficultyofexactdefinitionintermsofthemulti-agentsystem,multi-agentsystems areusedbroadlyintheapplicationareassuchassupplychainmanagement,distributedsystems,smartgrids,roboticmotionplanning.Multi-agentsystemsare stronglydependentoncontextsandroles.Eachagentplaysaroleandithasa minimalsetofattributesthatrepresentstheenvironment.Moreover,agentsshould havebehaviorsthatare,inessence,relatedtoimplementingdeterministicornondeterministicbehaviorsofanagentthatoperatearolethatcanbeinsequential order,cyclicorder,orparallelorder.

Softwareagentshavesomemandatoryfeaturesinordertocompletetasksthat havebeengivenbydevelopers.Agentmustperceptthesurroundingenvironment throughinformationreceivedfromtheenvironmentbysensors.Andthenanevent shouldbecreatedbyanagenttocreateknowledgeabouttheenvironment.This hasbeencalledbeliefs,whichprovidessomeaspectoftheagent’sknowledgeabout theenvironment[1].Afterdefiningaconcretegoalforanagent,eventsareoften extractedfromperceptsandtriggeredbyanewaction[2].

Agentsmustbeinarelationshipwithexternaltrustedpartiestoprovideprivacy andconsistencyinmulti-agentsystems.However,thetrustwasmostlyprovidedby differentlogicinterpretationsandcumbersomeontologicaldefinitionsinmulti-agent systems.Blockchaintechnologyoffersacredibleandprivatedatapoolthatcanbe usedwithprogrammablecontracts(smartcontracts)asashareddatabase.Aswe solvedthecredibilityproblemwithblockchaintechnology,wecanenforcethedata layersecurity,whichisvitalfordata-drivenmulti-agentsystemcommunication,by implementingsmartcontractsontheapplicationlayeroftheblockchainprotocol.

Asmartcontractisapieceofcodethatisstoredonablockchainbytriggeringcoinbasedtransactionswithsaveddataandwhichreadsandwritesdatainablockchain database 1 .Inaddition,smartcontractscanensurethetestabilityofrolefeatures, securetransactionswithintheblockchaindatabase,andseparationofthebusiness logic(model)andapplicationlogic(systemarchitecture).

Theresearchpaperisstructuredasfollows.First,wewilldiscusstheimportance andshorthistoryregardingthetopicintheBackground2.IntheMethodology andContributions1.1chapter,wewillexplaincontributionsthatcanoccurat theendofthisresearchandemphasizeourobjectives,problemstatement,and researchquestions.Secondly,wewilllistsomelimitations1.2,whichwemight encounterduringthisresearch.Inthechapter3,weintroducepreviousstudies andsurveysthathavebeenconductedbefore.Later,wewillgivethedetailsof theimplementationinthechapter4.InthechaptercalledCaseStudy5,wewill introduceasampleconcept,whichwewouldliketoimplementwithourlanguage. Inchapter6and7,wewilllistourfindingsandtasksthatshouldbetakeninto considerationforfurtherresearch.

1 https://www.coindesk.com/three-smart-contract-misconceptions

International
10, No 2, May 2021 2
Journal of Security, Privacy and Trust Management (IJSPTM) Vol

1.1MethodologyandContributions

Firstofall,wehavetworesearchquestions.Toconcludeupregardingtheresearch problem,wehavedefinedresearchquestions(RQ)asbelow:

RQ1:Canadomain-specificlanguagethatcomprisesthemainfeaturesofagent communicationlanguage,agentframework,andsmartcontractlanguagebe created?

RQ2:Cantemplatesbeintegratedintoannotationprocessorsintermsofroles, goals,andcompartmentsinthedomain-specificlanguage?

Goal:

Themaingoalofthisresearchistoimplementadomain-specificlanguageto demonstratetemplatesamplesandcodegenerationforsmartcontracts.

Objectives:

– Implementingtemplatestocreateanddeleteagentsinoneoftheselectedframeworks.

– Definingannotationsforstatefulsmartcontractlanguageinorderfortheprocessofcodegeneration.

– Attheimplementationphase,wewilldefinesomeeventsinsmartcontractsto logtotheblockchainnetworksandspecifyagents’basicfeaturestobealivein anagentmanagementsystem.

Expectedcontributionswillbeinthefollowingitems:

Wewillhaveanewembeddeddomain-specificlanguagethattakesasawhole privacy,security,dataintegrityandrole-orientationinmulti-agentsystems.

– Wewillcreateatoolforstatefulcontractdevelopmentintheblockchaindatabase.

– Wewillhaveagenttemplatestoreduceboilerplatecodebaseandincreasethe learningcurveforagent-orientedapplicationsinapracticalframework.

1.2Limitations

Inthissection,wewilllistourlimitationsregardingtheprocessofwritingthe thesis.

– Wewillpresentcodetemplatesforagent-orientedsoftwareengineeringanddiscusswiththemetaprogrammingthroughannotationprocessing.

– Wewillfocusontheexistingmeta-modelsuchasCROMforspecifyingcommunicativeentitytypes.InthecontextofCROMresearch,wewillfollowthe guidelineregardingrolesandcompartmentsthathavebeenspecifiedbefore.

– Wewilldevelopanapplicationbasedonastatefulsmartcontractlanguage suchasSoliditythefollowingdesign-by-contractapproachthatinteractswith differentagentsinthecontextofrole-orientedprogramming.

International
Vol 10, No 2, May 2021 3
Journal of Security, Privacy and Trust Management (IJSPTM)

ThisresearchislimitedtotheKQMLandFIPAagentcommunicationlanguages anditdoesnotcomprisestatelessblockchainlanguage.Duetothenatureofthe statelessblockchainlanguage,itdoesnotpurelysuitablefortheobject-oriented approach.

Asforontologicalrepresentation,semanticheterogeneitybetweenagent-oriented frameworkswillnotbetakenintoconsideration.Sowebasicallywillhandleexistingontologiesandwillnotadvancetoontologyengineering.

2Background

Codegenerationallowsyoutoproduceprogramcodethatisonlystronglytyped, andyetcanbeeasilyreconfiguredcodebasewhenthesourcemodelischanged

2 .Principally,codegeneratorsaremetaprogramstranslatingaregulartreetoa sentenceofacontext-freelanguage[3].Whenthecodegeneratortranslatesthe abstractsyntaxtreeintoacontext-freelanguage,itusesamodel,whichisthe definitionlanguageoftheagent,andview(result)inorderforrealizingtheoperation.Anabstractsyntaxtreeisatreerepresentationofthesyntacticstructure thathasbeenrepresentedinaprogramminglanguage.Inthisstudy,wewillwritea code-generatorinanad-hocfashion,whichisgoingtobewrittenforagent-oriented softwareapplications.Thecodegenerationprocessisaprojectionoftheinputdata modelintotooutputcodebase.Bydefininglanguagevocabularyinourembeddeddomainmodelinglanguage,wecaneasilygenerateanagent-orientedcodebasefor variouspracticalframeworks.

2.1Agent-OrientedProgramming

Anagentisanythingthatcanbeviewedasperceivingitsenvironmentthrough inputandoutputappliancesandactinguponthatenvironment

[4].Tounderstandanenvironment,agentneedstoregisterthestateofhistoryregardingtheenvironment.Agentshavebeendesignedtobetterunderstandthecomplexityofsoftwaresystems.Agent-to-AgentandAgent-to-Environmentinteractions areanimportantpartofagent-orientedprogrammingbecausethestateofpassive objectsissupposedtohaveinteractedinadynamicenvironment.

Themodelofgoals,roles,andorganizationsshouldbedesignedatthesystem level.Inthepracticalframeworks,thiscanbedonebymetamodelsormetaprogrammingwithanembeddeddomain-specificlanguage.Bothofthemethodscan generateagent-orientedcodewithsmartcontracts,butchangesshouldbeintegratedintothemetamodels.Modelandviewshouldbestrictlyseparatedinboth approachesandthemetamodelapproachtakesmoretimeforasteeplearningcurve.

International
10, No 2,
2021 4
2 MicrosoftCode-by-using-templates
Journal of Security, Privacy and Trust Management (IJSPTM) Vol
May

Organizationalparticipantsareoneofthemostimportantfeaturesintheagentorientedworld.Forinstance,thecardealership,thebank,theschool,andtheinsurancecompanyareallexamplesoforganizationalparticipants[5].Agentorientation aimsatpursuingasoftwareparadigm.Themainresearchpointisaboutwhether theagent-orientedcanensureahigherqualitythanitspredecessorintermsof autonomy,reactivity,proactivity,andcooperativefeaturesinaparticulardomain.

Inpractice,roles,organizations,andgoalsaredefinedbymessagesthatcontain envelope,payload,message,andcontent[?].Agentplatformsarephysicalplatforms inwhichagentsaredeployedandorganized.Agentplatformsneedtoregisterto directoryfacilitatorinordertofindotheragentservicesinthenetwork[?].An agentcanmodifyitsagentdescriptionbysendingrequeststothedirectoryfacilitator.Agentsaredeletedorcreatedbyagentmanagementsystems,whichareone ofthecorecomponentsinpracticalagentframeworks.Lastly,organizationaland role-basedentitiesaredescribedinmessagesincompliancewithFIPAandKQML throughagentmessagingtransportservices.

2.2Role-orientedProgramming

Inanobject-orientedapplication,objectsareinarelationshipbetweenotherobjects andtheyaresharingtheirfeaturesofrelationshipsthroughconstraints,dependency, andinvariants.Eventhoughthereisnocommonunderstandingaboutrolesina programminglanguage,role-orientedprogrammingbasicallylooksforananswerto whetherornotanobjectcancollaboratewithdefinedrolesamongotherobjectsin theapplicationlifetime.

Rolesencapsulatethedynamicbehaviorofplayers,whicharethecoreobjects inthecontext,anddynamicallyadapttheplayers’behavior[6].Compartments arecontainerthatholdsmultiplerolesortheircollaborationfeatures.Rolescan makethedesignofmulti-agentsystemseasierbyimplementingthecompositionof roleattributes,roleinvariants,rolemethods,andbindinginterfaces.Thedifference betweenrolesandobjectsiswhetherornottherolescanmovehoststhatexistin theenvironment[7].Role-basedsoftwareagentsarerelatedtocontext-awaremultiagentsystems.Contextisanyinformationthatisaccessibletotheprogram,where anentityisaperson,place,oranotheragentthatisconsideredrelevanttothe determinationofbehavioralvariations[8].Agentscandynamicallycollaboratewith roles,createcoalitionsoftrustedpartnersasaneffectivemechanismtocommunicate withservicerequestors,findservicesrequestedbythem,anddeterminetrusted servicesandprovideservicestotheapplicantswithoutviolatingtheprivacyofthe predefinedenvironment[9]

CompartmentsbelongtotheresearchoftheCompartmentRoleObjectModel (CROM)thatestablishessubtypesofnaturaltypesandrelationshiptypesamong combinedroles[10]

5
International Journal of Security, Privacy and Trust Management (IJSPTM) Vol 10, No 2, May 2021

2.3SmartContracts

Smartcontractsareapieceofcodethatcanbetriggeredbyblockchainnetwork throughtransactions.Morespecifically,asmartcontractisasecureandunstoppablecomputerrepresentinganagreementthatisautomaticallyexecutableand enforceable[11].Atransactionisasigneddatapackagetotransfervalue,which canbecoinbasevalue,fromanaccounttoanotheraccountortoacontract,invoke amethodofacontract,ordeployanewcontract[11].Principally,anorganization hasanidentityanditsownpurpose[11].

Smartcontractsaredeterministicapplications,whichmeansthattheapplicationsproducethesameoutputseverytimetheyarecarriedout.Theyalsohave somepreconditionsandpostconditionsthatfocusontheconditionlogicofapplicationsratherthansyntaxoralgorithmsinpractice.

Blockchainnetworksbehaveinadistributedanddecentralizedmanner,which providesimmutable,permissionlessorpermissionedsolutionsinaprivateorpublic environment.Consensusisthebackbonemechanismofablockchainsolutionthat iscomprisingofvarioustypesofthemsuchasproof-of-work,proof-of-stake,proofof-authority.Theselectionoftypesofconsensusshouldbedefinedbyblockchain technology,sothetechnologychoiceisoneoftheimportantparametersforsmart contractapplications.Forinstance,CordaapplicationsdonotprovidecertaindeterminismjustliketheEthereumtechnologybecausedevelopershavedesignedthe Cordablockchainnetworkasadistributedledgerwithoutdesigningaparticular virtualmachineenvironment.Inordertoensuredeterministicbehaviorsinthe blockchainnetworks,theymustimplyhonestagreement,propertermination,the validityofnodes,andfault-tolerant.

Onecantransfervaluewithafixedordynamicpriceintheblockchainnetwork,whichiscalledon-chaintransactions.Fordeterministicvaluetransfer,onchaintransactionsmustbeexecutedintheblockchainvirtualmachine.Statefulor statefultransactionscanbemadeineitherdeclarativeprogramminglanguagesor imperativeprogramminglanguages.Agentswhowanttojointhenetworkshould takepermissionfromthenetworkadministrator.Hence,wecanrestricttheaccess foranyexternalparticipantswhowanttoconnectwiththeinternalblockchain networkthatiscalledpermissionedblockchain.Thisprovideshighthroughputand lowlatencyintheblockchainnetwork.However,thenatureofblockchainisalways permissionlessbecauseallnodescanparticipateinthenetworktosynchronizetheir internalblockdatastructures.

DynamicSmartContracts

Asmartcontractcanexecuteasset-valuetransfersintheblockchainnetworkor executeanexternalcontractbypassingitsaddress.Thus,asmartcontractcan

Forpermissionlessandpermissionedblockchain, onceasmartcontractisdeployed,thesmartcontractremainsimmutable[12].
6
International Journal of Security, Privacy and Trust Management (IJSPTM) Vol 10, No 2, May 2021

triggeranothersmartcontractoritselfwithdifferentattributes.Thisisthepoint thatwecancreatedynamicsmartcontracts.

Dynamicsmartcontractsdealwiththemaintainabilityofimmutablesmart contractsinordertochangetheirbehaviorsatruntime.Reconfigurationofasmart contractthatiscalledbymultiplecontractsmighthaveseeneffectivetoimplement; however,deploymentoverloadcanaffecttheperformanceoftheblockchainnetwork. Dynamicsmartcontractsarenotimplementedinthisstudy;nevertheless,wewill considerthebehaviorchangesusingparameterpassingfromexternalcontractsto realizepartlydynamicstatesforagentsintheblockchainnetwork.

2.4Domain-SpecificLanguagesforMetaprogramming

Domain-SpecificLanguages(DSLs)haveasmallsetoffeaturesandtheyaremostly optimizedforaspecificdomainsuchashealth,finance,ormanufacturing.Byoptimizingforaspecificdomain,aDSLcanbeeasilymaintainedandbuiltupona general-purposelanguagewithoutdefiningdeeplytheunderlyingconceptoflanguagedesign.Inthisstudy,wehavechosenageneral-purposelanguagecalledJava, whichprovidesPluggableAnnotationProcessingAPIthatdealswithadvanced customizedannotationsatcompileorruntimelevels.Inthisstudy,webasically generateanembeddeddomain-specificlanguagethatgeneratesapieceofcodeina general-purposelanguageandastatefulsmartcontractlanguage.Atthefirststage oftheresearch,applicationswillbegeneratedbytheembeddeddomain-specific language.Later,wewillfocusonthefeatureoflanguagewhetherornotitchanges thebehaviorofexistingprograms.

3StateoftheArt

ALAADINisoneoftheoldestmetamodels[13]todefinemodelsoforganizationsfor agentsandthismodeldefinesaverysimpledescriptionofcoordinationandnegation schema[13].Theauthorsdeterminethattheroleisanabstractrepresentationofan agentorservicefunctionwithinagroup.Groupsareasetoffeaturesthatbehave asanatomicentitysothatanagentdynamicallyjoins,creates,orleavesgroups [14].

Whenwefocusonbehavioralrolesforagentinteraction,(Cabriet.al.2003) proposedthatanagentsystemdefinesaroleasasetofcapabilitiesandexpectedbehaviors.BRAINisanapproachthatcoversarole-basedinteractionmodel, whereagents’interactionsandbehaviorsareembeddedinroles[14].Moreover,they achievedandadvisetorealizeagent-orientedfeatures,separationofconcerns,and reuseofsolutions[15].Todescribeagentssemantically,theydefinedalanguage calledXRolethatexploitsbuilt-updefinitionsofroles.Thesedefinitionsconsistof name,description,addresses,roledescription,andcontentsoftheagentswithrelationalfeaturessuchas MinOccurs and MaxOccurs

.RoleSystemisaninteraction International Journal of Security, Privacy and Trust Management (IJSPTM) Vol 10, No 2, May 2021 7

infrastructurethatimplementsthemodelofBRAIN[16].RolesdefinedbyXRole canbereadbyhumansaswellasbyagentsandtools[16].TheRoleSystemprovides twomaincomponentswhichare: reqRegistration,toregisteranagentinthesystem withaspecifiedrole; searchForRoleAgent,tosearchforagentsplayingagivenrole betweenagentsandserveragents[16].

Theplanningcapabilityofmulti-agentsystemsisoneofthekeyfeaturesthat theblockchainshouldtakecareofit.Afterassigningroles,planexecutionofthe multi-agentsystemsshouldcompletedistributedorderingactions.Todoso,asmart contractcanbeusedwhichareessentiallycollectionsofdistributedcodeanddata representingsomebusinesslogicthatworkswiththeblockchaindistributedconsensusprotocols[17].Themainideaofthispaperistocoordinatethestepsof multi-agentsthroughthesmartcontractsaspectofdistributedplanexecution.In thisplanexecution,multiplesmartcontractscanbeusedsuchasoraclecontract, whichisallowingtoexploitsdataintheoff-chainstorage,orcontractofpreconditionsandpostconditionstoprovidethedesign-by-contractpattern.

Gaiaisoneofthemethodologiesatthedesignandanalysisphasesinmulti-agent systems.Themaingoalofthismethodologyistomodelmulti-agentsystemsforan organizationwheredifferentrolesinteract[14].TheGaiamethodologydefinesthe featuresofrolesasbelow:

– Responsibilities:Theyspecifythefunctionalitiesofagentsthatplayroles.

– Permissions:Theyareasetofrightsassociatedwithrolesinwhichagentsplay.

– Activities:Internalcomputationofanagent.Thisdoesnottakeintoconsiderationtherelationshipbetweenagents.

Protocols:Thisisrelatedtointeractionrolesindicatingagent-to-agentcommunication.

Therole-basedevolutionaryprogramming(RoleEP)presentscooperativemobileagentstocollaborateinachievingacommongoal[14].TheauthorsofRoleEP statethatanobjectbecomesanagentbybindingitselftoarolethatisdefinedin adynamicenvironment[7].Theauthorshavedefinedthebasicconceptasbelow [7].

Environment: Anenvironmentiscomposedofenvironmentattributes,methods ofenvironment,androles.

Roles: Arole,whichcanmovebetweenhoststhatexistinanenvironment, containsroleattributes,rolemethods,andbindinginterfaces.

Objects: Anobject,whichcannotmovebetweenhosts,iscomposedofattributes andmethods.

– Agents: Anobjectthatbindsitselfwithsomerolesandacquirestraveling/collaborationfunctionsisnamedasAgents.

– BindingInterface: Abindinginterface,whichlookslikeanabstractmethod interface,isusedwhenanobjectbindsitselfwitharole.

8
International Journal of Security, Privacy and Trust Management (IJSPTM) Vol 10, No 2, May 2021

Implementationofadomain-specificlanguagemayhavemetamodeldesign pathsatthelevelofM1(UserModel),M2(UnifiedModelingLanguage),M3(Meta ObjectFacility).Forinstance,AgentDSLisadomain-specificlanguageforcrosscuttingconcernsforagents,whichissupportingaspect-orientedprogramming,and non-crosscuttingconcerns[18].TheauthorsofAgentDSLdefinesacodegenerator thatmapsabstractions.

4Implementation

Principally,theselectionofthegeneral-purposelanguageisanimportantparameterregardingtheimplementationofcodegeneratorsbecausesomelanguagesgive native-insupportforcustomannotations.Forinstance,Javaprogramminglanguage supportsAnnotationProcessorwhichisequivalenttoaplug-inofthecompiler.

4.1AlgorithmoftheCodeGenerationwithMetaprogramming

RuntimeorCompile

roundEnvironment.getElementsAnnotatedWith(classname) scanforelements

AgentImplementautoImplement=element.getAnnotation(AgentGenerator.class);

13: endwhile

14: endprocedure

Theafore-mentionedalgorithmcanbeusedwithanygeneral-purposelanguageeven thoughithasbeenmentionedforJavalanguage.Moreorless,theannotationprocessfollowsstepsthathavealreadybeenexplainedtoreaders.Themostimportant pointabouteithertheRetentionPolicyshouldassignparticularconfigurationsat runtimeorgeneratecodebaseatthecompiletime.Thedevelopershoulddecidethe behaviorbeforeitwasdevelopedinagent-orientedframeworks.

International
10, No 2,
2021 9
Journal of Security, Privacy and Trust Management (IJSPTM) Vol
May

4.2Template-basedCodeGeneration

ApacheVelocity3 isatemplateprojectthathasbeenprovidedbyApacheFoundation.Templatescantakeinputsinternallyorexternallythroughgeneral-purpose language.Oneofthedisadvantagesregardingtemplateshaslackofvalidationsteps atthecompiletime.Nevertheless,thisissuecanbesolvedbypostcompile-time validation.Generatedsourcecodecanbeintegratedwithcompilerplugininorder tocheckdatatypevalidation.Thefollowingcodesnippethasbeendemonstrated asbelow:

1 package ${packagename};

2 #set($classkeyword= " class " )

3 #set($classwithString= " class toString () " )

4 #set($dfDescription= " DFDescription " )

5 #set($agentID= " setName ( getAID () ) ; " )

6 #set($addServices= " . addServices ( serviceDescription ) ; " )

7

10 public class ${entity} extends Agents{ 11 private static final long serialVersionUID=1L; 12 13 // 14 // AGENT SPECIFIC FUNCTIONS 15 // 16 17 public void setup(){ 18 19 addBehaviour(getAgentBehaviour( this ,$entity$classkeyword}; 20 DFAgentDescription$entity$dfDescription= new DFDescription(); 21 $entity$dfDescription$agentID 22 ServiceDescriptionserviceDescription= new ServiceDescription(); 23 serviceDescription.setType($entity$classwithString); 24 serviceDescription.setName($entity$classkeyword); 25 $entity$dfDescription$addServices 26 try { 27 DFService.register( this ,$entity$dfDescription); 28 } catch (Exceptionex) 29 { 30 ex.printStackTrace(); 31 } 32 } 33 34 protected void takeDown(){ 35 doDelete(); 36 } 37 } 3 https://velocity.apache.org/ International
10
8 import jade.core.Agent; 9
Journal of Security, Privacy and Trust Management (IJSPTM) Vol 10, No 2, May 2021

Aftercompilingtheprogramfromatemplate,avalidationstepmustbedone byanexternalapplicationprogrammableinterface(API).MostoftheprogramminglanguagesprovidetheCompilerAPIthatmightgeneratediagnosticsduring compilationsuchaserrormessages,warning-debug-infolevellogs 4 .Anembedded compilerpluginisabetterwaytodoit;however,externalcompilerAPIcantest theapplicationbetweenmultipleversionsanditprovidesplentyofbenefitstothe agentapplicationprogrammer.Inthefollowingcodesnippet,thecodebasehasbeen takenfromtheJThereumProject 5

Thefollowinglinesshowusageneratedcodebasefromastatefulsmartcontract language.

1 */ 2 pragmasolidity^0.5.9; 3 contractSimpleEventDemo 4 { 5 functionemitEvents(stringmemorystr1,stringmemorystr2) public 6 { 7 emitSimpleEvent(str1,str2, false ); 8 emitSimpleEvent(str2,str1, false ); 9 } 10 eventSimpleEvent(stringstr1,stringstr2,boolswitched); 11 12 13 } Listing1.1. GeneratedSolidityStatefulContract [H] 1 public class App implements ContractProxyHelper 2 { 3 4 public void emitACoupleOfEvents(Strings1,Strings2){ 5 ContractStaticImports.emitEvent( new SimpleEvent(s1,s2, false )); 6 ContractStaticImports.emitEvent( new SimpleEvent(s2,s1, false )); 7 } 8 9 @EventClass 10 static class SimpleEvent extends EventClassHelper{ 11 final Strings1; 12 13 final Strings2; 14 15 final boolean switched; 16 17 public SimpleEvent(Strings1,Strings2, boolean switched){ 4 https://docs.oracle.com/javase/8/docs/api/javax/tools/JavaCompiler.html 5 https://jthereum.com/ International
10, No
11
Journal of Security, Privacy and Trust Management (IJSPTM) Vol
2, May 2021

4.3Metaprogramming

Metaprogrammingistheabilitytowriteprogramsthatgeneratesourcecodedefinedbydevelopers[19].Beyondthatinsomeprogramminglanguagessuchas GroovyandRuby,onecanchangethebehaviorofexistingmethodsinorderfor realizingdynamicmetaprogramming.Forinstance,Javaofferstwotypesofstatic metaprogrammingsuchasannotationprocessingandaspect-orientedprogramming togeneratecodebase;however,dynamicmetaprogrammingcanbeachievedbyexternalthird-partylibraries.

Ameta-objectprotocol(MOP)representsthesemanticoftheextendibilitythat residesinaprogramminglanguage.Thebehavioroftheprogramisdeterminedby theMOP,includingtheaspectoftheprograminruntimeandcompile-time[19].

Everyaspectofaprogram’smappingdownontothelowerlevelsubstratethat iscontrolledbyobjectsincompileorruntime 6 .Theseobjectsarecalledmetaobjects,becausetheprimarydutyoftheseobjectsistomaptheprogram,notto representthepredefineddomain.Forinstance,thejava.lang.reflectpackageinJava, onecancreateaself-configuringsystemwithpluggableannotationsandtemplates.

Principally,metaprogrammingisdividedintotwomainparts,whichareruntime metaprogrammingandcompile-timemetaprogramming.Compile-timemetaprogrammingletsyouorganizegeneratedcodebaseatcompiletime.Youcanperform syntactictransformationsandcodeoptimizationleveltointeractwiththecompiler duringthecodegenerationphase[19].

5CaseStudy

Manufacturingschedulingistheprocessofassignmentoftimingfororder,manufacturing,anddelivery.Soweshouldprovideagoodqualityperunitandthenumber ofunitsshouldbemaximizedperslotintheproductionline.Atthesametime,we needtominimizethewasteofresourcerequirementsandpotentialfailures.Basically,thenextstateofsmartcontractsinablockchainenvironmentiscompletely determinedbythecurrentstate.

Wecancreateroletypes,naturaltypesandcompartmenttypesinorderforimplementingasamplecaseforGasMASklikeinthefollowingfigure1.Wewouldlike 6 https://wiki.c2.com/?MetaObjectProtocol

18 this .s1=s1; 19 this .s2=s2; 20 this .switched=switched; 21 } 22 }
Listing1.2. JavaContractGenerator
International
10, No 2, May 2021 12
Journal of Security, Privacy and Trust Management (IJSPTM) Vol

toimplementasupplychainmodelingbyrealizingdatastructuresinrole-oriented programminginsmartcontracts.Smartcontractswilltakethedatastructureand evaluatetheminobject-orientedprogrammingwithpreconditionsandpostconditionsastheunittestingframeworkdoes.

Aproducttypeiscreatedforamanufacturingsimulationtosimulatebetween retailer,wholesaler,andmanufacturingcompany.Whenwedefinedtypeofdata structuresforroles,theywillbecreatethroughannotationprocessingbydeploying inablockchainnetwork.Alloftheparticipantswillseeevents,transactionsand valuesintheblockchainnetworkandthetypeofblockchainnetworkwillbepermissionedblockchaintoprovidesecurityandtrust.RetailerProduct,WholeslarProduct,andFactoryProductaretheabstracttypesthatareimplementedfromProduct type.Thesetypeswillbeusedforagents’behavior.NaturaltypesinFigure1are goingtobeinSoliditylanguagesothatonecanusethemforverificationand immutablebehaviors.

Fig.1. Exampleoftheroletypes
International Journal of Security, Privacy and Trust Management (IJSPTM) Vol 10, No 2, May 2021 13

6Conclusion

Thepaperaddressedthechallengeofcompellingtrustandsecurityinmulti-agent systemsandtheirrole-orientedfeaturesbyrealizingsmartcontractsregarding blockchaintechnology(BCT).Themainpurposeoftheresearchistogiveanew approachtotheintersectionbetweensmartcontractprogramming,role-oriented programming,andagent-orientedprogramming.Thecourseoffindingsamongvariousresearchareasguidesustodesignadomain-specificlanguagetocontributeto themulti-agentsystemarea.

– Thereisnocommonunderstandingintermsofmulti-agentsystemmethodology,analysis,design,orimplementation.Thisincreasesthecomplexityofthe researchinthemulti-agentsystemarea.

Thelimitednumberofdomain-drivenagent-orientedlanguageshavebeenprovidedsothatonecannoticethatmulti-agentsystemresearchismostlikely conceptualanditdoesnotprovideprototypeandresult-evaluatedresearch.

Synthesizedmetamodelingfromscratchindifferentresearchareascanbeambiguous;thus,webelievethatembeddeddomain-specificlanguagewithblockchain cansolvemostoftheproblemsformulti-agentsystems.

– Role-orientedprogrammingwithsmartcontractsischallengingbecausethe choicesoftechnologycanaffecttheresultofthestudy.Forinstance,statefulandstatelesscontractsarenotadvancedtechnologiesthatcanemployallof thefeaturesoftheobject-orientedparadigm.Turingcompleteandnon-Turing completetechnologieswillbescrutinizedinfuturework.Inanutshell,thispaperpresentedanewsignificantroleapproachwithsmartcontractprogramming implementinghashdatastructureandprovidingdatasecu-rityregardingroles. Presentingourapproachwillsimplifytheapplicationdevelop-mentprocessfor furtherresearchers.

Inparticular,thisstudyinspectsrole-orientedmulti-agentsystemsregarding domain-drivendesignandblockchaintechnologyinmulti-agentsystemsseparately. Thecourseoffindingcommonpointsbetweenvariousresearchareasguidesusto designadomain-specificlanguagetocontributetothemulti-agentsystemarea. Thereisnocommonunderstandingintermsofmulti-agentsystemmethodology, analysis,design,orimplementation.Thisincreasesthecomplexityoftheresearchin themulti-agentsystemarea.Thelimitednumberofdomain-drivenagent-oriented languageshavebeenprovidedsothatonecannoticethatmulti-agentsystemresearchismostlikelyconceptualanditdoesnotprovideprototypeandresultevaluatedresearch.Synthesizedmetamodelingfromscratchindifferentresearch areascanbeambiguous;thus,webelievethatembeddeddomain-specificlanguage withblockchaincansolvemostoftheproblemsformulti-agentsystems.Consequently,thispaperpresentedanewsignificantroleapproachwithsmartcontract

14
International Journal of Security, Privacy and Trust Management (IJSPTM) Vol 10, No 2, May 2021

programmingtoencryptdataandtoprovidedatasecurityregardingroles.Introducingthisapproachwillsimplifytheapplicationdevelopmentprocesswithan embeddeddomainspecificlanguage.

7FutureWork

Infuturework,wewillfocusonthefollowingfeatures:

RuntimemetaprogrammingextendabilityoftheGasMASkcodegeneration.

Dynamicsmartcontractintegrationintotheembedded-domainspecificlanguage.

Wewillresearchontheruntimefeatureofcodegenerationwithastatically typedlanguage,whichmeansthatalanguagecandotypecheckingthetypeof variableatcompiletime.Mostofthedynamicallytypedlanguagecanhandlethis; however,mostoftheagentframeworksarewritteninastaticallytypedlanguage. Anotherconsiderationwouldberegardingroletypesandnaturaltypesatruntime adaptability.Separately,wewillconductresearchondynamicadaptabilityona deterministicblockchainenvironment.

Acknowledgements

Theauthorwouldliketothankhissupervisors,Prof.Dr.UweAßmann,andProf. Dr.SusanneStrahringer,forthepatientguidance,encouragement,andcomments theyhaveprovidedtoshapehisdoctoralvision.ThisworkisfundedbytheGerman Research(DFG)withintheResearchTrainingGroupRole-BasedSoftwareInfrastructuresforcontinuous-context-sensitiveSystems(GRK1907,TUDresden,SoftwareTechnologyGroup,N¨othnitzerStraße46,01187,Dresden).

References

1. Index.JohnWileyandSons,Ltd,2004,pp.221–225.[Online].Available:https: //onlinelibrary.wiley.com/doi/abs/10.1002/0470861223.index

2. B.M.Balachandran,“Developingintelligentagentapplicationswithjadeandjess,”in Knowledge-BasedIntelligentInformationandEngineeringSystems,I.Lovrek,R.J.Howlett, andL.C.Jain,Eds.Berlin,Heidelberg:SpringerBerlinHeidelberg,2008,pp.236–244.

3. J.A.M.vandenBrandA.SerebrenikJ.J.Brunekree, CodeGenerationwithTemplates.John WileyandSons,Ltd,2006,pp.221–225.

4. S.RussellandP.Norvig, ArtificialIntelligence:AModernApproach,3rded.USA:Prentice HallPress,2009.

5. N.Gaur,L.Desrosiers,P.Novotny,V.Ramakrishna,A.O’Dowd,andS.A.Baset, Hands-On BlockchainwithHyperledger:BuildingDecentralizedApplicationswithHyperledgerFabricand Composer.PacktPublishing,2018.

6. N.Taing,T.Springer,N.Cardozo,andA.Schill,“Adynamicinstancebindingmechanism supportingrun-timevariabilityofrole-basedsoftwaresystems,”032016,pp.137–142.

15
International Journal of Security, Privacy and Trust Management (IJSPTM) Vol 10, No 2, May 2021

7. N.UbayashiandT.Tamai,“Roleep:Rolebasedevolutionaryprogrammingforcooperative mobileagentapplications,” PrinciplesofSoftwareEvolution,InternationalSymposiumon, vol.0,p.232,Nov.2000.

8. B.FerreiraandA.Leit˜ao,“Context-orientedalgorithmicdesign,”in SLATE,2018.

9. K.WanandV.Alagar,“Acontext-awaretrustmodelforservice-orientedmulti-agent systems,”in Service-OrientedComputing–ICSOC2008Workshops,G.Feuerlichtand W.Lamersdorf,Eds.Berlin,Heidelberg:SpringerBerlinHeidelberg,2009,pp.221–236.

10. T.K¨uhn,S.B¨ohme,S.G¨otz,andU.Aßmann,“Acombinedformalmodelforrelational context-dependentroles,”in Proceedingsofthe2015ACMSIGPLANInternational ConferenceonSoftwareLanguageEngineering,ser.SLE2015.NewYork,NY, USA:AssociationforComputingMachinery,2015,p.113–124.[Online].Available: https://doi.org/10.1145/2814251.2814255

11. I.Bashir, Advancedblockchaindevelopment:buildhighlysecure,decentralizedapplicationsand conductsecuretransactions,1sted.,ser.Learningpath.Birmingham;:PacktPublishing, 2019.

12. A.Imeri,J.Lamont,N.Agoulmine,andD.Khadraoui,“Modelofdynamicsmartcontractfor permissionedblockchains,”112019.

13. J.FerberandO.Gutknecht,“Ameta-modelfortheanalysisanddesignoforganizationsin multi-agentsystems,”Feb.1970.

14. G.Cabri,L.Leonardi,L.Ferrari,andF.Zambonelli,“Role-basedsoftwareagentinteraction models:Asurvey,” KnowledgeEng.Review,vol.25,pp.397–419,Dec.2010.

15. G.Cabri,L.Leonardi,andF.Zambonelli,“Implementingrole-basedinteractionsforinternet agents,”Feb.2003,pp.380–387.

16. Cabri,GiacomoandLeonardi,LetiziaandZambonelli,Franco,“Brain:Aframeworkforflexiblerole-basedinteractionsinmultiagentsystems,”vol.2888,Nov.2003,pp.145–161.

17. A.Shukla,S.K.Mohalik,andR.Badrinath,“Smartcontractsformultiagentplanexecution inuntrustedcyber-physicalsystems,”in 2018IEEE25thInternationalConferenceonHigh PerformanceComputingWorkshops(HiPCW),2018,pp.86–94.

18. U.Kulesza,A.Garcia,C.Lucena,andP.Alencar,“Agenerativeapproachformulti-agent systemdevelopment,”vol.3390,May2004,pp.52–69.

19. D.Ghosh, DSLsinAction,1sted.USA:ManningPublicationsCo.,2010.

Author

Or¸cunOru¸c receivedM.Sc.fromTUChemnitz,andhegraduatedfromKocaeli UniversitywithaB.Sc.degree.Currently,heispursuinghisPh.D.inComputer Engineering-SoftwareTechnologyattheDresdenTechnicalUniversity.Hisresearch interestsincludeprogramminglanguages,multi-agentsystems,role-orientedprogramming,naturallanguageprocessing,decentralized,anddistributedapplications.

International Journal
(IJSPTM) Vol 10, No 2, May 2021 16
of Security, Privacy and Trust Management

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.