Questions tagged [memory]

Questions related to memory use in Solidity or by nodes

46 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4 votes
2 answers
2k views

Declaring a memory array of storage pointers in Solidity

I would like to declare a variable as a memory array of pointers to storage arrays of uint256. For example: pragma solidity ^0.4.24; contract A { uint256[] public array0; uint256[] public ...
Jesbus's user avatar
  • 10.3k
4 votes
3 answers
641 views

convert bytes to uint8[8] using mstore()

I know how to convert bytes to uint8[8] using mload but mstore seemed like it could be more gas efficient. Is something like this possible? function bytesToUintArray(bytes input) returns (uint8[8])) ...
antevirus's user avatar
4 votes
1 answer
393 views

personal.newAccount("mypassword") stops the server when i create two accounts consecutively in local privatenet

personal.newAccount("mypassword") stops the server when i try to create two accounts one after the another. personal.unlockAccount(eth.accounts[0],"mypassword"); same happens when I try unlock ...
Priyanka D L's user avatar
3 votes
0 answers
272 views

Quorum failure - Failed to decode message from payload

We use in our project -JP Morgan Quorum (Ethereum based) bloackchain - with istanbul voting mode. We have 4 nodes (3 of them are validators - hard coded, nonchangable) And from time to time (...
Nick Kernel's user avatar
2 votes
1 answer
15 views

Can you please explain this concept and how it works?

I would like to clear my doubt that when caller and called contract are same. Then the memory will get a new initialization right? or is it a different case.
Mayank Jamwal's user avatar
2 votes
1 answer
2k views

Calling a function with calldata parameter from another contract

Contact A: function redeemAssetsForBuyback(address[] calldata tokens) external { // ... } I would like to call redeemAssetsForBuyback from Contract B: function initiateRedeem() external { // ... ...
CeamKrier's user avatar
  • 121
2 votes
0 answers
239 views

Converting static variable to memory

I have the following code snippet in my contract, trying to call flashLoan from Aave. address private constant LINK = 0x...; function myFlashLoanCall(uint256 _amount, bytes memory _params) public {...
mtheorylord's user avatar
2 votes
0 answers
777 views

What is the default cache value of Geth?

According to the help page of Geth, --cache value defines Megabytes of memory allocated to internal caching (default = 4096 mainnet full node, 128 light mode) (default: 1024) I don't quite get it, is ...
msa's user avatar
  • 123
2 votes
0 answers
424 views

How to store array parameter of a function to contract state?

I am trying to save an invoice to contract storage (see function addNewInvoice(..)) but I seem to be tripping over the data locations. // SPDX-License-Identifier: private pragma solidity >=0.7.0; ...
chspr's user avatar
  • 21
2 votes
0 answers
133 views

Is it possible for a mapping to run out of space?

Can storage mappings in a contract run out of space? Say that mapping was keyed to an address and the value as the following struct: User bytes32 name uint8 age Theoretically, if there was a ...
The Nomad's user avatar
  • 399
2 votes
0 answers
91 views

Assembly operations throw warnings during compiling

Leveraging the following common string utility has been quite helpful, but would like to get rid of a warning: function stringToBytes32(string memory source) returns (bytes32 result) { assembly ...
skarred14's user avatar
  • 945
2 votes
0 answers
64 views

How does a plot "Gas price to call / memory allocated" looks like?

Pretty simple question: i.e. I have a dummy contract like this one: contract simple { uint[] dataArray; function push_one_more() { dataArray.push(1); } } How does the cost of ...
Sergey Potekhin's user avatar
1 vote
1 answer
141 views

Dynamic arrays in memory layout

I think i've figured out dynamic memory layout for dynamic arrays, but could use a check on my reasoning. Consider the contract : pragma solidity >=0.8.4; struct state_type { bytes b;...
Bobo's user avatar
  • 21
1 vote
1 answer
82 views

What does keyword memory in function return means

In some contexts, the keyword memory seems quite similar to a reference type in C++, where it gives an alias to a variable (see method 1 below). It confuses me when it's used to specify the return ...
Yongkin's user avatar
  • 13
1 vote
0 answers
36 views

Why Is My Smart Contract Not Able To Be Optimized?

I have a smart contract that is barely below the limits of the solidity compiler. When I try to enable optimization at 200 runs I get this error: CompilerError: Stack too deep when compiling inline ...
Jim's user avatar
  • 173
1 vote
1 answer
241 views

Understanding memory type solidity in function's return type

pragma solidity ^0.8.0; contract Crud { struct Users{ uint id; string name; } Users[] users; // this is type storage uint length = 0; function addUser(string ...
Rajan Lagah's user avatar
1 vote
0 answers
1k views

Using memory vs storage for arrays in structs in Solidity - Q&A

Wanted to share what I learned to help someone in the future running into a similar issue: I have this struct, which includes two arrays. In createNewEvent, I initialize two arrays, confirmedRSVPs and ...
camcam's user avatar
  • 11
1 vote
2 answers
360 views

Why does this function not update my storage array?

Since reference types such as arrays are passed by reference by in Solidity, they pass a reference (pointer) to the value. Any change to that value will reflect on original value. If this is the case, ...
Emrah's user avatar
  • 1,564
1 vote
1 answer
75 views

Memory to memory assignment doesn't point to the same reference

Hey I am trying to understand data location more it is stated in the docs that "Assignments from memory to memory only create references. This means that changes to one memory variable are also ...
jmsandiegoo's user avatar
1 vote
1 answer
81 views

default storage location

This post (When should I use calldata and when should I use memory?) explains the differences between calldata and memory. However where are function arguments or variables within functions stored if ...
Friedrich Coen's user avatar
1 vote
0 answers
25 views

How to give an array in storage value from an array from a function's input parameters

Below is the code that I have: struct Cow{ uint age; uint name; } Cow[] cows; // this is the code I am trying below. function createCows(Cow[] memory _cows) public { cows =_cows; } When ...
YulePale's user avatar
  • 1,823
1 vote
0 answers
114 views

Saving String Memory Argument to Struct Array

I have the following Solidity code that compiles and tests okay, but the insurancePlan property of the Patient struct is not being saved. I've tried many variations and it is just blank (empty) when I ...
namket's user avatar
  • 11
1 vote
0 answers
409 views

How store memory array in storage

In this code, I want to send an array of bytes32 and store them in the struct but I get the error which is TypeError: Type string memory[8] memory is not implicitly convertible to expected type ...
mohsen's user avatar
  • 53
1 vote
0 answers
84 views

Private Ethereum PoA error: "out of memory"

I'm working with multi node setup on Ethereum private chain PoA. We have all three validator nodes. blockchain ├── genesis.json ├── node1 │ ├── geth │ ├── keystore │ ├── ...
Div's user avatar
  • 361
1 vote
0 answers
35 views

Calling private function from external - where are referenced type parameters stored in the end?

Let's assume we have something like: contract C { function externalFunction(uint256[] calldata data) external { privateFunction(data); } function privateFunction(uint256[] memory data)...
KwahuNashoba's user avatar
1 vote
0 answers
39 views

Why is an address changing when I add it to an array?

I'm encountering a memory / storage issue (I think) w/ an array of addresses where I want to swap out one address with another. Here's how I've initialized the array: address[] public maintainers; ...
dougiebuckets's user avatar
1 vote
0 answers
59 views

getLogs RPC makes filters?

I am stuggling with memory explosion issue of Parity on my EC2 instance. The memory usage of it keeps increasing gradually. I suspect that getLogs API call makes some garbage on the node. But I ...
santony's user avatar
  • 135
1 vote
1 answer
12k views

GPU'S Failed cannot create DAG

Last night everything is fine and then this morning I check my mining its's closed I think it was restarted or close accidentally then when I open my pool I have this error. ETH: 5 pools are ...
Carlvic Lim's user avatar
1 vote
0 answers
88 views

Solidity VM memory management

I'm trying to do an external function call in assembly. So I have to prepare a memory area that store the input args. But where's the address that I should start with mstore? I mean, there are some ...
Jerrylk's user avatar
  • 13
1 vote
0 answers
29 views

How load out data from blockchain when it occupies too much space?

If the blockchain working long enough it fills the memory of the mining device, how to load out the data and then rerun the system? and why does my mining device has different miner address every time ...
Nurbolat K's user avatar
1 vote
0 answers
429 views

For what data does Ethereum use Memory Database, and for what does it use Level Database

Ethereum uses two databases Memory database and Level Database. Is data stored in MemoryDatabase different than LevelDb? In what cases is one database used over other? The question is different from -...
Shubham Chaudhary's user avatar
1 vote
0 answers
580 views

Extreme memory consumption by geth

I'm using geth's traceTransaction() API to index certain opcodes that are used in transactions. When I request traces from some transactions (e.g. ...
Loonix Tarballs's user avatar
0 votes
1 answer
14 views

Inline assembly loop doesn't update memory

I want to copy in inline assembly from calldata the last two bytes of every 32 byte slices to the lower half of the first free memory slot(32 bytes). free = free memory pointer + 14 (bytes) moffset = ...
Igor József Vass's user avatar
0 votes
0 answers
33 views

Why "It's better to use the bytes type instead of the bytes1[] type"? Solidity

I read a Note in documentation of Solidity: The type bytes1[] is an array of bytes, but due to padding rules, it wastes 31 bytes of space for each element (except in storage). It is better to use the ...
Trong-Hieu Nguyen's user avatar
0 votes
0 answers
41 views

How would look like calldata for bytes[] calldata argument?

Imagine I have a function with such signature in Solidity: function doThing(bytes[] calldata arr) external; how are elements of arr are packed in bytes? I would say that first 4 bytes is bytes4(...
gabbi's user avatar
  • 1
0 votes
1 answer
44 views

Changing storage ref to storage pointer

In the function registerUser below, I am trying to access a global array of structs, and seeing if the argument I have passed exists in the global array or not. The code is as follows: user_details[] ...
Dhairya Khale's user avatar
0 votes
0 answers
56 views

How does EVM handle when passing a memory type variable as a function parameter of type memory?

There are two things that are bugging me about the below smart contract: In the below contract, I noticed that the orders variable declared with the memory keyword in sortTheArrayOrders function is ...
Bobtheblobber's user avatar
0 votes
0 answers
245 views

Maximum amount of state vars, smart contract storage limit and scalable architecture in Solidity

While architecting a smart contract system, which is expected to grow to a large size and be highly scalable, the question arose to use a central module with storage and functionality set in one place ...
Whytecrowe's user avatar
0 votes
0 answers
18 views

string storage vs memory

i have a function in my smart contract which needs a string to work, and for this i have two options : OPTION 1 : Store my string in a state variable : contract A { string public immutable ...
noro meb's user avatar
  • 328
0 votes
1 answer
187 views

Copying of type struct '' memory to storage not yet supported

I can't figure out how to initial this data for the life of me. I have 2 structs which looks like so: struct UserVotes { address userAddress; VoteOptionAmounts[] votes; } struct VoteInfo { ...
Ritzy Dev's user avatar
  • 271
0 votes
0 answers
298 views

Solidity dynamic arrays in memory: overflow bug

I was trying to create a lottery smart contract that stores every tickets (ticket = address) that someone buys into into an array to later on select winners from it. Unfortunately I stumbled into an ...
Puddi's user avatar
  • 1
0 votes
1 answer
28 views

return array of size n

I need a function that willl return an array of size n and have each element be a 1. How do I write this in solidity? I need something like uint256[] a = makeOnesArray(5) => [1, 1, 1, 1, 1]
degendeveloper's user avatar
0 votes
1 answer
503 views

Initialising an array with a single value in solidity

I want to create an array of all 1's. As per my understanding, doing it manually after declaration through a for loop will lead to high gas expense. So, is there any way to initialize an array at once,...
Hrishabh's user avatar
0 votes
0 answers
611 views

Memory Arrays Should Have Push() And Pop()

Dynamic memory arrays currently cannot be resized. This is true for Solang and solc solidity. However, Solang uses a heap, and has a realloc() function. Thus it is is possible for Solang to support ...
user60454's user avatar
0 votes
0 answers
51 views

How to save/read mappings within struct?

I am trying to create a mapping inside struct and then create a mapping of the struct. Take a look at below example: // ------------------------------------------------------------------------ ...
Fariha Abbasi's user avatar
0 votes
0 answers
1k views

FATAL ERROR: Rebalance Allocation failed - process out of memory

So while running truffle compile for my contracts on AWS Ubuntu server I got the following error: <--- Last few GCs ---> [17055:0x3985730] 11958 ms: Scavenge 511.7 (553.4) -> 506.9 (553.4) ...
Gagan's user avatar
  • 423