KR102529028B1 - Method And Apparatus for Generating Proxy Contract - Google Patents

Method And Apparatus for Generating Proxy Contract Download PDF

Info

Publication number
KR102529028B1
KR102529028B1 KR1020210086311A KR20210086311A KR102529028B1 KR 102529028 B1 KR102529028 B1 KR 102529028B1 KR 1020210086311 A KR1020210086311 A KR 1020210086311A KR 20210086311 A KR20210086311 A KR 20210086311A KR 102529028 B1 KR102529028 B1 KR 102529028B1
Authority
KR
South Korea
Prior art keywords
execution
contract
proxy contract
flow
cost
Prior art date
Application number
KR1020210086311A
Other languages
Korean (ko)
Other versions
KR20230005508A (en
Inventor
한동수
김정민
이종협
Original Assignee
한국과학기술원
주식회사 파이랩테크놀로지
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 한국과학기술원, 주식회사 파이랩테크놀로지 filed Critical 한국과학기술원
Priority to KR1020210086311A priority Critical patent/KR102529028B1/en
Publication of KR20230005508A publication Critical patent/KR20230005508A/en
Application granted granted Critical
Publication of KR102529028B1 publication Critical patent/KR102529028B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/606Protecting data by securing the transmission between two devices or processes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/3005Arrangements for executing specific machine instructions to perform operations for flow control
    • G06F9/30058Conditional branch instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • G06F9/30072Arrangements for executing specific machine instructions to perform conditional operations, e.g. using predicates or guards
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements
    • G06F9/3012Organisation of register space, e.g. banked or distributed register file
    • G06F9/30134Register stacks; shift registers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/04Payment circuits
    • G06Q20/06Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme
    • G06Q20/065Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Business, Economics & Management (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

본 개시는 프록시 컨트랙트 생성방법 및 장치를 제공한다. 본 개시의 일 측면에 의하면, 실행 흐름에 요구되는 수행 비용 및/또는 스택 크기를 이용하여 상태 불일치 검사를 수행하는 프록시 컨트랙트를 생성하여 각 실행 흐름이 상태 불일치를 유발하지 않도록 보장하는 프록시 컨트랙트 생성방법 및 장치를 제공한다.This disclosure provides a method and apparatus for generating a proxy contract. According to one aspect of the present disclosure, a proxy contract creation method that ensures that each execution flow does not cause state inconsistency by creating a proxy contract that performs a state inconsistency check using execution cost and/or stack size required for an execution flow. and devices.

Description

프록시 컨트랙트 생성방법 및 장치 {Method And Apparatus for Generating Proxy Contract}Proxy contract generation method and device {Method And Apparatus for Generating Proxy Contract}

본 개시는 프록시 컨트랙트 생성방법 및 장치에 관한 것이다. 본 개시는 과학기술정보통신부의 블록체인 에뮬레이션을 위한 모듈형 라이브러리 및 엔진 기술 개발의 일환으로 수행한 연구로부터 도출된 것이다. [과제고유번호: 2020-0-00191, 과제명: 블록체인 에뮬레이션을 위한 모듈형 라이브러리 및 엔진 기술 개발] The present disclosure relates to a method and apparatus for generating a proxy contract. The present disclosure is derived from research conducted as part of the development of modular library and engine technology for block chain emulation by the Ministry of Science and ICT. [Task identification number: 2020-0-00191, task title: Development of modular library and engine technology for blockchain emulation]

이 부분에 기술된 내용은 단순히 본 실시예에 대한 배경 정보를 제공할 뿐 종래기술을 구성하는 것은 아니다.The contents described in this part merely provide background information on the present embodiment and do not constitute prior art.

최근 디앱(Decentralized Application, DApp)을 기반으로 한 서비스가 증가하고 있다. 디앱이란, 블록체인 기술을 활용하여 서비스를 제공하는 탈중앙화된 애플리케이션으로서, 온 체인(On-Chain) 데이터의 데이터 무결성(data integrity)을 보장받는다. 디앱을 기반으로 제공되는 서비스 중에는 다중 컨트랙트(multiple on contracts) 기반의 서비스가 있다. Recently, services based on DApp (Decentralized Application, DApp) are increasing. A DApp is a decentralized application that provides services using blockchain technology, ensuring the data integrity of on-chain data. Among the services provided based on DApp, there are services based on multiple on contracts.

다중 스마트 컨트랙트란 데이터 접근 권한에 따라 다른 스마트 컨트랙트(smart contract)의 데이터에 접근이 가능하도록 구성된 스마트 컨트랙트들을 의미한다. 스마트 컨트랙트란 블록체인 환경에서 체결되고 이행되는 계약을 의미한다. 블록체인 네트워크상의 노드가 스마트 컨트랙트의 체결 조건을 만족하는 경우, 스마트 컨트랙트가 체결되어 스마트 컨트랙트의 코드가 실행된다. 이러한 스마트 컨트랙트의 코드를 실행하는 데에는 수행 비용(예: 이더리움(Etherium)의 가스(gas))이 필요하다. 스마트 컨트랙트의 내용과 체결 여부 등에 대한 상태 정보는 블록체인 네트워크의 온 체인 데이터가 되어 데이터 무결성을 보장받을 수 있다.Multiple smart contracts refer to smart contracts configured to access data of other smart contracts according to data access rights. A smart contract is a contract concluded and executed in a blockchain environment. When a node on the blockchain network satisfies the conditions for signing a smart contract, the smart contract is concluded and the code of the smart contract is executed. Executing the code of these smart contracts requires an execution cost (e.g. gas in Ethereum). State information on the contents of the smart contract and whether or not it has been signed becomes on-chain data of the blockchain network and data integrity can be guaranteed.

디앱이 다중 스마트 컨트랙트 기반의 서비스를 제공하기 위해서는 온 체인에서의 유동적인 실행 흐름(control flow 또는 execution flow)이 지원되어야 한다. 예컨대, low-level API(예: delegatecall) 등을 이용하여 변화된 실행 흐름에 대한 에러 처리 등이 지원되어야 한다. 스마트 컨트랙트의 실행에 있어 적절한 에러 처리가 이루어지지 않는 경우, 명령이 올바르게 실행되지 않았음에도 트랜잭션(transaction)이 정상적으로 종료된 것으로 처리되어 상태 불일치(state inconsistency) 문제가 발생할 수 있다. In order for DApp to provide services based on multiple smart contracts, a flexible execution flow (control flow or execution flow) on-chain must be supported. For example, error handling for the changed execution flow using low-level API (eg delegate call) should be supported. If proper error handling is not performed in the execution of the smart contract, the transaction is treated as normally terminated even though the command was not executed correctly, and a state inconsistency problem may occur.

도 1은 다중 스마트 컨트랙트 기반의 환경에서 상태 불일치가 발생하는 시나리오의 예시도이다.1 is an exemplary diagram of a scenario in which state inconsistency occurs in an environment based on multiple smart contracts.

사용자 노드가 스마트 컨트랙트 Z의 체결 조건을 만족하도록 트랜잭션을 발생시키면, 스마트 컨트랙트 Z의 코드가 실행이 된다. 스마트 컨트랙트 Z는 스마트 컨트랙트 A를 호출하여 스마트 컨트랙트 A의 코드가 실행되도록 한다. 이후, 스마트 컨트래트 Z는 low-level API를 통해 스마트 컨트랙트 B를 호출한다. 스마트 컨트랙트 B는 low-level API를 통해 스마트 컨트랙트 B를 호출하므로, 스마트 컨트랙트 Z에는 스마트 컨트랙트 B의 호출에 따른 예외 처리(exception handling)가 포함되어 있지 않는다. 따라서 스마트 컨트랙트 B가 성공적으로 수행되지 않아 예외 처리를 수행하는 경우에도 스마트 컨트랙트 Z는 컨트랙트가 정상적으로 수행된 것으로 처리하고, 블록체인상에는 사용자 노드가 요청한 트랜잭션이 성공적으로 수행된 것으로 기록되고, 블록체인 네트워크는 사용자 노드로부터 코드의 실행에 따른 수행 비용을 지급 처리한다.When a user node generates a transaction to satisfy the contract condition of smart contract Z, the code of smart contract Z is executed. Smart contract Z calls smart contract A, causing smart contract A's code to be executed. Then, smart contract Z calls smart contract B through low-level API. Since smart contract B calls smart contract B through low-level API, smart contract Z does not include exception handling for calls from smart contract B. Therefore, even if smart contract B is not executed successfully and exception processing is performed, smart contract Z treats the contract as normally executed, and the transaction requested by the user node is recorded as successfully executed on the blockchain, and the blockchain network pays the execution cost according to the execution of the code from the user node.

이러한 상태 불일치 문제는, 코드의 각 실행 흐름을 수행하기 위한 수행 비용이 부족하거나, 변화된 실행 흐름의 수행에 필요한 스택 공간이 이용할 수 있는 스택 공간의 크기를 초과하는 경우 또는 변화된 실행 흐름의 예외 처리의 부재로 발생한다. 일단 잘못된 트랜잭션 상태가 블록체인에 저장되면, 이후에는 오류를 정정할 수 없고, 새로운 스마트 컨트랙트로 스마트 컨트랙트를 대체하는 데에 큰 비용이 소요된다.This state inconsistency problem occurs when the execution cost for executing each execution flow of the code is insufficient, the stack space required to execute the changed execution flow exceeds the available stack space, or the exception handling of the changed execution flow occurs in the absence of Once an erroneous transaction state is stored in the blockchain, the error cannot be corrected afterwards, and replacing the smart contract with a new smart contract is costly.

따라서, 디앱이 사용자에게 안정적으로 서비스를 제공할 수 있도록, 코드 불변성을 유지하면서도 상태 불일치 문제를 방지할 수 있는 방안의 고안이 필요하다.Therefore, it is necessary to devise a method to prevent the state inconsistency problem while maintaining code invariance so that DApp can stably provide services to users.

본 개시의 일 측면에 의하면, 실행 흐름에 요구되는 수행 비용 및/또는 스택 크기를 이용하여 상태 불일치 검사를 수행하는 프록시 컨트랙트를 생성하여 각 실행 흐름이 상태 불일치를 유발하지 않도록 보장하는 프록시 컨트랙트 생성방법 및 장치를 제공하는 데 주된 목적이 있다.According to one aspect of the present disclosure, a proxy contract creation method that ensures that each execution flow does not cause state inconsistency by creating a proxy contract that performs a state inconsistency check using execution cost and/or stack size required for an execution flow. And there is a main purpose to provide a device.

본 개시의 일 측면에 의하면, 프록시 컨트랙트 생성장치가 프록시 컨트랙트를 생성하는 방법에 있어서, 스마트 컨트랙트의 코드로부터 실행 흐름(call-flow)을 추출하는 과정; 추출된 실행 흐름 중 어느 하나의 실행 흐름인 제1 실행 흐름의 수행에 요구되는 수행 비용 및/또는 상기 제1 실행 흐름의 수행에 요구되는 스택 크기(stack size)를 입력받는 과정; 및 상기 수행 비용 및/또는 상기 스택 크기를 기초로 상태 불일치(state inconsistency) 검사를 수행하는 프록시 컨트랙트(proxy contract)를 생성하는 과정을 포함하는, 프록시 컨트랙트 생성방법을 제공한다.According to one aspect of the present disclosure, in a method for generating a proxy contract by a proxy contract generator, the process of extracting a call-flow from the code of a smart contract; A process of receiving an execution cost required for execution of a first execution flow, which is any one of the extracted execution flows, and/or a stack size required for execution of the first execution flow; and generating a proxy contract that performs a state inconsistency check based on the execution cost and/or the stack size.

본 개시의 일 측면에 의하면, 스마트 컨트랙트의 코드로부터 실행 흐름(call-flow)을 추출하는 추출 모듈; 노드로부터, 추출된 실행 흐름 중 어느 하나의 실행 흐름인 제1 실행 흐름의 수행에 요구되는 수행 비용 및/또는 상기 제1 실행 흐름의 수행에 요구되는 스택 크기(stack size)를 입력받는 입력 모듈; 및 상기 수행 비용 및/또는 상기 스택 크기를 기초로 상태 불일치(state inconsistency) 검사를 수행하는 프록시 컨트랙트(proxy contract)를 생성하는 생성 모듈을 포함하는, 프록시 컨트랙트 생성장치를 제공한다.According to one aspect of the present disclosure, an extraction module for extracting a call-flow from the smart contract code; An input module that receives, from a node, an execution cost required for execution of a first execution flow, which is any one of the extracted execution flows, and/or a stack size required for execution of the first execution flow; and a generating module generating a proxy contract that performs a state inconsistency check based on the execution cost and/or the stack size.

본 개시의 일 측면에 의하면, 실행 흐름에 요구되는 수행 비용 및/또는 스택 크기를 이용하여 상태 불일치 검사를 수행하는 프록시 컨트랙트를 생성함으로써, 각 실행 흐름이 상태 불일치를 유발하지 않도록 보장하는 효과가 있다. According to one aspect of the present disclosure, by creating a proxy contract that performs a state inconsistency check using the execution cost and / or stack size required for the execution flow, there is an effect of ensuring that each execution flow does not cause state inconsistency. .

그에 따라, 프록시 컨트랙트 생성방법 및 장치를 이용하는 경우, 기 서비스 중인 스마트 컨트랙트의 코드를 변경하지 않고 취약점을 보호하여, 비정상적으로 수행된 트랜잭션에 대한 사용자의 수행 비용 지급을 방지하고, 서비스 제공자가 컨트랙트의 취약점을 파악하여 적절히 대응할 수 있도록 하는 효과가 있다.Accordingly, in the case of using the proxy contract creation method and device, vulnerabilities are protected without changing the code of the smart contract currently in service, preventing users from paying execution costs for abnormally performed transactions, and service providers It has the effect of identifying vulnerabilities and responding appropriately.

본 개시의 효과들은 이상에서 언급한 효과들로 제한되지 않으며, 언급되지 않은 또 다른 효과들은 아래의 기재로부터 통상의 기술자에게 명확하게 이해될 수 있을 것이다.The effects of the present disclosure are not limited to the effects mentioned above, and other effects not mentioned will be clearly understood by those skilled in the art from the description below.

도 1은 다중 스마트 컨트랙트 기반의 환경에서 상태 불일치가 발생하는 시나리오의 예시도이다.
도 2는 본 개시의 일 실시예에 따른 프록시 컨트랙트 생성장치를 나타내는 블록구성도이다.
도 3은 본 개시의 일 실시예에 따른 실행 흐름의 추출 방법을 나타내는 예시도이다.
도 4는 본 개시의 일 실시예에 따른 프록시 컨트랙트 생성방법을 수행하고, 프록시 컨트랙트 생성방법이 적용되는 과정을 나타내는 흐름도이다.
1 is an exemplary diagram of a scenario in which state inconsistency occurs in an environment based on multiple smart contracts.
2 is a block diagram showing an apparatus for generating a proxy contract according to an embodiment of the present disclosure.
3 is an exemplary view illustrating a method of extracting an execution flow according to an embodiment of the present disclosure.
4 is a flowchart illustrating a process of performing a proxy contract creation method according to an embodiment of the present disclosure and applying the proxy contract creation method.

이하, 본 개시의 일부 실시예들을 예시적인 도면을 통해 상세하게 설명한다. 각 도면의 구성요소들에 열람부호를 부가함에 있어서, 동일한 구성요소들에 대해서는 비록 다른 도면상에 표시되더라도 가능한 한 동일한 부호를 가지도록 하고 있음에 유의해야 한다. 또한, 본 개시를 설명함에 있어, 관련된 공지 구성 또는 기능에 대한 구체적인 설명이 본 개시의 요지를 흐릴 수 있다고 판단되는 경우에는 그 상세한 설명은 생략한다.Hereinafter, some embodiments of the present disclosure will be described in detail through exemplary drawings. In adding a reference code to the components of each drawing, it should be noted that the same components have the same numbers as much as possible even if they are displayed on different drawings. In addition, in describing the present disclosure, if it is determined that a detailed description of a related known configuration or function may obscure the gist of the present disclosure, the detailed description will be omitted.

또한, 본 개시의 구성 요소를 설명하는 데 있어서, 제2, 제1 등의 용어를 사용할 수 있다. 이러한 용어는 그 구성 요소를 다른 구성 요소와 구별하기 위한 것일 뿐, 그 용어에 의해 해당 구성 요소의 본질이나 차례 또는 순서 등이 한정되지 않는다. 명세서 전체에서, 어떤 부분이 어떤 구성요소를 '포함', '구비'한다고 할 때, 이는 특별히 반대되는 기재가 없는 한 다른 구성요소를 제외하는 것이 아니라 다른 구성요소를 더 포함할 수 있는 것을 의미한다. 또한, 명세서에 기재된 '…부', '모듈' 등의 용어는 적어도 하나의 기능이나 동작을 처리하는 단위를 의미하며, 이는 하드웨어나 소프트웨어 또는 하드웨어 및 소프트웨어의 결합으로 구현될 수 있다.In addition, in describing the components of the present disclosure, terms such as second and first may be used. These terms are only used to distinguish the component from other components, and the nature, order, or order of the corresponding component is not limited by the term. Throughout the specification, when a part 'includes' or 'includes' a certain component, it means that it may further include other components without excluding other components unless otherwise stated. . In addition, the '... Terms such as 'unit' and 'module' refer to a unit that processes at least one function or operation, and may be implemented as hardware, software, or a combination of hardware and software.

첨부된 도면과 함께 이하에 개시될 상세한 설명은 본 개시의 예시적인 실시형태를 설명하고자 하는 것이며, 본 개시가 실시될 수 있는 유일한 실시형태를 나타내고자 하는 것이 아니다.The detailed description set forth below in conjunction with the accompanying drawings is intended to describe exemplary embodiments of the present disclosure, and is not intended to represent the only embodiments in which the present disclosure may be practiced.

본 개시는 스마트 컨트랙트(smart contract)의 각 실행 흐름(control flow)의 수행에 요구되는 수행 비용과 스택 슬롯 길이를 기반으로 컨트랙트 수행의 상태 불일치(state inconsistency)가 발생하지 않도록 보장하는 프록시 컨트랙트(proxy contract)의 생성방법 및 장치를 개시한다.This disclosure is a proxy contract that guarantees that state inconsistency in contract execution does not occur based on the execution cost and stack slot length required for the execution of each control flow of the smart contract. contract) generation method and device are disclosed.

프록시 컨트랙트(proxy contract)는 사용자가 실행을 요청한 콜(function call 또는 명령)이 특정 로직 컨트랙트(logic contract)의 로직에 의해 실행되게 하는 스마트 컨트랙트이다. 프록시 컨트랙트는 요청받은 콜을 변조없이 로직 컨트랙트(logic contract) 또는 스마트 컨트랙트(smart contract)에 전달하기 위하여, delegateCall을 포함하는 폴백(fallback) 함수를 포함할 수 있다. A proxy contract is a smart contract that allows the user to request execution (function call or command) to be executed by the logic of a specific logic contract. The proxy contract may include a fallback function including delegateCall in order to transfer the requested call to a logic contract or smart contract without modification.

본 개시는 이더리움(Ethereum) 환경을 예를 들어 설명하나, 본 개시의 프록시 컨트랙트 생성방법 및 그를 위한 컴퓨터 프로그램이 블록체인 환경으로서 반드시 이더리움 환경에서만 수행되어야 하는 것은 아니다. 예컨대, 스마트 컨트랙트를 지원하면서 코드의 실행 흐름별로 수행 비용이 소요되는 블록체인 환경(예: 블록체인 2.0 이상의 환경)이라면 본 개시의 프록시 컨트랙트 생성방법 및 장치가 적용될 수 있다.Although the present disclosure describes an Ethereum environment as an example, the proxy contract creation method and computer program for the present disclosure do not necessarily have to be performed only in the Ethereum environment as a blockchain environment. For example, the proxy contract creation method and device of the present disclosure can be applied to a blockchain environment (eg, a blockchain 2.0 or higher environment) that supports smart contracts and requires execution costs for each execution flow of code.

도 2는 본 개시의 일 실시예에 따른 프록시 컨트랙트 생성장치를 나타내는 블록구성도이다.2 is a block diagram showing an apparatus for generating a proxy contract according to an embodiment of the present disclosure.

본 개시의 일 실시예에 따른 프록시 컨트랙트 생성장치(200)는 추출 모듈(extraction module, 202), 입력 모듈(input module, 204) 및 생성 모듈(generation module, 206)을 전부 또는 일부 포함한다. 도 2에 도시된 프록시 컨트랙트 생성장치(200)는 본 개시의 일 실시예에 따른 것으로서, 도 2에 도시된 모든 구성이 필수 구성요소는 아니며, 다른 실시예에서 일부 구성이 추가, 변경 또는 삭제될 수 있다. 예컨대, 다른 실시예에서 프록시 컨트랙트 생성장치는 실행 흐름의 수행에 요구되는 수행 비용 및/또는 실행 흐름의 수행에 요구되는 스택 슬롯 사이즈를 예측하여 입력 모듈에 전달하는 예측 모듈(prediction module, 미도시)을 더 포함할 수 있다.The proxy contract generating device 200 according to an embodiment of the present disclosure includes all or part of an extraction module 202, an input module 204, and a generation module 206. The proxy contract generating device 200 shown in FIG. 2 is according to an embodiment of the present disclosure, and all components shown in FIG. 2 are not essential components, and some components may be added, changed, or deleted in other embodiments. can For example, in another embodiment, the proxy contract generator predicts the execution cost required for execution flow and/or the stack slot size required for execution flow, and transmits it to the input module (prediction module (not shown)) may further include.

도 2는 프록시 컨트랙트 생성장치(200)를 장치로서 도시하였으나, 이는 설명의 편의를 위한 것으로, 다른 실시예에서 프록시 컨트랙트 생성장치는 각 구성(202 내지 206)의 기능을 수행하는 소프트웨어 모듈 또는 프로세서로 구현될 수 있다.2 shows the proxy contract generator 200 as a device, but this is for convenience of explanation. In another embodiment, the proxy contract generator is a software module or processor that performs the functions of each component 202 to 206. can be implemented

추출 모듈(202)은 스마트 컨트랙트의 코드로부터 실행 흐름(call-flow)을 추출한다. 실행 흐름을 추출하기 위하여, 추출 모듈(202)은 스마트 컨트랙트의 코드에 대한 추상 구문 트리(Abstract Syntax Tree, AST)를 생성할 수 있다. 여기서 추상 구문 트리란, 소스 코드(source code)의 추상 구문 구조를 나타내는 트리형 데이터 구조이다. 추출 모듈(202)은 스마트 컨트랙트의 코드에 대해 생성한 추상 구문 트리에 대하여 콜 그래프(call-graph)를 더 추출하여, 코드의 실행에 따른 개별 실행 흐름을 추출할 수 있다. 여기서 콜 그래프란, 프로그램의 서브 루틴 간의 호출 관계를 나타내는 실행 흐름의 그래프이다. 추상 구문 트리와 콜 그래프를 이용하여 실행 흐름을 추출하는 구체적인 예시는 도 3에서 후술한다.The extraction module 202 extracts the call-flow from the code of the smart contract. To extract the execution flow, the extraction module 202 may create an Abstract Syntax Tree (AST) for the code of the smart contract. Here, the abstract syntax tree is a tree-type data structure representing an abstract syntax structure of source code. The extraction module 202 may further extract a call-graph for the abstract syntax tree generated for the code of the smart contract, and extract individual execution flows according to the execution of the code. Here, the call graph is a graph of an execution flow showing a call relationship between subroutines of a program. A specific example of extracting an execution flow using an abstract syntax tree and a call graph will be described later with reference to FIG. 3 .

추출 모듈(202)이 추출한 실행 흐름에 대하여, 입력 모듈(204)은 별도의 사용자 또는 별도의 장치로부터 실행 흐름의 수행에 요구되는 수행 비용 및/또는 실행 흐름의 수행에 요구되는 스택 크기를 입력받는다. 여기서 별도의 사용자 또는 별도의 장치란, 스마트 컨트랙트 기반의 서비스를 제공하는 디앱(DApp, Decentralized Applicatoin)의 서비스 개발자/서비스 제공자 또는 이러한 서비스 개발자나 서비스 제공자가 서비스를 제공하기 위하여 이용하는 장치를 의미할 수 있다. 여기서 입력이란, 사용자가 입력 장치를 이용하여 수행 비용 및/또는 스택 크기가 입력되는 경우는 물론, 사용자가 사용자 단말의 유무선 통신 수단을 이용하여 수행 비용 및/또는 스택 사이즈를 수신하여 획득하는 경우를 모두 포함할 수 있다. 또한, 별도의 장치에 의한 입력이란 예컨대, 입력 장치를 이용한 입력 또는 유무선 통신 수단에 의한 입력을 모두 포함할 수 있다. 입력 모듈(204)에 입력되는 수행 비용 및/또는 스택 크기는 별도의 사용자 또는 별도의 장치가 예측한 값(또는 범주의 값)일 수 있다.With respect to the execution flow extracted by the extraction module 202, the input module 204 receives an execution cost required for execution of the execution flow and/or a stack size required for execution of the execution flow from a separate user or a separate device. . Here, a separate user or a separate device may refer to a service developer/service provider of DApp (Decentralized Applicatoin) that provides smart contract-based services, or a device used by such service developer or service provider to provide services. there is. Here, input refers to a case in which a user inputs an execution cost and/or a stack size using an input device as well as a case in which a user receives and obtains an execution cost and/or a stack size using a wired/wireless communication means of a user terminal. can include all In addition, input by a separate device may include, for example, both input using an input device or input using wired or wireless communication means. The execution cost and/or the stack size input to the input module 204 may be a value (or a range value) predicted by a separate user or a separate device.

블록체인 환경에서는 스마트 컨트랙트의 코드의 실행(또는 실행 흐름의 실행)이 블록체인 네트워크상의 임의의 노드에 의해 수행된다. 그에 따라, 본 개시에서 실행 흐름의 수행에 요구되는 수행 비용의 의미는, 코드의 실행(또는 실행 흐름의 실행)에 따른 수수료(또는 컴퓨팅 파워와 같이 실행으로 소모된 리소스의 가치)를 의미한다. 이더리움 환경에서는 코드를 실행하는 임의의 노드에게 코드가 실행된 만큼에 해당하는 가스(gas)가 제공된다. 트랜잭션을 요청하는 노드는 일정 Gwei와 가스 한도(gas limit)를 제시하며 트랜잭션을 요청할 수 있는데, 코드를 실행하는 임의의 노드는 가스 한도 내에서만 작업을 수행하게 된다. 그에 따라, 입력 모듈(204)은 수행비용으로서 가스 한도와 Gwei를 입력받거나, 가스를 입력받을 수 있다.In a blockchain environment, execution of smart contract code (or execution flow) is performed by any node on the blockchain network. Accordingly, in the present disclosure, the meaning of execution cost required for execution of an execution flow means a fee (or a value of resources consumed by execution such as computing power) according to execution of code (or execution of execution flow). In the Ethereum environment, gas corresponding to the number of times the code is executed is provided to any node that executes the code. A node requesting a transaction can request a transaction by presenting a certain Gwei and gas limit, and any node executing the code will only perform work within the gas limit. Accordingly, the input module 204 may receive gas limit and Gwei or gas as an execution cost.

입력 모듈(204)은 실행 흐름의 수행에 요구되는 최대 수행 비용 및/또는 최소 수행 비용을 수행 비용으로서 입력받을 수 있다. 입력 모듈(204)이 수행 비용으로 최대 수행 비용만을 입력받은 경우 프록시 컨트랙트는 0부터(단위는 각 블록체인 환경에 따라 달라질 수 있다) 입력받은 최대 수행 비용 범위 내에 실행 흐름이 실행되는지를 판단하여 상태 불일치 검사를 수행할 수 있다. 실행 흐름의 실행이 최대 수행 비용을 초과하는 경우 프록시 컨트랙트는 상태 불일치가 발생하였다고 판단하게 된다. 입력 모듈(204)이 수행 비용으로 최소 수행 비용만을 입력받은 경우 프록시 컨트랙트는 입력받은 최소 수행 비용 이상으로 실행 흐름이 실행되는지를 판단하여 상태 불일치 검사를 수행할 수 있다. 실행 흐름의 실행이 최소 수행 비용의 미만으로 수행되는 경우 프록시 컨트랙트는 상태 불일치가 발생하였다고 판단하게 된다.The input module 204 may receive a maximum execution cost and/or a minimum execution cost required for execution of the execution flow as an execution cost. When the input module 204 receives only the maximum execution cost as the execution cost, the proxy contract judges whether the execution flow is executed within the input maximum execution cost range from 0 (the unit may vary depending on each blockchain environment) to state Inconsistency checks can be performed. If the execution of the execution flow exceeds the maximum execution cost, the proxy contract determines that a state inconsistency has occurred. When the input module 204 receives only the minimum execution cost as the execution cost, the proxy contract can perform a state inconsistency check by determining whether the execution flow is executed with a value higher than the input minimum execution cost. If the execution of the execution flow is performed at less than the minimum execution cost, the proxy contract determines that a state inconsistency has occurred.

입력 모듈(204)이 수행 비용으로 최소 수행 비용 및 최대 수행 비용을 입력받은 경우 프록시 컨트랙트는 최소 수행 비용과 최대 수행 비용 범위 내에서 실행 흐름이 실행되는지를 판단하여 상태 불일치 검사를 수행할 수 있다. When the input module 204 receives the minimum execution cost and the maximum execution cost as the execution cost, the proxy contract can perform a state inconsistency check by determining whether the execution flow is executed within the range of the minimum execution cost and the maximum execution cost.

임의의 노드가 스마트 컨트랙트의 코드를 실행(또는 실행 흐름의 실행)하는 경우, 변수 등을 저장하기 위한 스택 메모리가 요구된다. 그에 따라, 본 개시에서 실행 흐름의 수행에 요구되는 스택 크기의 의미는, 코드의 실행(또는 실행 흐름의 실행)에 사용되는 메모리의 크기(또는 사이즈)를 의미한다. 이더리움 가상 머신(Ethereum Virtual Machine, EVM)은 예컨대, 256 비트 크기의 스택 1024 개만큼의 스택 공간을 제공할 수 있다. 따라서, 입력 모듈(204)은 스택 슬롯 사이즈(또는 스택 슬롯 개수)를 스택 크기로서 입력받을 수 있다. 이 경우 프록시 컨트랙트는 실행 흐름을 실행하며 소요되는 스택 슬롯 사이즈가 입력 모듈(204)이 입력받은 스택 슬롯 사이즈를 초과하는 경우에 상태 불일치가 발생하였다고 판단하게 된다.When an arbitrary node executes smart contract code (or execution flow), stack memory for storing variables and the like is required. Accordingly, in the present disclosure, the meaning of the stack size required for execution of an execution flow means the size (or size) of memory used for execution of code (or execution of execution flow). The Ethereum Virtual Machine (EVM) can provide, for example, as much stack space as 1024 256-bit stacks. Accordingly, the input module 204 may receive the stack slot size (or the number of stack slots) as the stack size. In this case, the proxy contract executes the execution flow and determines that state inconsistency has occurred when the required stack slot size exceeds the stack slot size inputted by the input module 204.

생성 모듈(206)은 입력 모듈(204)이 입력받은 수행 비용 및/또는 스택 크기를 이용하여, 상태 불일치 검사를 수행하는 프록시 컨트랙트를 생성한다. 생성 모듈(206)은 예컨대, 상태 불일치 검사로서, 실행 흐름의 실제 실행 과정에서 요구되는 비용이 입력받은 수행 비용의 범위에 포함되는지 여부를 검사하는 프록시 컨트랙트를 생성할 수 있다. 또는, 생성 모듈(206)은 상태 불일치 검사로서, 실행 흐름의 실제 실행 과정에서 요구되는 스택의 크기가 입력받은 스택 크기 이하인지 여부를 검사하는 프록시 컨트랙트를 생성할 수 있다.The creation module 206 uses the execution cost and/or stack size input by the input module 204 to create a proxy contract that performs state inconsistency check. The generation module 206 may generate a proxy contract that checks whether a cost required in an actual execution process of an execution flow is included in a range of an input execution cost, for example, as a state inconsistency check. Alternatively, the generation module 206 may generate a proxy contract that checks whether the stack size required in the actual execution process of the execution flow is less than or equal to the input stack size as a state inconsistency check.

생성 모듈(206)은 또한, 상태 불일치 검사로서, 실행 흐름의 실제 실행 과정에서 요구되는 비용이 입력받은 수행 비용의 범위에 포함되는지 여부 및 실행 흐름의 실제 실행 과정에서 요구되는 스택의 크기가 입력받은 스택 크기 이하인지 여부를 각각 검사하는 프록시 컨트랙트를 생성할 수 있다.The generation module 206 also checks whether the cost required in the actual execution process of the execution flow is included in the range of the input execution cost and the size of the stack required in the actual execution process of the execution flow. You can create a proxy contract that each checks whether it is less than or equal to the stack size.

표 1은 실행 흐름의 실제 실행 과정에서 요구되는 비용이 입력받은 수행 비용의 범위에 포함되는지 여부 및 실행 흐름의 실제 실행 과정에서 요구되는 스택의 크기가 입력받은 스택 크기 이하인지 여부를 검사하는 수도 코드의 예시를 나타낸다.Table 1 is pseudo code that checks whether the cost required in the actual execution process of the execution flow is included in the range of the input execution cost and whether the stack size required in the actual execution process of the execution flow is less than or equal to the input stack size. shows an example of

function check (inputSize, inputGas){
if(checkStack(inputSize, 0) && checkGas(inputGas)){
(bool success,) = delegatecall();
if(!success) revert();
}else revert();
}

function checkStack (requiredSize, count) {
if (0<=count && count < requiredSize)
return checkStack(requiredSize, count+1);
else false;
}

function checkGas (requiredGas) public {
if (gasleft >= requiredGas)
return true;
else false;
}
}
function check (inputSize, inputGas){
if(checkStack(inputSize, 0) && checkGas(inputGas)){
(bool success,) = delegatecall();
if(!success) revert();
}else revert();
}

