<100 subscribers
Share Dialog
Share Dialog
Private functions are only accessible to the contract that defines it.
Internal functions are only accessible to the contract that defines it and any child contracts that inherit it.
External functions are only accessible externally by other contracts and are not visible inside the contracts that define them. External uses less gas than public.
Public functions are accessible to the contract that defines it and to any external contract or third party that calls it. The public is the default visibility.
EIP-170 set the contract code size limit to 0x6000 bytes (i.e 24,576 bytes) which results in a contract creation failure with an out-of-gas error. It was introduced to address the slight quadratic vulnerability in Ethereum and prevent DOS denial of service attacks.
Although the nodes are compensated with gas fees for the computational work that they perform when executing a transaction, there are additional costs associated with maintaining and interacting with the smart contract that are not directly covered by the gas fees.
Storage Costs: storing the contract’s bytecode and state on the blockchain incurs storage costs for the nodes. As the size of the contract grows, so does the storage cost for the nodes
Disk Access and Preprocessing: reading the contract’s bytecode from disk and preprocessing it for execution on the virtual machine also imposes computational overhead on nodes.
Merkle Proof Generation: Generating Merkle proofs for contract state verification , especially for large contracts or complex state structures.
Gas fees do not adequately cover these long-term costs associated with maintaining and interacting with smart contracts. This creates a potential imbalance where the deployer of a contract may incur relatively low transaction costs while imposing a significantly higher computational burden on the nodes after deployment.
Without a maximum contract size or other mechanisms to limit the computational workload imposed by smart contracts, there is a risk that malicious actors could deploy large contracts or design contract interactions in a way that maximizes computational work for nodes, effectively conducting a Denial-of-Service (DoS) attack on the network.
Even with a limited contract size, the attack is only deterrant, not impossible. The attacker will have to create multiple large contracts , multiplying the cost and making it more difficult to execute a coordinated attack effectively.
EVM has 2 opcodes to create a new contract address. Create and Create2.They are both used to determine the address of the smart contract even before it is deployed.
CREATE: A new contract can take the hash of the sender address and nonce.
Precisely, the last 20 bytes of keccak256 of RLP encoding of the creator’s contract address and a nonce. Every account has an associated nonce; for regular accounts, it is increased on every transaction. For contract accounts, it is increased on every contract creation. Since nonces can’t be reused and must be sequential, it’s almost possible to predict the address where the next created contract will be deployed, onyl if no other transaction happens before that which is an undesirable property of counterfactual systems, says openzeppelin. So, CREATE is not reliable to predict the address accurately.
CREATE2:
The address of the new contract created is by taking the keccak256 hash of contract offset constant 0xFF, deployer address, salt(an arbitrary value provided by the deployer), and contract initialization code. Since the deployer provides the salt value, it’s theoretically possible to choose a desirable address by adjusting the salt value.
Arithemetic operations revert on underflow and overflow . They are checked by default default and Panic(0x11) error is throw and the call iss reverted.
Delegate call is required for proxy to work. delecate call executes code in another contract in the context of the contract that calls it.For this to work, the storage layout must be preserved. When A executes delegatecall to B, B’s code is executed with the context of A’s storage, A’s msg.sender and A’s msg.value. The implementation contract can be upgraded without the smart contract having to change the address of the proxy.
Prior to EIP-1559,The miner received 100% of the gas cost.
Dollar Cost = (Gas Price * Gas Used / 1e9) * Ether Exchange Rate
Gas used: The amount of gas consumed by the transaction.
Gas price: The price per unit of gas specified by the sender in Gwei (1 Gwei = 0.000000001 ETH).
1e9: is 10 to the power 9,for conversion from gwei to ether.
Ether Exchange Rate: The current exchange rate of Ether to US dollars.
Dollar Cost = (Base Fee + Priority Fee) * Gas Used / 1e9 * Ether Exchange Rate
Base Fee(Gwei): The minimum fee required to include a transaction in a block.Its dynamically adjusted based on network congestion.The fee is then burned.
Priority Fee:(Tip) The amount paid to miners per gas to incentivize them to include the transaction. Users specify this fee.
Gas Used(units): The amount of gas that can be used for the transaction.
Ether Exchange Rate: The current exchange rate of Ether to US dollars.
Blockchain is deterministic. They must arrive at the same state after processing same set of transactions and all of this data is public. So, arriving at random number is challenging. althought attempts to generate random numbers from blocknumber and block timestamp can be used for limited randomness, they also pose the risk of miners poentially manipulating the process if they have significant hashing power.
Private functions are only accessible to the contract that defines it.
Internal functions are only accessible to the contract that defines it and any child contracts that inherit it.
External functions are only accessible externally by other contracts and are not visible inside the contracts that define them. External uses less gas than public.
Public functions are accessible to the contract that defines it and to any external contract or third party that calls it. The public is the default visibility.
EIP-170 set the contract code size limit to 0x6000 bytes (i.e 24,576 bytes) which results in a contract creation failure with an out-of-gas error. It was introduced to address the slight quadratic vulnerability in Ethereum and prevent DOS denial of service attacks.
Although the nodes are compensated with gas fees for the computational work that they perform when executing a transaction, there are additional costs associated with maintaining and interacting with the smart contract that are not directly covered by the gas fees.
Storage Costs: storing the contract’s bytecode and state on the blockchain incurs storage costs for the nodes. As the size of the contract grows, so does the storage cost for the nodes
Disk Access and Preprocessing: reading the contract’s bytecode from disk and preprocessing it for execution on the virtual machine also imposes computational overhead on nodes.
Merkle Proof Generation: Generating Merkle proofs for contract state verification , especially for large contracts or complex state structures.
Gas fees do not adequately cover these long-term costs associated with maintaining and interacting with smart contracts. This creates a potential imbalance where the deployer of a contract may incur relatively low transaction costs while imposing a significantly higher computational burden on the nodes after deployment.
Without a maximum contract size or other mechanisms to limit the computational workload imposed by smart contracts, there is a risk that malicious actors could deploy large contracts or design contract interactions in a way that maximizes computational work for nodes, effectively conducting a Denial-of-Service (DoS) attack on the network.
Even with a limited contract size, the attack is only deterrant, not impossible. The attacker will have to create multiple large contracts , multiplying the cost and making it more difficult to execute a coordinated attack effectively.
EVM has 2 opcodes to create a new contract address. Create and Create2.They are both used to determine the address of the smart contract even before it is deployed.
CREATE: A new contract can take the hash of the sender address and nonce.
Precisely, the last 20 bytes of keccak256 of RLP encoding of the creator’s contract address and a nonce. Every account has an associated nonce; for regular accounts, it is increased on every transaction. For contract accounts, it is increased on every contract creation. Since nonces can’t be reused and must be sequential, it’s almost possible to predict the address where the next created contract will be deployed, onyl if no other transaction happens before that which is an undesirable property of counterfactual systems, says openzeppelin. So, CREATE is not reliable to predict the address accurately.
CREATE2:
The address of the new contract created is by taking the keccak256 hash of contract offset constant 0xFF, deployer address, salt(an arbitrary value provided by the deployer), and contract initialization code. Since the deployer provides the salt value, it’s theoretically possible to choose a desirable address by adjusting the salt value.
Arithemetic operations revert on underflow and overflow . They are checked by default default and Panic(0x11) error is throw and the call iss reverted.
Delegate call is required for proxy to work. delecate call executes code in another contract in the context of the contract that calls it.For this to work, the storage layout must be preserved. When A executes delegatecall to B, B’s code is executed with the context of A’s storage, A’s msg.sender and A’s msg.value. The implementation contract can be upgraded without the smart contract having to change the address of the proxy.
Prior to EIP-1559,The miner received 100% of the gas cost.
Dollar Cost = (Gas Price * Gas Used / 1e9) * Ether Exchange Rate
Gas used: The amount of gas consumed by the transaction.
Gas price: The price per unit of gas specified by the sender in Gwei (1 Gwei = 0.000000001 ETH).
1e9: is 10 to the power 9,for conversion from gwei to ether.
Ether Exchange Rate: The current exchange rate of Ether to US dollars.
Dollar Cost = (Base Fee + Priority Fee) * Gas Used / 1e9 * Ether Exchange Rate
Base Fee(Gwei): The minimum fee required to include a transaction in a block.Its dynamically adjusted based on network congestion.The fee is then burned.
Priority Fee:(Tip) The amount paid to miners per gas to incentivize them to include the transaction. Users specify this fee.
Gas Used(units): The amount of gas that can be used for the transaction.
Ether Exchange Rate: The current exchange rate of Ether to US dollars.
Blockchain is deterministic. They must arrive at the same state after processing same set of transactions and all of this data is public. So, arriving at random number is challenging. althought attempts to generate random numbers from blocknumber and block timestamp can be used for limited randomness, they also pose the risk of miners poentially manipulating the process if they have significant hashing power.
No comments yet