Skip to main content

Questions tagged [memory]

Questions related to memory use in Solidity or by nodes

Filter by
Sorted by
Tagged with
3 votes
2 answers
2k views

Is it possible to copy the internal storage of a smart contract to a new contract?

Assume that I want to implement my own version of a suicide contract function with extended functionality. More specifically, I want to copy the internal storage state of the contract to a new ...
Mike B's user avatar
  • 131
3 votes
1 answer
3k views

Restrict CPU/memory usage of geth while syncing

I'm trying to run a geth node and a bitcoin core node on one server. I started with a DigitalOcean droplet with 2 CPU and 2GB memory, but both the geth and bitcoin node would run out of memory. I ...
Inigo's user avatar
  • 131
3 votes
1 answer
467 views

Mist 0.8.6 crashing with Couldn't connect to node? See the logs for more

I have updated Ethereum-Wallet to 0.8.6. My accounts were not showing up in Wallet, so I deleted the .ethereum folder (after taking a backup) and restarted Wallet, but now I was unable to run wallet, ...
Prashant Prabhakar Singh's user avatar
3 votes
1 answer
235 views

why is preloading uint256 array into memory for a for loop faster?

sload loads a word from storage. https://ethereum.github.io/yellowpaper/paper.pdf if we have a loop over uint256, both preloading into memory and loading within the loop should use the same number ...
kirill_igum's user avatar
3 votes
1 answer
1k views

Geth Version: 1.9.12-stable keeps getting killed...Out of memory: Kill process (geth) score 901 or sacrifice child

I am experiencing issues with my Geth (Version: 1.9.12-stable) nodes. Very often Geth exhausts all memory, which causes a sudden drop in blocks, resulting in the node falling behind. I am running ...
tovsky's user avatar
  • 31
3 votes
2 answers
308 views

How to get live mempool transactions whitout full blokchain

I just want to analyse all mempool txs in realtime. I cant use an api because after several requests my ip gets blocked for some minutes, so I dont get the txs in this time. Thank you for help.
Wahrscheinlich dein Vater's user avatar
3 votes
1 answer
895 views

Can I reduce the space chaindata takes up?

So the size of my chaindata folder has snowballed to close to 80GB. Is there a way to reduce it or is the only way to delete it and resync geth with --syncmode fast? Thanks!
Tomas Vrba's user avatar
3 votes
1 answer
256 views

My disk has only 1 GB free - how can I use the Linux Ethereum Wallet?

I just downloaded the Ethereum Wallet for Debian Linux (I have Ubuntu 16.04). It appears to be downloading a lot of blocks: it now says that there are 3,310,606 blocks, and the number is decreasing. I ...
Erel Segal-Halevi's user avatar
3 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
  • 131
3 votes
0 answers
281 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
2 answers
1k views

Where is the length of an array located in terms of memory layout?

For example, given the following cases: uint[3] memory arr; uint[] memory arr = new uint[](3); Suppose I try to access arr from within an assembly block (using mload, for example). Where (...
goodvibration's user avatar
2 votes
2 answers
6k views

how does Storing and Fetching data works in Smart contracts [closed]

Please help me out with these questions. 1)Where does the contract stores the data? 2)when we access the value of a variable form of a contract, how does it retrieve the latest value? 3)how is the ...
Yash Shukla's user avatar
2 votes
2 answers
1k views

How could Solidity 0.5.0 dynamic sized parameters be declared as storage?

As I understand it 'memory' in the EVM is a byte array and cannot be dynamically resized, whereas 'storage' is able to be resized. What is happening when a parameter is declared as storage. Where is ...
arete's user avatar
  • 609
2 votes
2 answers
156 views

Are storage values copied or referenced?