function checkStack(requiredSize, count) {
if (0<=count && count < requiredSize)
return checkStack(requiredSize, count+1);
else false;
}

function checkGas(requiredGas) public {
if (gasleft >= requiredGas)
return true;
else false;
}
}

표 1을 참조하면, 프록시 컨트랙트에 포함된 check 함수는 실행 흐름을 수행하기 위하여, checkStack와 checkGas 함수를 각각 실행한다. check 함수는 checkStack 및 checkGas 함수 모두 true 값을 반환하는 경우, 즉 상태 불일치가 발생하지 않은 것으로 판단되는 경우, delegatecall 함수를 호출하여 실행 흐름을 실행한다. check 함수는 checkStack 및 checkGas 함수 중 어느 하나라도 false 값을 반환하는 경우, 즉 상태 불일치가 발생한 것으로 판단되는 경우, revert 함수를 호출하여 실행 흐름의 실행을 중단하고 변경 사항을 복구한다.Referring to Table 1, the check function included in the proxy contract executes the checkStack and checkGas functions respectively to perform the execution flow. The check function executes the execution flow by calling the delegatecall function when both the checkStack and checkGas functions return true, that is, when it is judged that no state mismatch has occurred. The check function calls the revert function to abort the execution of the execution flow and restore the change when either of the checkStack and checkGas functions return a false value, that is, when it is determined that a state inconsistency has occurred.

