Skip to content

Commit

Permalink
Add configurables section offset in the preamble (#6522)
Browse files Browse the repository at this point in the history
The preamble now contains 8 bytes of offset to the configurables
section. If there is no configurable const in the data-section, then the
value of this integer will be equal to the size of the binary itself.

This also means that we now sort the data-section to have all the
non-configurables first, and then the configurables.

The preamble final asm looks like this (the offset to configurables is
0'd out here in the example):
```
;; ASM: Final program
;; Program kind: Script
.program:
move $$tmp $pc
jmpf $zero i10
DATA_SECTION_OFFSET[0..32]
DATA_SECTION_OFFSET[32..64]
CONFIGURABLES_OFFSET[0..32]
CONFIGURABLES_OFFSET[32..64]
lw   $$ds $$tmp i1
add  $$ds $$ds $$tmp
```
The preamble bytecode looks like this:

```
0x00000000 MOVE R60 $pc                                    ;; [26, 240, 48, 0]
0x00000004 JMPF $zero 0xa                                  ;; [116, 0, 0, 10]
0x00000008                                                 ;; [0, 0, 0, 0, 0, 0, 2, 40]
0x00000010                                                 ;; [0, 0, 0, 0, 0, 0, 0, 0]
0x00000030 LW R63 R60 0x1                                  ;; [93, 255, 192, 1]
0x00000034 ADD R63 R63 R60                                 ;; [16, 255, 255, 0]
...
```

---------

Co-authored-by: Sophie Dankel <[email protected]>
Co-authored-by: IGI-111 <[email protected]>
  • Loading branch information
3 people committed Nov 11, 2024
1 parent b75e6fd commit 0e875cf
Show file tree
Hide file tree
Showing 34 changed files with 3,868 additions and 34 deletions.
8 changes: 4 additions & 4 deletions forc-plugins/forc-client/tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ async fn test_simple_deploy() {
node.kill().unwrap();
let expected = vec![DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"5c51b8904c539700852c646c6700fddab4b80477f66e56fb2515736facd84e69",
"adcd0480deb735ffd8f5bd0683b66c55465e0841076efca4c28be25c767ede5b",
)
.unwrap(),
proxy: None,
Expand Down Expand Up @@ -416,7 +416,7 @@ async fn test_deploy_submit_only() {
node.kill().unwrap();
let expected = vec![DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"5c51b8904c539700852c646c6700fddab4b80477f66e56fb2515736facd84e69",
"adcd0480deb735ffd8f5bd0683b66c55465e0841076efca4c28be25c767ede5b",
)
.unwrap(),
proxy: None,
Expand Down Expand Up @@ -462,12 +462,12 @@ async fn test_deploy_fresh_proxy() {
node.kill().unwrap();
let impl_contract = DeployedPackage::Contract(DeployedContract {
id: ContractId::from_str(
"5c51b8904c539700852c646c6700fddab4b80477f66e56fb2515736facd84e69",
"adcd0480deb735ffd8f5bd0683b66c55465e0841076efca4c28be25c767ede5b",
)
.unwrap(),
proxy: Some(
ContractId::from_str(
"7a78517c2c3322028db65e54893dc97958fa3d7c846a66f5675859e64f927540",
"5297238a1d867c9d7c8fa83c700e2d0d1c57e1874ec95ff4a67063e222ab1880",
)
.unwrap(),
),
Expand Down
Loading

0 comments on commit 0e875cf

Please sign in to comment.