From aca561623fb57a6140b46ffe11d59c7daedb3ca0 Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Thu, 9 Nov 2017 10:48:16 -0700 Subject: [PATCH 01/11] start on defining link references --- release-lockfile.spec.md | 252 ++++++++++++++++++++++++--------------- 1 file changed, 159 insertions(+), 93 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index 8bf4342..8a3a287 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -43,31 +43,41 @@ The set of EVM instructions as produced by a compiler. Unless otherwise specified this should be assumed to be hexidecimal encoded and prefixed with a `'0x'`. + +#### Binary Bytecode + +The binary representation of bytecode is defined as the raw bytes. + + #### Unlinked Bytecode Unlinked bytecode is the hexidecimal representation of a contract's EVM -instructions which contains placeholders which are referred to as *link -references*. +instructions which contains sections of code which require *linking* fort he +contract to be functional. + +The sections of code which are unlinked **must** be filled in with zero bytes. + -* Unlinked Bytecode: `606060405260e0600073__MathLib_______________________________634d536f` +* unlinked bytecode: `606060405260e06000730000000000000000000000000000000000000000634d536f` #### Linked Bytecode -Linked bytecode is the hexidecimal representation of a contract's EVM instructions which has hadd all *link references* replaced with the desired *link values* +Linked bytecode is the hexidecimal representation of a contract's EVM +instructions which has hadd all *link references* replaced with the desired +*link values* -* linked Bytecode: `606060405260e06000736fe36000604051602001526040518160e060020a634d536f` +* linked bytecode: `606060405260e06000736fe36000604051602001526040518160e060020a634d536f` #### Link Reference -A placeholder within the hexidecimal representation of a contract's EVM instructions. +A location within a contract's bytecode which needs to be linked. A link +reference has the following properties. -`606060405260e0600073__MathLib_______________________________634d536f` the - -In the bytecode -`606060405260e0600073__MathLib_______________________________634d536f`, the -substring `__MathLib_______________________________` is a link reference. +* `offset`: Defines the location within the bytecode where the link reference begins. +* `length`: Defines the length of the reference. +* `name`: A string that **must** be a valid *Contract Name* #### Link Value @@ -284,6 +294,130 @@ prefixed with `x-` to prevent name collisions with future versions of the specification. +### The *Link Reference * Object + +A link reference object has the following key/value pairs. All link references +**must** be associated with some corresponding bytecode. + +#### Offset: `offset` + +The `offset` field is an integer which defines the start position for the link +reference in the binary representation of the corresponding bytecode. This +field is invalid if it references a position that is beyond the end of the +bytecode. + + +#### Length: `length` + +The `length` field is an integer which defines the length of the link +reference. This field is invalid if the end of the defined link reference +exceeds the end of the bytecode. + + +#### Name: `name` + +The `name` field is a string which **must** be a valid *Contract Name*. Any +link references which **should** be linked with the same *link value* +**should** be given the same name. + + +### The *Link Value* Object + +A *Link Value* object is defined to have the following key/value pairs. + + +#### Offset `offset` + +The `offset` field defines the location within the corresponding bytecode where +the `value` for this *link value* should be written. This location is a +0-indexed offset from the beginning of the unprefixed binary +representation of the bytecode. + +* Required: Yes +* Type: Integer +* Format: The integer **must** conform to all of the following: + * be greater than or equal to zero + * strictly less than the length of the unprefixed hexidecimal representation of the corresponding bytecode. + + +#### Value `value` + +The `value` field defines the value which should be written when *linking* the +corresponding bytecode. + +* Required: Yes +* Type: String +* Format: One of the following formats. + +To reference the address of a *contract instance* from the current release lockfile +the value should be the name of that *contract instance*. + +* This value **must** be a valid *contract instance* name. +* The chain definition under which the *contract instance* that this *link value* belongs to must contain this value within its keys. +* This value **may not** reference the same *contract instance* that this *link value* belongs to. + + +To reference a *contract instance* from a lockfile from somewhere within the +dependency tree the value is constructed as follows. + +* Let `[p1, p2, .. pn]` define the path down the dependency tree. +* Each of `p1, p2, pn` are dependency names. +* `p1` **must** be present in keys of the `build_dependencies` for the current release lockfile. +* For every `pn` where `n > 1`, `pn` **must** be present in the keys of the `build_dependencies` of the lockfile for `pn-1`. +* The value is represented by the string `::<...>::` where all of ``, ``, `` are valid package names and `` is a valid contract name. +* The `` value **must** be a valid *contract instance* name. +* Within the release lockfile of the package dependency defined by ``, all of the following must be satisfiable: + * There **must** be *exactly* one chain defined under the `deployments` key which matches the chain definition that this *link value* is nested under. + * The `` value **must** be present in the keys of the matching chain. + +To references a static address use the `'0x'` prefixed address as the value. +Package managers **should not** use this pattern when building releases that +will be published as open source packages or that are intended to be used +outside of a closed system. Package managers **should** require some form of +explicit input from the user such as a command line flag like +`--allow-unverifiable-linking` before linking code with this type of *link +value*. + + +### The *Bytecode* Object + +A bytecode object has the following key/value pairs. + +#### Bytecode: `bytecode` + +The `bytecode` field is a string containing the `0x` prefixed hexidecimal +representation of the bytecode. + +#### Link References: `link_references` + +The `link_references` field defines the locations in the corresponding bytecode +which require linking. + +* Type: Array +* Format: All values **must** be valid *Link Reference* objects + +This field is considered invalid if *any* of the link references are invalid +when applied to the corresponding `bytecode` field, *or* if any of the link +references intersect. + +Intersection is defined as two link references which overlap. + + +#### Link Dependencies: `link_dependencies` + +The `link_dependencies` defines the *link values* that have been used to link +the corresponding bytecode. + +* Type: Array +* Format: All values **must** be valid *Link Value* objects + +Validation of this field includes the following: + +* No two link value objects may contain the same `offset`. +* Each link value object **must** have a corresponding link reference object under the `link_references` field. +* The length of the resolved `value` **must** be equal to the `length` of the corresponding link reference. + + ### The *Package Meta* Object The *Package Meta* object is defined to have the following key/value pairs. @@ -360,11 +494,11 @@ The `contract_name` field defines *contract name* for this *contract type*. #### Bytecode `bytecode` -The `bytecode` field defines the unlinked `'0x'` prefixed bytecode for this *contract type* +The `bytecode` field defines the bytecode for this *contract type* * Required: No -* Type: String -* Format: Hex encoded unlinked bytecode for the compiled contract. +* Type: Object +* Format: **must** conform to the *Bytecode* object format. #### Runtime Bytecode `runtime_bytecode` @@ -373,8 +507,8 @@ The `runtime_bytecode` field defines the unlinked `'0x'` prefixed runtime portion of bytecode for this *contract type*. * Required: No -* Type: String -* Format: Hex encoded unlinked runtime portion of the bytecode for the compiled contract. +* Type: Object +* Format: **must** conform to the *Bytecode* object format. #### ABI `abi` @@ -459,14 +593,17 @@ created this *contract instance* was mined. #### Runtime Bytecode `runtime_bytecode` -The `runtime_bytecode` field defines the unlinked `'0x'` prefixed runtime -portion of bytecode for this *contract instance*. When present, the value from -this field takes priority over the `runtime_bytecode` from the -*contract_type* for this *contract instance*. +The `runtime_bytecode` field defines the runtime portion of bytecode for this +*contract instance*. When present, the value from this field supersedes +the `runtime_bytecode` from the *contract_type* for this *contract +instance*. * Required: No -* Type: String -* Format: Hex encoded unlinked runtime portion of the bytecode for the compiled contract. +* Type: Object +* Format: **must** conform to the *Bytecode* object format. + +Every entry in the `link_references` for this bytecode **must** have a +corresponding entry in the `link_dependencies` section. #### Compiler `compiler` @@ -480,77 +617,6 @@ compilation of this *contract class*. This field **should** be present in all * Format: **must** conform the the *Compiler Information* object format. -#### Link Dependencies `link_dependencies` - -The `link_dependencies` defines the values which were used to fill in any -*link* references which are present in the `runtime_bytecode` for this -*contract instance*. This field **must** be present if there are any *link -references* in the `runtime_bytecode` for this *contract instance*. This field -**must** contain an entry for all *link references* found the `runtime_bytecode`. - -* Required: If there are any *link references* in the `runtime_bytecode` for the *contract type* of this *contract instance*. -* Type: Array -* Format: All values **must** be valid *Link Value* objects - - -### The *Link Value* Object - -A *Link Value* object is defined to have the following key/value pairs. - - -#### Offset `offset` - -The `offset` field defines the location within the corresponding bytecode where -the `value` for this *link value* should be written. This location is a -0-indexed offset from the beginning of the unprefixed hexidecimal -representation of the bytecode. - -* Required: Yes -* Type: Integer -* Format: The integer **must** conform to all of the following: - * be greater than or equal to zero - * strictly less than the length of the unprefixed hexidecimal representation of the corresponding bytecode. - - -#### Value `value` - -The `value` field defines the value which should be written when *linking* the -corresponding bytecode. - -* Required: Yes -* Type: String -* Format: One of the following formats. - -To reference the address of a *contract instance* from the current release lockfile -the value should be the name of that *contract instance*. - -* This value **must** be a valid *contract instance* name. -* The chain definition under which the *contract instance* that this *link value* belongs to must contain this value within its keys. -* This value **may not** reference the same *contract instance* that this *link value* belongs to. - - -To reference a *contract instance* from a lockfile from somewhere within the -dependency tree the value is constructed as follows. - -* Let `[p1, p2, .. pn]` define the path down the dependency tree. -* Each of `p1, p2, pn` are dependency names. -* `p1` **must** be present in keys of the `build_dependencies` for the current release lockfile. -* For every `pn` where `n > 1`, `pn` **must** be present in the keys of the `build_dependencies` of the lockfile for `pn-1`. -* The value is represented by the string `::<...>::` where all of ``, ``, `` are valid package names and `` is a valid contract name. -* The `` value **must** be a valid *contract instance* name. -* Within the release lockfile of the package dependency defined by ``, all of the following must be satisfiable: - * There **must** be *exactly* one chain defined under the `deployments` key which matches the chain definition that this *link value* is nested under. - * The `` value **must** be present in the keys of the matching chain. - -To references a static address use the `'0x'` prefixed address as the value. -Package managers **should not** use this pattern when building releases that -will be published as open source packages or that are intended to be used -outside of a closed system. Package managers **should** require some form of -explicit input from the user such as a command line flag like -`--allow-unverifiable-linking` before linking code with this type of *link -value*. - - ### The *Compiler Information* Object The `compiler` field defines the compiler information that was used during From 217c9dabda1de3758293cf68118f23ed43019ca0 Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Thu, 9 Nov 2017 13:23:55 -0700 Subject: [PATCH 02/11] cleanup --- release-lockfile.spec.md | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index 8a3a287..769ee76 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -286,7 +286,7 @@ this project depends on. * Values **must** be valid IPFS URIs which resolve to a valid *Release Lock File* -## Object Definitions +## Definitions Definitions for different objects used within the release lockfile. All objects allow custom fields to be included. Custom fields **should** be @@ -297,14 +297,17 @@ specification. ### The *Link Reference * Object A link reference object has the following key/value pairs. All link references -**must** be associated with some corresponding bytecode. +are assumed to be associated with some corresponding bytecode. #### Offset: `offset` The `offset` field is an integer which defines the start position for the link -reference in the binary representation of the corresponding bytecode. This -field is invalid if it references a position that is beyond the end of the -bytecode. +reference. The location is a 0-indexed offset from the beginning of the binary +representation of the corresponding bytecode. This field is invalid if it +references a position that is beyond the end of the bytecode. + +* Required: Yes +* Type: Integer #### Length: `length` @@ -313,6 +316,9 @@ The `length` field is an integer which defines the length of the link reference. This field is invalid if the end of the defined link reference exceeds the end of the bytecode. +* Required: Yes +* Type: Integer + #### Name: `name` @@ -320,6 +326,10 @@ The `name` field is a string which **must** be a valid *Contract Name*. Any link references which **should** be linked with the same *link value* **should** be given the same name. +* Required: No +* Type: String +* Format: **must** conform to the *Contract Name* format. + ### The *Link Value* Object @@ -329,9 +339,9 @@ A *Link Value* object is defined to have the following key/value pairs. #### Offset `offset` The `offset` field defines the location within the corresponding bytecode where -the `value` for this *link value* should be written. This location is a -0-indexed offset from the beginning of the unprefixed binary -representation of the bytecode. +the `value` for this *link value* was written. This location is a +0-indexed offset from the beginning of the binary representation of the +corresponding bytecode. * Required: Yes * Type: Integer @@ -388,11 +398,16 @@ A bytecode object has the following key/value pairs. The `bytecode` field is a string containing the `0x` prefixed hexidecimal representation of the bytecode. +* Required: Yes +* Type: String +* Format: `0x` prefixed hexidecimal. + #### Link References: `link_references` The `link_references` field defines the locations in the corresponding bytecode which require linking. +* Required: No * Type: Array * Format: All values **must** be valid *Link Reference* objects @@ -408,6 +423,7 @@ Intersection is defined as two link references which overlap. The `link_dependencies` defines the *link values* that have been used to link the corresponding bytecode. +* Required: No * Type: Array * Format: All values **must** be valid *Link Value* objects From 7193f99dd2931035bb1da6d3621576cde6816d2f Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Thu, 9 Nov 2017 15:40:15 -0700 Subject: [PATCH 03/11] language --- release-lockfile.spec.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index 769ee76..0ac1658 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -312,7 +312,7 @@ references a position that is beyond the end of the bytecode. #### Length: `length` -The `length` field is an integer which defines the length of the link +The `length` field is an integer which defines the length in bytes of the link reference. This field is invalid if the end of the defined link reference exceeds the end of the bytecode. @@ -370,8 +370,8 @@ the value should be the name of that *contract instance*. To reference a *contract instance* from a lockfile from somewhere within the dependency tree the value is constructed as follows. -* Let `[p1, p2, .. pn]` define the path down the dependency tree. -* Each of `p1, p2, pn` are dependency names. +* Let `[p1, p2, .. pn]` define a path down the dependency tree. +* Each of `p1, p2, pn` **must** be valid package names. * `p1` **must** be present in keys of the `build_dependencies` for the current release lockfile. * For every `pn` where `n > 1`, `pn` **must** be present in the keys of the `build_dependencies` of the lockfile for `pn-1`. * The value is represented by the string `::<...>::` where all of ``, ``, `` are valid package names and `` is a valid contract name. From 200873cdc76d4e48dae51b8630781700fcfb1163 Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Fri, 15 Dec 2017 13:08:00 -0700 Subject: [PATCH 04/11] dirty --- release-lockfile.spec.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index 0ac1658..8aba01e 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -294,7 +294,7 @@ prefixed with `x-` to prevent name collisions with future versions of the specification. -### The *Link Reference * Object +### The *Link Reference* Object A link reference object has the following key/value pairs. All link references are assumed to be associated with some corresponding bytecode. From 2f632126086710f52762238dbbe838d17ee7466f Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Fri, 15 Dec 2017 13:25:27 -0700 Subject: [PATCH 05/11] update schema --- spec/release-lockfile.spec.json | 54 +++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/spec/release-lockfile.spec.json b/spec/release-lockfile.spec.json index 57524cb..8cce2eb 100644 --- a/spec/release-lockfile.spec.json +++ b/spec/release-lockfile.spec.json @@ -123,12 +123,10 @@ "pattern": "[a-zA-Z][a-zA-Z0-9_]*" }, "bytecode": { - "title": "The unlinked '0x' prefixed bytecode for this contract type", - "type": "string" + "$ref": "#/definitions/BytecodeObject" }, "runtime_bytecode": { - "title": "The unlinked '0x' prefixed runtime portion of the bytecode for this contract type", - "type": "string" + "$ref": "#/definitions/BytecodeObject" }, "abi": { "title": "The ABI for this contract type", @@ -165,8 +163,7 @@ "$ref": "#/definitions/BlockHash" }, "runtime_bytecode": { - "title": "The on-chain bytecode for this contract instance.", - "type": "string" + "$ref": "#/definitions/BytecodeObject" }, "compiler": { "$ref": "#/definitions/CompilerInformation" @@ -180,6 +177,51 @@ } } }, + "BytecodeObject": { + "title": "Contract bytecode", + "type": "object", + "required": ["bytecode"], + "properties": { + "bytecode": { + "type": "string", + "pattern": "^0x[0-9a-fA-F]*$" + }, + "link_references": { + "type": "array", + "items": { + "$ref": "#/definitions/LinkReference" + } + }, + "link_dependencies": { + "type": "array", + "items": { + "$ref": "#/definitions/LinkValue" + } + } + } + }, + "LinkReference": { + "title": "A defined location in some bytecode which requires linking", + "type": "object", + "required": [ + "offset", + "length", + "name" + ], + "properties": { + "offset": { + "type": "integer", + "minimum": 0 + }, + "length": { + "type": "integer", + "minimum": 1 + }, + "name": { + "$ref": "#/definitions/ContractInstanceName" + } + } + }, "LinkValue": { "title": "A value for an individual link reference in a contract's bytecode", "type": "object", From 4a100fca7564798c97acf74b6411a8705fb2cfb6 Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Wed, 20 Dec 2017 11:12:41 -0700 Subject: [PATCH 06/11] spelling --- release-lockfile.spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index 8aba01e..c15133f 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -52,7 +52,7 @@ The binary representation of bytecode is defined as the raw bytes. #### Unlinked Bytecode Unlinked bytecode is the hexidecimal representation of a contract's EVM -instructions which contains sections of code which require *linking* fort he +instructions which contains sections of code which require *linking* for the contract to be functional. The sections of code which are unlinked **must** be filled in with zero bytes. @@ -64,7 +64,7 @@ The sections of code which are unlinked **must** be filled in with zero bytes. #### Linked Bytecode Linked bytecode is the hexidecimal representation of a contract's EVM -instructions which has hadd all *link references* replaced with the desired +instructions which has had all *link references* replaced with the desired *link values* * linked bytecode: `606060405260e06000736fe36000604051602001526040518160e060020a634d536f` From b5bc1e0f27f9bfd7809edc49124825cfe3ec1592 Mon Sep 17 00:00:00 2001 From: Piper Merriam Date: Wed, 20 Dec 2017 11:41:21 -0700 Subject: [PATCH 07/11] remove part about unsafe linking --- release-lockfile.spec.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index c15133f..28da93e 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -381,12 +381,6 @@ dependency tree the value is constructed as follows. * The `` value **must** be present in the keys of the matching chain. To references a static address use the `'0x'` prefixed address as the value. -Package managers **should not** use this pattern when building releases that -will be published as open source packages or that are intended to be used -outside of a closed system. Package managers **should** require some form of -explicit input from the user such as a command line flag like -`--allow-unverifiable-linking` before linking code with this type of *link -value*. ### The *Bytecode* Object From fe52a4da50d8b8132e704a14617639cfdf83423c Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Tue, 24 Apr 2018 18:33:39 -0400 Subject: [PATCH 08/11] Remove trailing whitespace --- release-lockfile.spec.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index b84b984..ee1bdb6 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -53,7 +53,7 @@ The binary representation of bytecode is defined as the raw bytes. Unlinked bytecode is the hexidecimal representation of a contract's EVM instructions which contains sections of code which require *linking* for the -contract to be functional. +contract to be functional. The sections of code which are unlinked **must** be filled in with zero bytes. @@ -352,7 +352,7 @@ corresponding bytecode. * Required: Yes * Type: Integer * Format: The integer **must** conform to all of the following: - * be greater than or equal to zero + * be greater than or equal to zero * strictly less than the length of the unprefixed hexidecimal representation of the corresponding bytecode. @@ -366,7 +366,7 @@ corresponding bytecode. * Format: One of the following formats. To reference the address of a *contract instance* from the current release lockfile -the value should be the name of that *contract instance*. +the value should be the name of that *contract instance*. * This value **must** be a valid *contract instance* name. * The chain definition under which the *contract instance* that this *link value* belongs to must contain this value within its keys. @@ -405,7 +405,7 @@ representation of the bytecode. #### Link References: `link_references` The `link_references` field defines the locations in the corresponding bytecode -which require linking. +which require linking. * Required: No * Type: Array @@ -421,7 +421,7 @@ Intersection is defined as two link references which overlap. #### Link Dependencies: `link_dependencies` The `link_dependencies` defines the *link values* that have been used to link -the corresponding bytecode. +the corresponding bytecode. * Required: No * Type: Array @@ -430,7 +430,7 @@ the corresponding bytecode. Validation of this field includes the following: * No two link value objects may contain the same `offset`. -* Each link value object **must** have a corresponding link reference object under the `link_references` field. +* Each link value object **must** have a corresponding link reference object under the `link_references` field. * The length of the resolved `value` **must** be equal to the `length` of the corresponding link reference. From 5d299190030c2528ee1c7fd2ae2db42769adfc67 Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Tue, 24 Apr 2018 18:34:42 -0400 Subject: [PATCH 09/11] Add missing 0x prefixes --- release-lockfile.spec.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index ee1bdb6..cf1281b 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -58,7 +58,7 @@ contract to be functional. The sections of code which are unlinked **must** be filled in with zero bytes. -* unlinked bytecode: `606060405260e06000730000000000000000000000000000000000000000634d536f` +* unlinked bytecode: `0x606060405260e06000730000000000000000000000000000000000000000634d536f` #### Linked Bytecode @@ -67,7 +67,7 @@ Linked bytecode is the hexidecimal representation of a contract's EVM instructions which has had all *link references* replaced with the desired *link values* -* linked bytecode: `606060405260e06000736fe36000604051602001526040518160e060020a634d536f` +* linked bytecode: `0x606060405260e06000736fe36000604051602001526040518160e060020a634d536f` #### Link Reference From 1574655cc221239477f9b5b828c8dbf92c8eb0db Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Tue, 24 Apr 2018 18:41:16 -0400 Subject: [PATCH 10/11] Change offset to offsets --- release-lockfile.spec.md | 29 +++++++++++++++-------------- spec/release-lockfile.spec.json | 22 ++++++++++++++-------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index cf1281b..dcebb49 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -75,7 +75,7 @@ instructions which has had all *link references* replaced with the desired A location within a contract's bytecode which needs to be linked. A link reference has the following properties. -* `offset`: Defines the location within the bytecode where the link reference begins. +* `offsets`: Defines the location within the bytecode where the link reference begins. * `length`: Defines the length of the reference. * `name`: A string that **must** be a valid *Contract Name* @@ -305,15 +305,16 @@ specification. A link reference object has the following key/value pairs. All link references are assumed to be associated with some corresponding bytecode. -#### Offset: `offset` +#### Offset: `offsets` -The `offset` field is an integer which defines the start position for the link -reference. The location is a 0-indexed offset from the beginning of the binary -representation of the corresponding bytecode. This field is invalid if it -references a position that is beyond the end of the bytecode. +The `offsets` field is an array of integers, corresponding to each of the +start positions where the link reference appears in the bytecode. +Locations are 0-indexed from the beginning of the binary representation of +the corresponding bytecode. This field is invalid if it references a position +that is beyond the end of the bytecode. * Required: Yes -* Type: Integer +* Type: Array #### Length: `length` @@ -342,16 +343,16 @@ link references which **should** be linked with the same *link value* A *Link Value* object is defined to have the following key/value pairs. -#### Offset `offset` +#### Offset `offsets` -The `offset` field defines the location within the corresponding bytecode where -the `value` for this *link value* was written. This location is a -0-indexed offset from the beginning of the binary representation of the +The `offsets` field defines the locations within the corresponding bytecode +where the `value` for this *link value* was written. These locations are +0-indexed from the beginning of the binary representation of the corresponding bytecode. * Required: Yes -* Type: Integer -* Format: The integer **must** conform to all of the following: +* Type: Array +* Format: Array of integers, where each integer **must** conform to all of the following: * be greater than or equal to zero * strictly less than the length of the unprefixed hexidecimal representation of the corresponding bytecode. @@ -429,7 +430,7 @@ the corresponding bytecode. Validation of this field includes the following: -* No two link value objects may contain the same `offset`. +* No two link value objects may contain any of the same values for `offsets`. * Each link value object **must** have a corresponding link reference object under the `link_references` field. * The length of the resolved `value` **must** be equal to the `length` of the corresponding link reference. diff --git a/spec/release-lockfile.spec.json b/spec/release-lockfile.spec.json index 8cce2eb..089f419 100644 --- a/spec/release-lockfile.spec.json +++ b/spec/release-lockfile.spec.json @@ -204,14 +204,17 @@ "title": "A defined location in some bytecode which requires linking", "type": "object", "required": [ - "offset", + "offsets", "length", "name" ], "properties": { - "offset": { - "type": "integer", - "minimum": 0 + "offsets": { + "type": "array", + "items": { + "type": "integer", + "minimum": 0 + } }, "length": { "type": "integer", @@ -226,13 +229,16 @@ "title": "A value for an individual link reference in a contract's bytecode", "type": "object", "required": [ - "offset", + "offsets", "value" ], "properties": { - "offset": { - "type": "integer", - "minimum": 0 + "offsets": { + "type": "array", + "items": { + "type": "integer", + "minimum": 0 + } }, "value": { "title": "The value for the link reference", From a4eeb1da1a62d835c716fddcc07f64e7d4decc2e Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Tue, 24 Apr 2018 18:51:46 -0400 Subject: [PATCH 11/11] Generalize LinkReference name as any identifier --- release-lockfile.spec.md | 4 ++-- spec/release-lockfile.spec.json | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/release-lockfile.spec.md b/release-lockfile.spec.md index dcebb49..74f7c5a 100644 --- a/release-lockfile.spec.md +++ b/release-lockfile.spec.md @@ -77,8 +77,8 @@ reference has the following properties. * `offsets`: Defines the location within the bytecode where the link reference begins. * `length`: Defines the length of the reference. -* `name`: A string that **must** be a valid *Contract Name* - +* `name`: A string that **must** match the regular expression +`[a-zA-Z][-a-zA-Z0-9_]*`. #### Link Value diff --git a/spec/release-lockfile.spec.json b/spec/release-lockfile.spec.json index 089f419..1cabc9d 100644 --- a/spec/release-lockfile.spec.json +++ b/spec/release-lockfile.spec.json @@ -221,7 +221,7 @@ "minimum": 1 }, "name": { - "$ref": "#/definitions/ContractInstanceName" + "$ref": "#/definitions/Identifier" } } }, @@ -251,6 +251,10 @@ } } }, + "Identifier": { + "type": "string", + "pattern": "^[a-zA-Z][a-zA-Z0-9_]*$" + }, "ContractInstanceName": { "title": "The name of the deployed contract instance", "type": "string",