표 1에서의 checkStack 함수는 별도의 장치 또는 별도의 사용자로부터 입력받은 스택 크기인 inputSize를 입력 파라미터 requiredSize의 값으로서 전달받아, 현재 이용되는 스택이 inputSize 이하인지 여부를 반환한다. 표 1에서의 checkGas 함수는 별도의 장치 또는 별도의 사용자로부터 입력받은 수행 비용인 inputGas를 입력 파라미터 requiredGas의 값으로서 전달받아, 잔여 가스량(gasleft 함수의 반환값)이 inputGas 이상인지 여부를 반환한다.The checkStack function in Table 1 receives inputSize, which is the stack size input from a separate device or a separate user, as the value of the input parameter requiredSize, and returns whether or not the currently used stack is less than or equal to inputSize. The checkGas function in Table 1 receives inputGas, an execution cost input from a separate device or a separate user, as the value of the input parameter requiredGas, and returns whether the remaining gas amount (return value of the gasleft function) is greater than or equal to inputGas.

도 3은 본 개시의 일 실시예에 따른 실행 흐름의 추출 방법을 나타내는 예시도이다.3 is an exemplary view illustrating a method of extracting an execution flow according to an embodiment of the present disclosure.

도 3의 "스마트 컨트랙트 코드"는 실행 대상인 스마트 컨트랙트의 예시적 코드이다. 프록시 컨트랙트 생성장치는 도 3의 "스마트 컨트랙트 코드"에 대한 추상 구문 트리로서, 도 3의 "추상 구문 트리"를 생성한다. 도 3의 "추상 구문 트리"는, 도 3의 "스마트 컨트랙트 코드"를 실행하는 경우의 실행 흐름으로서 각 함수 간의 호출 관계를 나타낸다. 예컨대, "blog" 함수를 호출하는 경우, "blogMeta" 함수가 호출되고, "blogMeta" 함수가 호출되는 경우 "setWriter" 함수가 호출된다. 이처럼 추상 구문 트리는 각 함수 또는 변수 간의 호출 관계에 있어 선행하여 호출되는 함수 또는 선행하여 선언되는 변수를 부모 노드(parent node)로, 부모 노드에 의해 호출되거나 선언되는 함수 또는 변수를 자식 노드(child node)로서 나타낸다.The “smart contract code” in FIG. 3 is an exemplary code of a smart contract to be executed. The proxy contract generator generates the "abstract syntax tree" of FIG. 3 as an abstract syntax tree for the "smart contract code" of FIG. The “Abstract Syntax Tree” in FIG. 3 is an execution flow when executing the “smart contract code” in FIG. 3 and shows the call relationship between functions. For example, when the "blog" function is called, the "blogMeta" function is called, and when the "blogMeta" function is called, the "setWriter" function is called. In this way, in the call relationship between each function or variable, the abstract syntax tree refers to a function or variable that is called beforehand as a parent node, and a function or variable that is called or declared by a parent node as a child node. ).

