Skip to main content

Intelligence-Driven Optimization of Smart Contracts

  • Chapter
  • First Online:
Blockchain Intelligence
  • 1290 Accesses

Abstract

In this chapter, we present an overview on how smart contracts could be optimized by intelligence-driven approaches. We empirically study the repetitiveness of smart contracts via cluster analysis and try to extract differentiated codes from the similar contracts. Differentiated codes are defined as the source codes except the repeated ones in two similar smart contracts, usually illustrating how a software feature is implemented or a programming issue is solved. Then, a differentiated code might be used to guide the update of a smart contract in its next version. Finally, we apply syntax and semantic similarities to discover its similar smart contracts from more than 120,000 smart contracts, and recommend the differentiated codes to the target smart contracts.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 129.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 169.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 169.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    https://etherscan.io.

  2. 2.

    A standard interface for tokens. https://eips.ethereum.org/EIPS/eip-20.

References

  • Atzei, N., Bartoletti, M., & Cimoli, T. (2017). A survey of attacks on ethereum smart contracts (SoK). In M. Maffei & M. Ryan (Eds.), Principles of security and trust (pp. 164–186). Berlin: Springer. ISBN 978-3-662-54455-6.

    Chapter  Google Scholar 

  • Bartoletti, M., Carta, S., Cimoli, T., & Saia, R. (2017). Dissecting Ponzi schemes on Ethereum: identification, analysis, and impact. ArXiv e-prints.

    Google Scholar 

  • Baxter, I. D., Yahin, A., Moura, L., Sant’Anna, M., & Bier, L. (1998). Clone detection using abstract syntax trees. In Proceedings of the International Conference on Software Maintenance, ICSM ’98 (pp. 368–). Washington, DC, USA :IEEE Computer Society. ISBN 0-8186-8779-7. https://dl.acm.org/citation.cfm?id=850947.853341

  • Chen, T., Li, X., Luo, X., & Zhang, X. (2017). Under-optimized smart contracts devour your money. In 2017 IEEE 24th International Conference on Software Analysis, Evolution and Reengineering (SANER) (pp. 442–446). https://doi.org/10.1109/SANER.2017.7884650

  • Chen, T., Li, X., Wang, Y., Chen, J., Li, Z., Luo, X., et al. (2017). An adaptive gas cost mechanism for ethereum to defend against under-priced dos attacks. In J. K. Liu & P. Samarati (Eds.), Information Security Practice and Experience (pp. 3–24)/ Cham: Springer International Publishing. ISBN 978-3-319-72359-4.

    Google Scholar 

  • Chen, W., Zheng, Z., Cui, J., Ngai, E., Zheng, P., & Zhou, Y. (2018). Detecting ponzi schemes on ethereum: Towards healthier blockchain technology. In Proceedings of the 2018 World Wide Web Conference, WWW ’18 (pp. 1409–1418). Republic and Canton of Geneva, Switzerland. International World Wide Web Conferences Steering Committee. ISBN 978-1-4503-5639-8. https://doi.org/10.1145/3178876.3186046

  • Christidis, K., & Devetsikiotis, M. (2016). Blockchains and smart contracts for the internet of things. IEEE Access, 4, 2292–2303. ISSN 2169-3536. https://doi.org/10.1109/ACCESS.2016.2566339.

    Article  Google Scholar 

  • Dickerson, T., Gazzillo, P., Herlihy, M., & Koskinen, E. (2017). Adding concurrency to smart contracts. In Proceedings of the ACM Symposium on Principles of Distributed Computing, PODC ’17 (pp. 303–312). New York, NY, USA: ACM. ISBN 978-1-4503-4992-5. https://doi.org/10.1145/3087801.3087835.

    Chapter  Google Scholar 

  • Dinh, T. T. A., Liu, R., Zhang, M., Chen, G., Ooi, B. C., & Wang, J. (2018). Untangling blockchain: A data processing view of blockchain systems. IEEE Transactions on Knowledge and Data Engineering, 30 (7), 1366–1385. ISSN 1041-4347. https://doi.org/10.1109/TKDE.2017.2781227

    Article  Google Scholar 

  • Frantz, C. K., & Nowostawski, M. (2016). From institutions to code: Towards automated generation of smart contracts. In 2016 IEEE 1st International Workshops on Foundations and Applications of Self* Systems (FAS*W) (pp. 210–215). https://doi.org/10.1109/FAS-W.2016.53

  • Grossman, S., Abraham, I., Golan-Gueta, G., Michalevsky, Y., Rinetzky, N., Sagiv, M., et al. (2018). Online detection of effectively callback free objects with applications to smart contracts. CoRR. https://arxiv.org/abs/1801.04032

  • Hartigan, J. A., & Wong, M. A. (1979). Algorithm as 136: A k-means clustering algorithm. Journal of the Royal Statistical Society, 28(1), 100–108.

    MATH  Google Scholar 

  • He, X., Qin, B., Zhu, Y., Chen, X., & Liu, Y. (2018). Spesc: A specification language for smart contracts. In 2018 IEEE 42nd Annual Computer Software and Applications Conference (COMPSAC) (vol. 01, pp. 132–137). https://doi.org/10.1109/COMPSAC.2018.00025

  • Huang, Y., Chen, X., Liu, Z., Luo, X., & Zheng, Z. (2017). Using discriminative feature in software entities for relevance identification of code changes. Journal of Software: Evolution and Process, 29(7), e1859. https://doi.org/10.1002/smr.1859. https://onlinelibrary.wiley.com/doi/abs/10.1002/smr.1859

  • Huang, Y., Jia, N., Zhou, Q., Chen, X., Xiong, Y., & Luo, X. (2018). Guiding developers to make informative commenting decisions in source code. In Proceedings of the 40th International Conference on Software Engineering: Companion Proceeedings, ICSE ’18 (pp. 260–261). New York, NY, USA: ACM. ISBN 978-1-4503-5663-3. https://doi.org/10.1145/3183440.3194960

    Chapter  Google Scholar 

  • Jiang, J., Xiong, Y., Zhang, H., Gao, Q., & Chen, X. (2018). Shaping program repair space with existing patches and similar code. In Proceedings of the 27th ACM SIGSOFT International Symposium on Software Testing and Analysis, ISSTA 2018 (pp. 298–309). New York, NY, USA: ACM. ISBN 978-1-4503-5699-2. https://doi.org/10.1145/3213846.3213871

    Chapter  Google Scholar 

  • Juels, A., Kosba, A., & Shi, E. (2016). The ring of gyges: Investigating the future of criminal smart contracts. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security, CCS ’16 (pp. 283–295). New York, NY, USA: ACM. ISBN 978-1-4503-4139-4. https://doi.org/10.1145/2976749.2978362

    Chapter  Google Scholar 

  • Kosba, A., Miller, A., Shi, E., Wen, Z., & Papamanthou, C. (2016). Hawk: The blockchain model of cryptography and privacy-preserving smart contracts. In 2016 IEEE Symposium on Security and Privacy (SP) (pp. 839–858). https://doi.org/10.1109/SP.2016.55

  • Luu, L., Chu, D.-H., Olickel, H., Saxena, P., & Hobor, A. (2016). Making smart contracts smarter. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security, CCS ’16 (pp. 254–269). New York, NY, USA: ACM. ISBN 978-1-4503-4139-4. https://doi.org/10.1145/2976749.2978309

    Chapter  Google Scholar 

  • Mikolov, T., Sutskever, I., Chen, K., Corrado, G., & Dean, J. (2013). Distributed representations of words and phrases and their compositionality. In Proceedings of the 26th International Conference on Neural Information Processing Systems, NIPS’13 (pp. 3111–3119). Red Hook, NY, USA: Curran Associates. https://dl.acm.org/citation.cfm?id=2999792.2999959

    Google Scholar 

  • Nakamoto, S. (2009). Bitcoin: A peer-to-peer electronic cash system. Cryptography Mailing list at https://metzdowd.com, 03 (2009)

  • Nick, S. (2008). The idea of smart contracts (1997). https://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/idea.html

    Google Scholar 

  • Norta, A. (2015). Creation of smart-contracting collaborations for decentralized autonomous organizations. In Perspectives in Business Informatics Research (pp. 3–17). Cham: Springer International Publishing. ISBN 978-3-319-21915-8.

    Chapter  Google Scholar 

  • Oliva, J., Serrano, J. I., Del Castillo, M. D., & Iglesias, Á. (2011). SyMSS: A syntax-based measure for short-text semantic similarity. Data & Knowledge Engineering, 70(4), 390–405.

    Article  Google Scholar 

  • Ostrom, E. (1995). A grammar of institutions. American Political Science Review, 89(3), 582–600.

    Article  Google Scholar 

  • Porru, S., Pinna, A., Marchesi, M., & Tonelli, R. (2017). Blockchain-oriented software engineering: Challenges and new directions. In 2017 IEEE/ACM 39th International Conference on Software Engineering Companion (ICSE-C) (pp. 169–171). https://doi.org/10.1109/ICSE-C.2017.142

  • Roy, C. K., Cordy, J. R., & Koschke, R. (2009). Comparison and evaluation of code clone detection techniques and tools: A qualitative approach. Science of Computer Programming, 74(7), 470–495. ISSN 0167-6423. https://doi.org/10.1016/j.scico.2009.02.007

    Article  MathSciNet  Google Scholar 

  • Sapirshtein, A., Sompolinsky, Y., & Zohar, A. (2017). Optimal selfish mining strategies in bitcoin. In International Conference on Financial Cryptography and Data Security. Lecture Notes in Computer Science (vol. 9603, pp 515–532) Christ Church, Barbados.

    Google Scholar 

  • Wettel, R., & Marinescu, R. (2005). Archeology of code duplication: recovering duplication chains from small duplication fragments. In Seventh International Symposium on Symbolic and Numeric Algorithms for Scientific Computing (SYNASC’05) (p. 8,). https://doi.org/10.1109/SYNASC.2005.20

  • Yu, L., Tsai, W., Li, G., Yao, Y., Hu, C., & Deng, E. (2017). Smart-contract execution with concurrent block building. In 2017 11th IEEE Symposium on Service-Oriented System Engineering (SOSE) (pp. 160–167). Los Alamitos, CA, USA: IEEE Computer Society. https://doi.org/10.1109/SOSE.2017.33. https://doi.ieeecomputersociety.org/10.1109/SOSE.2017.33

  • Yue, R., Gao, Z., Meng, N., Xiong, Y., Wang, X., & Morgenthaler, J. D. (2018). Automatic clone recommendation for refactoring based on the present and the past. In 2018 IEEE International Conference on Software Maintenance and Evolution (ICSME) (pp. 115–126). https://doi.org/10.1109/ICSME.2018.00021

  • Zheng, P., Zheng, Z., Luo, X., Chen, X., & Liu, X. (2018). A detailed and real-time performance monitoring framework for blockchain systems. In International Conference on Software Engineering Software Engineering in Practice - ICSE-SEIP ’18 (pp. 134–143, 05). https://doi.org/10.1145/3183519.3183546

  • Zheng, Z., Xie, S., Dai, H., Chen, X., & Wang, H. (2017). An overview of blockchain technology: Architecture, consensus, and future trends. In 2017 IEEE International Congress on Big Data (BigData Congress) (pp. 557–564). https://doi.org/10.1109/BigDataCongress.2017.85

  • Zhu, J., He, P., Fu, Q., Zhang, H., Lyu, M. R., & Zhang, D. (2015). Learning to log: Helping developers make informed logging decisions. In Proceedings of the 37th International Conference on Software Engineering - Volume 1, ICSE ’15 (pp. 415–425). Piscataway, NJ, USA: IEEE Press. ISBN 978-1-4799-1934-5. https://dl.acm.org/citation.cfm?id=2818754.2818807

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Xiangping Chen .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Huang, Y., Kong, Q., Jia, N., Chen, X., Zheng, Z. (2021). Intelligence-Driven Optimization of Smart Contracts. In: Zheng, Z., Dai, HN., Wu, J. (eds) Blockchain Intelligence. Springer, Singapore. https://doi.org/10.1007/978-981-16-0127-9_4

Download citation

  • DOI: https://doi.org/10.1007/978-981-16-0127-9_4

  • Published:

  • Publisher Name: Springer, Singapore

  • Print ISBN: 978-981-16-0126-2

  • Online ISBN: 978-981-16-0127-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics