Online Detection of Effectively Callback-Free Objects with Applications to Smart Contracts

online detection of effectively callback free n.w
1 / 62
Embed
Share

Explore the concept of effectively callback-free objects and their significance in smart contracts. Delve into modular reasoning, evolving systems, Ethereum applications, and the notion of correctness within this innovative framework.

  • Online Detection
  • Smart Contracts
  • Modular Reasoning
  • Ethereum
  • Correctness

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Online Detection of Effectively Callback Free Objects with Applications to Smart Contracts Shelly Grossman Ittai Abraham Guy Golan-Gueta Yan Michalevsky Noam Rinetzky Mooly Sagiv Yoni Zohar

  2. Online Detection of Effectively Callback Free Objects with Applications to Smart Contracts Shelly Grossman Ittai Abraham Guy Golan-Gueta Yan Michalevsky Noam Rinetzky Mooly Sagiv Yoni Zohar

  3. Motivation: Modular Reasoning

  4. Modular Systems int X = 100 .... dec(a){ log(a) } inc(b){ X += b } int Z = 4 log(b){ Z = b } int T=0 f(q,e) { f(t, e) }

  5. Modular Systems dec(100) int X = 100 .... dec(a){ log(a) } inc(b){ X += b } int Z = 4 log(b){ Z = b } int T=0 f(q,e) { f(t, e) } f(1,2)

  6. Evolving Modular Systems int X = 100 .... dec(a){ log(a) } inc(b){ X += b } int Z = 4 log(b){ z = b } int T=0 f(q,e) { f(t, e) } .

  7. Evolving Modular Systems int X = 100 .... dec(a){ log(a) } inc(b){ X += b } log(b){ dec(b) } int T=0 f(q,e) { f(t, e) } .

  8. Evolving Modular Systems are Real int X = 100 .... dec(a){ log(a) } inc(b){ X += b } log(b){ dec(b) } int T=0 f(q,e) { f(t, e) } Ethereum .

  9. Meta Reasoning

  10. Notion of Correctness? int X = 100 .... dec(a){ log(a) } inc(b){ X += b } log(b){ dec(b) } int T=0 f(q,e) { f(t, e) } .

  11. Modular Correctness: ?.Blue? P int X = 100 dec(a){ log(a) } inc(b){ X += b }

  12. Modular Reasoning int X = 100 dec(a){ log(a) } inc(b){ X += b }

  13. The Challenge

  14. Encapsulation Modular Reasoning? module Blue int X := 100 void dec(a) if (X >= a) log(a) X := X a @Inv:X 0?

  15. Encapsulation Modular Reasoning? module Blue int X := 100 void dec(a) if (X >= a) log(a) X := X a @Inv:X 0?

  16. Encapsulation Modular Reasoning? module Blue int X := 100 X 0 void dec(a) if (X >= a) log(a) X := X a @Inv:X 0?

  17. Encapsulation Modular Reasoning? module Blue int X := 100 X 0 void dec(a) if (X >= a) log(a) X := X a X 0 X a @Inv:X 0?

  18. Encapsulation Modular Reasoning? module Blue int X := 100 X 0 void dec(a) if (X >= a) log(a) X := X a X 0 X a @Inv: X 0?

  19. Encapsulation Modular Reasoning module Red module Blue int X := 100 void log(a) if (*) dec(a) void dec(a) if (X >= a) log(a) X := X a

  20. Encapsulation Modular Reasoning module Red module Blue int X := 100 void log(a) if (*) dec(a) void dec(a) if (X >= a) log(a) X := X a X a X a Store: X=100 X=0 X=-100 dec(100) Blue Red Blue Red Stack/ Trace: log(100) dec(100) log(100)

  21. The Challenge: Callbacks int X = 100 dec(a){ log(a) } int Z = 4 log(b){ dec(b) } ... dec(100) Blue log(100) Red Blue or inc(100) dec(100)

  22. Do We Really Need Callbacks?

  23. Do We Really Need Callbacks? Yes

  24. Do We Really Need Callbacks? Yes Essential when there is no shared state

  25. Do We Really Need Callbacks? Yes Essential when there is no shared state Increasing usage in Ethereum Ethereum

  26. Our Approach

  27. Effective Callback Freedom (ECF) Modular correctness condition(s) Final-State ECF (ECFFS) Conflict ECF (ECFC) Tames callbacks Enables modular reasoning

  28. Final-State Effective Callback Freedom

  29. Complete Executions An execution? = s0 sn is complete if ?0 ?? ? =

  30. Final State Effective Callback Freedom A completeexecution? is ECFFS for an object O if ? = ?0 ?k . i. ?i is complete ? has no callbacks first(? )|O = first(?)|O last(? )|O = last(?)|O

  31. Final State Effective Callback Freedom A completeexecution? is ECFFS for an object O if ? = ?0 ?k . i. ?i is complete ? has no callbacks first(? )|O = first(?)|O last(? )|O = last(?)|O ?0 ?? ? =

  32. Final State Effective Callback Freedom A completeexecution? is ECFFS for an object O if ? = ?0 ?k . i. ?i is complete ? has no callbacks first(? )|O = first(?)|O last(? )|O = last(?)|O ?0 ?? ? = Callback

  33. Final State Effective Callback Freedom A completeexecution? is ECFFS for an object O if ? = ?0 ?k . i. ?i is complete ? has no callbacks first(? )|O = first(?)|O last(? )|O = last(?)|O ?0 ?? ? = ? = ?0 ??

  34. Final State Effective Callback Freedom A completeexecution? is ECFFS for an object O if ? = ?0 ?k . i. ?i is complete ? has no callbacks first(? )|O = first(?)|O last(? )|O = last(?)|O ?0 ?? ? = ? = ?0 ?? |? |? ??|?= ?? ?0|?= ?0

  35. Final State Effective Callback Freedom A completeexecution? is ECFFS for an object O if ? = ?0 ?k . i. ?i is complete ? has no callbacks first(? )|O = first(?)|O last(? )|O = last(?)|O O? O? ? ?

  36. A Non ECFFS Execution for Blue module Red module Blue int X := 100 void log(a) if (*) dec(a) void dec(a) if (X >= a) log(a) X := X a X=100 X=0 Store: X=-100 dec(100) Blue Red Blue Red Stack/ Trace: log(100) dec(100) Callback log(100)

  37. A Non ECFFS Execution for Blue Every Execution is ECFFS for Blue module Red module Blue int X := 100 void log(a) if (*) dec(a) void dec(a) if (X >= a) log(a) X := X a log(a) X := X a X=100 X=100 Blue Red Blue X=0 X=0 Store: Store: X=-100 X=0 dec(100) dec(100) Blue Red Blue Red Stack/ Trace: Trace: Stack/ log(100) log(100) dec(100) dec(100) Callback Callback log(100)

  38. Real World Example: The DAO Attack 20June 2016: software bug in DAO, an Ethereum contract, led to a (temporary) theft of 3,500,000 ETH DAO attack exploited not ECF callbacks The DAO Ethereum

  39. Gist of DAO Attack DAO_withdraw(to) { if (shares[to] > 0) { to.send(shares[to]); shares[to] = 0 } }

  40. (Dynamic) ECFFS A completeexecution? is ECFFS for an object O ?0 ?? ? = if ? ? = ?0 ?? |? |? ??|?= ?? ?0|?= ?0

  41. (Dynamic) ECFFS A completeexecution? is ECFFS for an object O ?0 ?? ? = The state (of O) produced by the execution with callbacks can also be produced by a callback free execution if ? ? = ?0 ?? |? |? ??|?= ?? ?0|?= ?0

  42. Static ECFFS An objectO is static ECFFSif every complete execution is ECFFS for O

  43. Static ECFFS Modular Reasoning An objectO is static ECFFSif every complete execution is ECFFS for O module Blue int X := 100 X 0 void dec(a) if (X >= a) X := X a log(a) X 0 X a @Inv:X 0

  44. (Dynamic) ECFFS Modular Reasoning Provided we enforce ECFFSin runtime module Blue int X := 100 X 0 void dec(a) if (X >= a) log(a) X := X a X 0 X a @Inv:X 0

  45. Final-State Effective Callback Freedom Static ECFFS is undecidable Decidable if we have a finite data domain (Dynamic) ECFFS is undecidable We cannot check if an arbitrary execution is ECFFS

  46. Conflict Effective Callback Freedom

  47. Conflict Effective Callback Freedom A completeexecution? is ECFC for an object O if ? . ? is a permutation of the O invocations in ? preserving order of conflicting events

  48. Conflict Effective Callback Freedom A completeexecution? is ECFC for an object O if ? . ? is a permutation of the O invocations in ? preserving order of conflicting events ? =

  49. Conflict Effective Callback Freedom A completeexecution? is ECFC for an object O if ? . ? is a permutation of the O invocations in ? preserving order of conflicting events ? =

  50. Conflict Effective Callback Freedom A completeexecution? is ECFC for an object O if ? . ? is a permutation of the O invocations in ? preserving order of conflicting events ? = ? =

More Related Content