프록시 컨트랙트 생성장치는 현재 단계에서 수행하여야 하는 실행 흐름을 추출하기 위하여, 추상 구문 트리로부터 도 3의 "콜 그래프"를 추출할 수 있다. 도 3의 "콜 그래프"는 "setWriter" 함수가 "calcMoney" 함수를 호출하는 실행 흐름에 대한 것이므로, 프록시 컨트랙트 생성장치는 "setWriter" 함수가 "calcMoney" 함수를 호출하는 실행 흐름을 프록시 컨트래트를 생성할 대상으로서 추출한다.The proxy contract generator may extract the “call graph” of FIG. 3 from the abstract syntax tree in order to extract the execution flow to be performed at the current stage. Since the “call graph” in FIG. 3 is for the execution flow in which the “setWriter” function calls the “calcMoney” function, the proxy contract generator converts the execution flow in which the “setWriter” function calls the “calcMoney” function to the proxy contract. Extract as object to create.

도 4는 본 개시의 일 실시예에 따른 프록시 컨트랙트 생성방법을 수행하고, 프록시 컨트랙트 생성방법이 적용되는 과정을 나타내는 흐름도이다.4 is a flowchart illustrating a process of performing a proxy contract creation method according to an embodiment of the present disclosure and applying the proxy contract creation method.