Given this contract contract C { struct Product { uint price } Product[] storage products; function doSomething() { products.push(Product({price: 100})); products.push(...
Luke Hutchison's user avatar
2 votes
2 answers
2k views

What is the proper pattern to use a temporary variable and ensure it gets stored?

A contract has a state variable, which is complex. For the example, lets say it is a mapping of structs. Inside a method, I want to access that and store the changes. Like so: contract FooManager { ...
berkes's user avatar
  • 217
2 votes
2 answers
3k views

Convert 'bytes memory' to 'bytes8'

In solidity, how can I convert bytes memory buffer to bytes8 type? Example: bytes8 buf2 = bytes8(memory_buf); // TypeError: Explicit type conversion not allowed
Alianse777's user avatar
2 votes
1 answer
107 views

Is memory logged in a transaction?

Data in memory during a transaction is deleted when execution stops. This means this information is not stored in the contract state, but is the information that was in memory during the transaction ...
Curious2424's user avatar
2 votes
1 answer
116 views

Why can you slice bytes in calldata but not in memory?

If trying to slice bytes in memory one gets the error below. The solidity docs give no explanation just state that array slices are only supported for calldata as of now. TypeError: Index range access ...
FreddyC's user avatar
  • 301
2 votes
1 answer
435 views

Always use "memory" for variables created within functions. Bad practice?

Is it bad practice to systematically use the memory keyword for variables declared within a function (other than constructor)?
hartmut's user avatar
  • 488
2 votes
1 answer
426 views

Can marking object as 'memory' before pushing in Array save gas?

We have a struct: struct structEx { uint num; } And an array: structEx[] arr; Have a look at this code snippet, which just instantiates the struct and push: function f() public { structEx s =...
Karan's user avatar
  • 416
2 votes
1 answer
915 views

How to make mining efficient in terms of memory, for a light weight client?

Since mining is resource intensive process, how to make it more efficient for a lightweight client in terms of memory. I am ready for a trade off even it takes more time to mine than what it would ...
Bhoopesh kumar goyal's user avatar
2 votes
1 answer
90 views

Two ways of assigning a pointer. Is there a difference?

Here's one way to assign a pointer to variable z: function f(uint8[] memoryArray){ var z = memoryArray; } and here's another function f(uint8[] memoryArray){ uint8[] memory z = memoryArray; ...
manidos's user avatar
  • 4,298
2 votes
1 answer
45 views

Best practices for working around the lack of dynamically sized memory arrays in solidity

Consider the following solidity function: function example(uint256[] calldata _numbers) external { uint256[] memory _evenNumbers; // initialize `_evenNumbers` and populate it with even ...
Sam's user avatar
  • 103
2 votes
1 answer
376 views

Can't find memory field in structLogs field in debug_traceTransaction RPC Call

I'm trying to index internal eth transactions transactions of the Ethereum blockchain and as it is not present in the logs, the way is to replay the transaction with debug_tracetransaction so I can ...
Cyriaque Pin's user avatar
2 votes
2 answers
145 views

why a parameter must be "storage" or "memory"?

I am creating a token like this: pragma solidity ^0.5.0; import "../utils/math/SafeMath.sol"; contract ExampleDivisibleNFTs { using SafeMath for uint256; // Percentage of ownership over a ...
misael zurdo's user avatar
2 votes
3 answers
1k views

value types(uint, bool, etc) as local variable is set to memory initially?

According to this answer, it says simpler variables like bool, uint, et cetera are not variable in length, and are therefore defaulted to memory, whereas this one mentions uint256 v; is default to ...
bbusdriver's user avatar
  • 1,154
2 votes
1 answer
111 views

Examples of functions limitations?

I coded different functions and didn't find a standard that define crystal clear how many variables you can use (fields, local or as parameters of modifiers inside this function? Do you know a ...
Mario Granero's user avatar
2 votes
1 answer
3k views

Is there a maximum size for arrays in Solidity?

In my solidity code I define 3 arrays with around 700 elements inside. However, when I try to deploy the contract using Geth I am having the following error message: Error: oversized data undefined ...
Önder Gürcan's user avatar
2 votes
1 answer
228 views

Why is the cost of memory non-linear, while the cost of storage is linear?

Why is the cost of memory non-linear, while the cost of storage is linear? I wonder why the cost function of memory vs. storage differ? While storage is associated with a constant cost, this is not ...
Shuzheng's user avatar
  • 1,855
2 votes
2 answers
521 views

How much memory do I need to mine any blocks on my lockal network?

I have linux box with 5Gb of memory: osboxes@osboxes ~/node1 $ free total used free shared buff/cache available Mem: 5176876 158360 3536464 ...
Stepan Yakovenko'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
0 answers
243 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
834 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
428 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
135 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
2 answers
904 views

Is the EVM memory model a word array or byte array?

The yellow paper says that the memory model for the EVM is a word-addressed byte array (YP 9.1), but when I run debug.traceTransaction in Geth, the memory looks more like an array of words, maybe a ...
John Stanford's user avatar
1 vote
3 answers
499 views

Where are local variables of Primitive (Elementary) data types stored in Solidity

Though in the latest solidity compiler versions, it has been made clear that for reference variables local to a function, one needs to now explicitly mention its location modifier (memory, storage), ...
Kombo's user avatar
  • 353
1 vote
1 answer
12k views

Type error: memory is not implicitly convertible to expected type

I have a function that returns a list of BetProposition smart contracts: function getBetsForMatchup(uint matchupIdentifier) public returns (BetProposition[]) { return bets[matchupIdentifier]; ...
user339946's user avatar
1 vote
1 answer
2k views

Solidity: Convert from "bytes memory" to "address"

I'm using solidity 0.5.0 and when i try to compile my contract it's giving me this error Explicit type conversion not allowed from "bytes memory" to "address" my code is this: /// @dev get broker ...
caitlinp's user avatar
1 vote
2 answers
1k views

Why cryptokitties uses storage instead of memory?

There are a lot of explainations of storage and memory out there like this question or this question. But I'm wondering why cryptokitties for example uses storage instead of memory in many functions. ...
MarcS82's user avatar
  • 323
1 vote
1 answer
3k views

Hidden problems in "set array to empty array to clear it" approach

I needed a way to clear a storage array in my contract. I've seen this answer, but I tried to think of different approach (My arrays are most probably will contain enormous amount of elements) and ...
whyamiroot's user avatar
1 vote
1 answer
639 views

Data location specification and bytes32

Why is data location not required to be specified for bytes32?
Rachid Atmai's user avatar
1 vote
1 answer
577 views

Where does mapping store a variable if an address is already used?

I know that mapping use addresses, based on a hash of key + position of mapping storage variable keccak256(bytes32(variable_address) + bytes32(key)) And I want to know where variable would be stored ...
30mb1's user avatar
  • 369
1 vote
1 answer
113 views

Does it make any sense to specify reference type function input parameters as calldata if the given function is only called contract to contract?

As far as I am aware contract to contract calls store input arguments in memory. Or put more precisely they store them in memory and they can be accessed with CALLDATALOAD within the the new call ...
FreddyC's user avatar
  • 301
1 vote
2 answers
345 views

Define a struct in library vs in the contract

I have a struct defined in a library (to call it from different contracts): library DataTypes { struct Test{ uint256 a; uint256 b; } when i want to initialize it or update in my ...
noro meb's user avatar
  • 368
1 vote
1 answer
79 views

Why cannot insert elements dynamically into 2D memory array

I have some issues with understanding exactly how the arrays and memory works in solidity, but I found this nice question that kind of help me to understand some parts - Solidity 2D in-memory array ...
VitoCK's user avatar
  • 161
1 vote
1 answer
297 views

Loading an array into memory, does it call `SLOAD` many times?

Let's say I have an array in storage: // SPDX-License-Identifier: MIT pragma solidity ^0.8.7; contract Test { uint256[] s_array = [1,2,3,4,5,6,7,7,8,8,8,8,8,8,8,8,8,8,8]; function doStuff() ...
Patrick Collins's user avatar
1 vote
1 answer
1k views

What is the layout of returndata from returndatacopy opcode?

I am attempting to perform operations on returned data from delegatecall opcode using a similar familiar proxy pattern: assembly { let ptr := mload(0x40) // load empty memory address pointer ...
Shiri's user avatar
  • 796