ChainStorageContainer.md 3.45 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
# ChainStorageContainer



> ChainStorageContainer



*The Chain Storage Container provides its owner contract with read, write and delete functionality. This provides gas efficiency gains by enabling it to overwrite storage slots which can no longer be used in a fraud proof due to the fraud window having passed, and the associated chain state or transactions being finalized. Three distinct Chain Storage Containers will be deployed on Layer 1: 1. Stores transaction batches for the Canonical Transaction Chain 2. Stores queued transactions for the Canonical Transaction Chain 3. Stores chain state batches for the State Commitment Chain*

## Methods

13 14 15 16 17 18
### deleteElementsAfterInclusive

```solidity
function deleteElementsAfterInclusive(uint256 _index) external nonpayable
```

Indeavr's avatar
Indeavr committed
19
Removes all objects after and including a given index. Also allows setting the global metadata field.
20 21 22



23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#### Parameters

| Name | Type | Description |
|---|---|---|
| _index | uint256 | Object index to delete from.

### get

```solidity
function get(uint256 _index) external view returns (bytes32)
```

Retrieves an object from the container.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _index | uint256 | Index of the particular object to access.

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bytes32 | 32 byte object value.

### getGlobalMetadata

```solidity
function getGlobalMetadata() external view returns (bytes27)
```

Retrieves the container's global metadata field.




#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | bytes27 | Container global metadata field.

### length

```solidity
function length() external view returns (uint256)
```

Retrieves the number of objects stored in the container.




#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | uint256 | Number of objects in the container.

### libAddressManager

```solidity
function libAddressManager() external view returns (contract Lib_AddressManager)
```






#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | contract Lib_AddressManager | undefined

### owner

```solidity
function owner() external view returns (string)
```






#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | string | undefined

### push

121 122 123 124
```solidity
function push(bytes32 _object) external nonpayable
```

Indeavr's avatar
Indeavr committed
125
Pushes an object into the container. Function allows setting the global metadata since we'll need to touch the "length" storage slot anyway, which also contains the global metadata (it's an optimization).
126 127 128 129 130 131 132 133 134



#### Parameters

| Name | Type | Description |
|---|---|---|
| _object | bytes32 | A 32 byte value to insert into the container.

135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
### resolve

```solidity
function resolve(string _name) external view returns (address)
```

Resolves the address associated with a given name.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _name | string | Name to resolve an address for.

#### Returns

| Name | Type | Description |
|---|---|---|
| _0 | address | Address associated with the given name.

### setGlobalMetadata

```solidity
function setGlobalMetadata(bytes27 _globalMetadata) external nonpayable
```

Sets the container's global metadata field. We're using `bytes27` here because we use five bytes to maintain the length of the underlying data structure, meaning we have an extra 27 bytes to store arbitrary data.



#### Parameters

| Name | Type | Description |
|---|---|---|
| _globalMetadata | bytes27 | New global metadata to set.