블록체인 네트워크상에 스마트 컨트랙트에 대한 트랜잭션이 발생하고, 스마트 컨트랙트가 실행된다(S400). S400 단계에서의 스마트 컨트랙트의 실행의 의미는, 스마트 컨트랙트의 실행 명령이 이루어진다는 의미로 스마트 컨트랙트의 모든 실행 흐름이 실행 완료됨을 의미하는 것은 아니다. 블록체인 네트워크는 스마트 컨트랙트의 실행 명령에 따라, 프록시 컨트랙트 생성장치로 하여금 프록시 컨트랙트를 먼저 생성하게 할 수 있다. 이는 프록시 컨트랙트에 의하여 상태 불일치 검사가 수행되면서 스마트 컨트랙트의 각각의 실행 흐름이 실행되도록 하기 위함이다.A transaction for the smart contract occurs on the blockchain network, and the smart contract is executed (S400). The execution of the smart contract in step S400 does not mean that all execution flows of the smart contract are completed, as it means that the execution command of the smart contract is executed. The blockchain network can cause the proxy contract creation device to first create a proxy contract according to the execution command of the smart contract. This is to ensure that each execution flow of the smart contract is executed while the state inconsistency check is performed by the proxy contract.

프록시 컨트랙트 생성장치는 스마트 컨트랙트의 코드에 대한 AST를 생성한다(S402).The proxy contract generator generates an AST for the code of the smart contract (S402).

프록시 컨트랙트 생성장치는 AST에 포함된 콜 그래프를 추출하여 실행 흐름을 추출한다(S404).The proxy contract generator extracts the execution flow by extracting the call graph included in the AST (S404).

프록시 컨트랙트 생성장치는 블록체인 네트워크상의 노드, 별도의 사용자 또는 별도의 장치로부터 실행 흐름의 수행에 요구되는 수행 비용 및/또는 실행 흐름의 수행에 요구되는 스택 크기(또는 스택 슬롯 사이즈, 이하 생략)를 입력받는다(S406). 여기서 입력이란, 입력 장치를 통해 수행 비용 및/또는 스택 크기가 입력되는 경우는 물론, 유무선 통신을 통해 수행 비용 및/또는 스택 크기를 수신하여 획득하는 경우를 모두 포함한다. 입력되는 수행 비용 및/또는 스택 크기는 노드, 별도의 사용자 또는 별도의 장치에 의해 예측된 값(또는 범주의 값)일 수 있다.The proxy contract generating device calculates the execution cost and/or the stack size (or stack slot size, omitted below) required to execute the execution flow from a node on the blockchain network, a separate user, or a separate device. Input is received (S406). Herein, the input includes both a case where the execution cost and/or the stack size is input through an input device and a case where the execution cost and/or the stack size are received and obtained through wired/wireless communication. The input cost and/or stack size may be a value predicted by a node, a separate user, or a separate device (or a value of a category).

프록시 컨트랙트 생성장치는 입력받은 수행 비용 및/또는 스택 크기를 이용하여 상태 불일치 검사를 수행하는 프록시 컨트랙트 생성한다(S408).The proxy contract generating device creates a proxy contract that performs a state inconsistency check using the input execution cost and/or stack size (S408).

S404 단계에서 추출된 실행 흐름에 대하여, 블록체인 네트워크 상에서 프록시 컨트랙트가 실행된다(S409). 프록시 컨트랙트는 S404 단계에서 추출된 실행 흐름을 실행(run)하며, 실행 과정에서 요구되는 비용 및/또는 사용되는 스택 크기에 대하여 상태 불일치 여부를 판단하게 된다.For the execution flow extracted in step S404, a proxy contract is executed on the blockchain network (S409). The proxy contract runs the execution flow extracted in step S404, and determines whether the status is inconsistent with respect to the cost and/or used stack size during the execution process.

S409 과정의 실행 과정에서, 프록시 컨트랙트는 상태 불일치가 발생하는지 여부를 판단한다(S410). 예컨대, 프록시 컨트랙트는 실행 흐름을 실행하면서 소요되는 수행 비용 및/또는 스택 크기가 S406 단계에서 입력받은 수행 비용 및/또는 스택 크기를 초과하는지 여부를 실시간으로 판단하여, 상태 불일치 여부를 판단할 수 있다.During the execution of step S409, the proxy contract determines whether state inconsistency occurs (S410). For example, the proxy contract determines in real time whether the execution cost and / or stack size required while executing the execution flow exceeds the execution cost and / or stack size input in step S406, and determines whether the state is inconsistent. .

S410 단계에서 상태 불일치가 발생하였다고 판단하는 경우, 블록체인 네트워크는 요청된 트랜잭션을 실패 처리한다(S412). 예컨대, 프록시 컨트랙트가 실패 처리를 의미하는 반환값을 반환하는 경우, 블록체인 네트워크상의 임의의 노드는 트랜잭션 실패의 상태를 각 노드의 블록에 기록하도록 수 있다.If it is determined that a state inconsistency has occurred in step S410, the blockchain network fails the requested transaction (S412). For example, when a proxy contract returns a return value indicating failure processing, any node on the blockchain network can record the transaction failure status in the block of each node.

S410 단계에서 상태 불일치가 발생하지 않았다고 판단하는 경우, 블록체인 네트워크상의 임의의 노드는 그 다음 순서의 실행 흐름을 실행하기 위하여 스마트 컨트랙트의 전체 코드가 실행되었는지를 판단한다(S420). 단, S410 단계에서 상태 불일치가 발생하지 않았다고 판단하는 경우, S420 단계 내지 S422 단계는 생략되고, 실행 흐름이 실행 후에 전체 절차가 종료될 수 있다.If it is determined that state inconsistency has not occurred in step S410, any node on the blockchain network determines whether the entire code of the smart contract has been executed in order to execute the next execution flow (S420). However, when it is determined that state inconsistency does not occur in step S410, steps S420 to S422 are omitted, and the entire procedure may end after the execution flow is executed.

S420 단계에서 전체 코드가 실행되었다고 판단하는 경우, 블록체인 네트워크는 트랜잭션을 성공 처리한다(S422). 예컨대, 블록체인 네트워크상의 임의의 노드는 트랜잭션 성공의 상태를 각 노드의 블록에 기록하도록 수 있다.If it is determined that the entire code has been executed in step S420, the blockchain network successfully processes the transaction (S422). For example, any node on the blockchain network can record the status of a successful transaction in the block of each node.

S420 단계에서 전체 코드가 실행되지 않았다고 판단하는 경우, 블록체인 네트워크상의 임의의 노드는 프록시 컨트랙트 생성장치로 하여금 S404 단계를 다시 실행하도록 한다. 이로써 프록시 컨트랙트 생성장치는, 다음 순서의 실행 흐름에 대한 프록시 컨트랙트를 생성할 수 있다.If it is determined that the entire code has not been executed in step S420, any node on the blockchain network causes the proxy contract generator to execute step S404 again. As a result, the proxy contract generator can create a proxy contract for the next execution flow.

한편, 스마트 컨트랙트의 전체 실행 흐름에 대하여 프록시 컨트랙트를 생성할 필요가 없는 경우, S420 단계는 기 설정된 범주의 코드가 전부 실행되었는지를 판단하는 과정으로 대체될 수 있다.On the other hand, if it is not necessary to create a proxy contract for the entire execution flow of the smart contract, step S420 can be replaced with a process of determining whether all codes of a preset category have been executed.

또 다른 실시예에서 S402 단계 내지 S408 단계는 low-level call이 발생하는 경우에 한하여 수행될 수 있다.In another embodiment, steps S402 to S408 may be performed only when a low-level call occurs.

도 4에서는 과정 각 과정을 순차적으로 실행하는 것으로 기재하고 있으나, 이는 본 개시의 일 실시예의 기술 사상을 예시적으로 설명한 것에 불과한 것이다. 다시 말해, 본 개시의 일 실시예가 속하는 기술 분야에서 통상의 지식을 가진 자라면 본 개시의 일 실시예의 본질적인 특성에서 벗어나지 않는 범위에서 도 4에 기재된 순서를 변경하여 실행하거나 각 과정 중 하나 이상의 과정을 병렬적으로 실행하는 것으로 다양하게 수정 및 변형하여 적용 가능할 것이므로, 도 4의 시계열적인 순서로 한정되는 것은 아니다.In FIG. 4, it is described that each process is sequentially executed, but this is merely an example of the technical idea of an embodiment of the present disclosure. In other words, those skilled in the art to which an embodiment of the present disclosure pertains may change and execute the sequence described in FIG. 4 or perform one or more of each process without departing from the essential characteristics of the embodiment of the present disclosure. Since it can be applied by various modifications and variations by executing in parallel, it is not limited to the time-sequential order of FIG. 4 .

본 명세서에 설명되는 장치, 부(unit), 과정, 단계 등의 다양한 구현예들은, 디지털 전자 회로, 집적 회로, FPGA(field programmable gate array), ASIC(application specific integrated circuit), 컴퓨터 하드웨어, 펌웨어, 소프트웨어, 및/또는 이들의 조합으로 실현될 수 있다. 이러한 다양한 구현예들은 프로그래밍 가능 시스템상에서 실행 가능한 하나 이상의 컴퓨터 프로그램들로 구현되는 것을 포함할 수 있다. 프로그래밍 가능 시스템은, 저장 시스템, 적어도 하나의 입력 디바이스, 그리고 적어도 하나의 출력 디바이스로부터 데이터 및 명령을 수신하고 이들에게 데이터 및 명령을 전송하도록 결합된 적어도 하나의 프로그래밍 가능 프로세서(이것은 특수 목적 프로세서일 수 있거나 혹은 범용 프로세서일 수 있음)를 포함한다. 컴퓨터 프로그램들(이것은 또한 프로그램들, 소프트웨어, 소프트웨어 애플리케이션들 혹은 코드로서 알려져 있음)은 프로그래밍 가능 프로세서에 대한 명령어들을 포함하며 "컴퓨터가 읽을 수 있는 기록매체"에 저장된다. Various implementations of devices, units, processes, steps, etc. described herein may include digital electronic circuits, integrated circuits, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), computer hardware, firmware, software, and/or combinations thereof. These various implementations may include being implemented as one or more computer programs executable on a programmable system. A programmable system includes at least one programmable processor (which may be a special purpose processor) coupled to receive data and instructions from and transmit data and instructions to a storage system, at least one input device, and at least one output device. or may be a general-purpose processor). Computer programs (also known as programs, software, software applications or code) contain instructions for a programmable processor and are stored on a “computer readable medium”.

컴퓨터가 읽을 수 있는 기록매체는, 컴퓨터 시스템에 의하여 읽혀질 수 있는 데이터가 저장되는 모든 종류의 기록장치를 포함한다. 이러한 컴퓨터가 읽을 수 있는 기록매체는 ROM, CD-ROM, 자기 테이프, 플로피디스크, 메모리 카드, 하드 디스크, 광자기 디스크, 스토리지 디바이스 등의 비휘발성(non-volatile) 또는 비 일시적인(non-transitory) 매체를 더 포함할 수도 있다. 또한, 컴퓨터가 읽을 수 있는 기록매체는 네트워크로 연결된 컴퓨터 시스템에 분산되어, 분산 방식으로 컴퓨터가 읽을 수 있는 코드가 저장되고 실행될 수도 있다.A computer-readable recording medium includes all kinds of recording devices that store data that can be read by a computer system. These computer-readable  recording media include non-volatile or non-transitory storage devices such as ROM, CD-ROM, magnetic tape, floppy disk, memory card, hard disk, magneto-optical disk, and storage device. It may further include a medium. In addition, the computer-readable recording medium may be distributed in computer systems connected through a network, and computer-readable codes may be stored and executed in a distributed manner.

본 명세서에 설명되는 시스템들 및 기법들의 다양한 구현예들은, 프로그램가능 컴퓨터에 의하여 구현될 수 있다. 여기서, 컴퓨터는 프로그램가능 프로세서, 데이터 저장 시스템(휘발성 메모리, 비휘발성 메모리, 또는 다른 종류의 저장 시스템이거나 이들의 조합을 포함함) 및 적어도 한 개의 커뮤니케이션 인터페이스를 포함한다. 예컨대, 프로그램가능 컴퓨터는 서버, 네트워크 기기, 셋톱박스, 내장형 장치, 컴퓨터 확장 모듈, 개인용 컴퓨터, 랩톱, PDA(Personal Data Assistant), 클라우드 컴퓨팅 시스템 또는 모바일 장치 중 하나일 수 있다.Various implementations of the systems and techniques described herein may be implemented by a programmable computer. Here, the computer includes a programmable processor, a data storage system (including volatile memory, non-volatile memory, or other types of storage systems, or combinations thereof) and at least one communication interface. For example, a programmable computer may be one of a server, network device, set top box, embedded device, computer expansion module, personal computer, laptop, personal data assistant (PDA), cloud computing system, or mobile device.

이상의 설명은 본 실시예의 기술 사상을 예시적으로 설명한 것에 불과한 것으로서, 본 실시예가 속하는 기술 분야에서 통상의 지식을 가진 자라면 본 실시예의 본질적인 특성에서 벗어나지 않는 범위에서 다양한 수정 및 변형이 가능할 것이다. 따라서, 본 실시예들은 본 실시예의 기술 사상을 한정하기 위한 것이 아니라 설명하기 위한 것이고, 이러한 실시예에 의하여 본 실시예의 기술 사상의 범위가 한정되는 것은 아니다. 본 실시예의 보호 범위는 아래의 청구범위에 의하여 해석되어야 하며, 그와 동등한 범위 내에 있는 모든 기술 사상은 본 실시예의 권리범위에 포함되는 것으로 해석되어야 할 것이다.The above description is merely an example of the technical idea of the present embodiment, and various modifications and variations can be made to those skilled in the art without departing from the essential characteristics of the present embodiment. Therefore, the present embodiments are not intended to limit the technical idea of the present embodiment, but to explain, and the scope of the technical idea of the present embodiment is not limited by these embodiments. The scope of protection of this embodiment should be construed according to the claims below, and all technical ideas within the scope equivalent thereto should be construed as being included in the scope of rights of this embodiment.

200: 프록시 컨트랙트 생성장치
202: 추출 모듈
204: 입력 모듈
206: 생성 모듈
200: proxy contract generator
202: extraction module
204: input module
206: generation module

Claims (9)

프록시 컨트랙트 생성장치가 프록시 컨트랙트를 생성하는 방법에 있어서,
스마트 컨트랙트의 코드로부터 실행 흐름(call-flow)을 추출하는 과정;
추출된 실행 흐름 중 어느 하나의 실행 흐름인 제1 실행 흐름의 수행에 요구되는 수행 비용 및/또는 상기 제1 실행 흐름의 수행에 요구되는 스택 크기(stack size)를 입력받는 과정; 및
상기 수행 비용 및/또는 상기 스택 크기를 기초로 상태 불일치(state inconsistency) 검사를 수행하는 프록시 컨트랙트(proxy contract)를 생성하는 과정을 포함하되,
상기 수행 비용은 상기 제1 실행 흐름의 수행에 요구되는 최대 수행 비용 및/또는 최소 수행 비용인,
프록시 컨트랙트 생성방법.
In the method in which the proxy contract generator creates a proxy contract,
The process of extracting the call-flow from the code of the smart contract;
A process of receiving an execution cost required for execution of a first execution flow, which is any one of the extracted execution flows, and/or a stack size required for execution of the first execution flow; and
Creating a proxy contract that performs a state inconsistency check based on the execution cost and/or the stack size,
The execution cost is the maximum execution cost and / or minimum execution cost required for the execution of the first execution flow,
How to create a proxy contract.
제1항에 있어서,
상기 실행 흐름을 추출하는 과정은,
상기 코드에 대한 추상 구문 트리(abstract syntax tree)를 생성함으로써 수행되는, 프록시 컨트랙트 생성방법.
According to claim 1,
The process of extracting the execution flow,
A proxy contract creation method, performed by generating an abstract syntax tree for the code.
제2항에 있어서,
상기 실행 흐름을 추출하는 과정은,
상기 추상 구문 트리의 콜 그래프(call-graph)를 추출함으로써 수행되는, 프록시 컨트랙트 생성방법.
According to claim 2,
The process of extracting the execution flow,
Proxy contract creation method, performed by extracting a call-graph of the abstract syntax tree.
삭제delete 제1항에 있어서,
상기 프록시 컨트랙트를 생성하는 과정은,
상기 상태 불일치 검사로서, 상기 제1 실행 흐름의 실제 실행 과정에서 요구되는 비용이 상기 수행 비용의 범위에 포함되는지 여부를 검사하도록 상기 프록시 컨트랙트를 생성하는, 프록시 컨트랙트 생성방법.
According to claim 1,
The process of creating the proxy contract,
As the state inconsistency check, the proxy contract is created to check whether a cost required in an actual execution process of the first execution flow is included in a range of the execution cost.
제1항에 있어서,
상기 프록시 컨트랙트를 생성하는 과정은,
상기 상태 불일치 검사로서, 상기 제1 실행 흐름의 실제 실행 과정에서 요구되는 스택의 크기가 상기 스택 크기의 이하인지 여부를 검사하도록 상기 프록시 컨트랙트를 생성하는, 프록시 컨트랙트 생성방법.
According to claim 1,
The process of creating the proxy contract,
As the state inconsistency check, the proxy contract is created to check whether a stack size required in an actual execution process of the first execution flow is less than or equal to the stack size.
제1항에 있어서,
상기 프록시 컨트랙트를 생성하는 과정은,
상기 상태 불일치 검사로서, 상기 제1 실행 흐름의 실제 실행 과정에서 요구되는 비용이 상기 수행 비용의 범위에 포함되는지의 검사 및 상기 제1 실행 흐름의 실제 실행 과정에서 요구되는 스택의 크기가 상기 스택 크기의 이하인지 여부의 검사를 수행하도록 상기 프록시 컨트랙트를 생성하는, 프록시 컨트랙트 생성방법.
According to claim 1,
The process of creating the proxy contract,
As the state inconsistency check, it is determined whether a cost required in the actual execution process of the first execution flow is included in the range of the execution cost, and a stack size required in the actual execution process of the first execution flow is the stack size. A method for creating a proxy contract, wherein the proxy contract is created to check whether it is less than or equal to.
제1항 내지 제3항 및 제5항 내지 제7항 중 어느 한 항에 따른 프록시 컨트랙트 생성방법이 포함하는 각 과정을 실행시키기 위하여 컴퓨터로 읽을 수 있는 기록매체에 저장된 컴퓨터 프로그램. A computer program stored in a computer-readable recording medium to execute each process included in the proxy contract creation method according to any one of claims 1 to 3 and 5 to 7. 스마트 컨트랙트의 코드로부터 실행 흐름(call-flow)을 추출하는 추출 모듈;
노드로부터, 추출된 실행 흐름 중 어느 하나의 실행 흐름인 제1 실행 흐름의 수행에 요구되는 수행 비용 및/또는 상기 제1 실행 흐름의 수행에 요구되는 스택 크기(stack size)를 입력받는 입력 모듈; 및
상기 수행 비용 및/또는 상기 스택 크기를 기초로 상태 불일치(state inconsistency) 검사를 수행하는 프록시 컨트랙트(proxy contract)를 생성하는 생성 모듈을 포함하되,
상기 수행 비용은 상기 제1 실행 흐름의 수행에 요구되는 최대 수행 비용 및/또는 최소 수행 비용인,
프록시 컨트랙트 생성장치.
An extraction module that extracts a call-flow from the smart contract code;
An input module that receives, from a node, an execution cost required for execution of a first execution flow, which is any one of the extracted execution flows, and/or a stack size required for execution of the first execution flow; and
A generation module for generating a proxy contract that performs a state inconsistency check based on the execution cost and/or the stack size,
The execution cost is the maximum execution cost and / or minimum execution cost required for the execution of the first execution flow,
A proxy contract generator.
KR1020210086311A 2021-07-01 2021-07-01 Method And Apparatus for Generating Proxy Contract KR102529028B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020210086311A KR102529028B1 (en) 2021-07-01 2021-07-01 Method And Apparatus for Generating Proxy Contract

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020210086311A KR102529028B1 (en) 2021-07-01 2021-07-01 Method And Apparatus for Generating Proxy Contract

Publications (2)

Publication Number Publication Date
KR20230005508A KR20230005508A (en) 2023-01-10
KR102529028B1 true KR102529028B1 (en) 2023-05-03

Family

ID=84893398

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020210086311A KR102529028B1 (en) 2021-07-01 2021-07-01 Method And Apparatus for Generating Proxy Contract

Country Status (1)

Country Link
KR (1) KR102529028B1 (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020249572A1 (en) * 2019-06-12 2020-12-17 NEC Laboratories Europe GmbH Method and contract rewriting framework system for supporting smart contracts in a blockchain network
CN112269836A (en) * 2020-11-15 2021-01-26 北京物资学院 Block chain intelligent contract generation and management system and implementation mechanism thereof

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020249572A1 (en) * 2019-06-12 2020-12-17 NEC Laboratories Europe GmbH Method and contract rewriting framework system for supporting smart contracts in a blockchain network
CN112269836A (en) * 2020-11-15 2021-01-26 北京物资学院 Block chain intelligent contract generation and management system and implementation mechanism thereof

Also Published As

Publication number Publication date
KR20230005508A (en) 2023-01-10

Similar Documents

Publication Publication Date Title
CN106970873B (en) On-line mock testing method, device and system
JP2019536153A (en) Smart contract processing method and apparatus
TW200937188A (en) Contract programming for code error reduction
CN104360920A (en) Automatic testing method and device for interface
CN111274045B (en) Multi-platform docking method and device, computer equipment and readable storage medium
CN108614702B (en) Byte code optimization method and device
CN110659031A (en) Compiling method and device of application program, electronic equipment and storage medium
CN103561006A (en) Application authentication method and device and application authentication server based on Android
CN106775781B (en) Method and device for reducing application installation packages and electronic equipment
CN111857860A (en) Method and system for realizing safe loading of plug-in
CN111104158A (en) Software packaging method and device, computer equipment and storage medium
AU2021204593A1 (en) Methods and apparatuses for installing device application
CN111190915A (en) Method for determining road tool identifier or role identifier, server and storage medium
CN110083366B (en) Application running environment generation method and device, computing equipment and storage medium
KR102529028B1 (en) Method And Apparatus for Generating Proxy Contract
CN1825277B (en) Code morphing
CN111240987B (en) Method and device for detecting migration program, electronic equipment and computer readable storage medium
KR102529081B1 (en) Method And Apparatus for Generating Proxy Contract
CN104375993A (en) Data processing method and device
CN104506630A (en) Method, server and system for generating authority data on basis of user roles
CN113835748B (en) Packaging method, system and readable medium for application program based on HTML5
CN113986744A (en) Method and device for testing warehouse and table components and storage medium
CN115185847A (en) Fault testing method and device, storage medium and electronic equipment
CN114924742A (en) Hot patch making and applying method and device for virtual machine simulation software
CN112749152A (en) Data migration method and device of intelligent contract and storage medium

Legal Events

Date Code Title Description
E701 Decision to grant or registration of patent right