Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VM/Common] move gas base fees to Common #806

Merged
merged 2 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/common/src/hardforks/byzantium.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@
"ecPairingWord": {
"v": 80000,
"d": "Gas costs regarding curve pairing precompile input length"
},
"revert": {
"v": 0,
"d": "Base fee of the REVERT opcode"
},
"staticcall": {
"v": 700,
"d": "Base fee of the STATICCALL opcode"
},
"returndatasize": {
"v": 2,
"d": "Base fee of the RETURNDATASIZE opcode"
},
"returndatacopy": {
"v": 3,
"d": "Base fee of the RETURNDATACOPY opcode"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Byzantium looks good, all opcodes included.

}
},
"vm": {},
Expand Down
266 changes: 249 additions & 17 deletions packages/common/src/hardforks/chainstart.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,36 @@
"d": "Gas base cost, used e.g. for ChainID opcode (Istanbul)"
},
"tierStep": {
"v": [0, 2, 3, 5, 8, 10, 20],
"v": [
0,
2,
3,
5,
8,
10,
20
],
"d": "Once per operation, for a selection of them"
},
"exp": {
"v": 10,
"d": "Once per EXP instuction"
"d": "Base fee of the EXP opcode"
},
"expByte": {
"v": 10,
"d": "Times ceil(log256(exponent)) for the EXP instruction"
},

"sha3": {
"v": 30,
"d": "Once per SHA3 operation"
"d": "Base fee of the SHA3 opcode"
},
"sha3Word": {
"v": 6,
"d": "Once per word of the SHA3 operation's data"
},
"sload": {
"v": 50,
"d": "Once per SLOAD operation"
"d": "Base fee of the SLOAD opcode"
},
"sstoreSet": {
"v": 20000,
Expand All @@ -60,12 +67,11 @@
},
"jumpdest": {
"v": 1,
"d": "Refunded gas, once per SSTORE operation if the zeroness changes to zero"
"d": "Base fee of the JUMPDEST opcode"
},

"log": {
"v": 375,
"d": "Per LOG* operation"
"d": "Base fee of the LOG opcode"
},
"logData": {
"v": 8,
Expand All @@ -75,15 +81,13 @@
"v": 375,
"d": "Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas"
},

"create": {
"v": 32000,
"d": "Once per CREATE operation & contract-creation transaction"
"d": "Base fee of the CREATE opcode"
},

"call": {
"v": 40,
"d": "Once per CALL operation & message call transaction"
"d": "Base fee of the CALL opcode"
},
"callStipend": {
"v": 2300,
Expand All @@ -97,12 +101,10 @@
"v": 25000,
"d": "Paid for CALL when the destination address didn't exist prior"
},

"selfdestructRefund": {
"v": 24000,
"d": "Refunded following a selfdestruct operation"
},

"memory": {
"v": 3,
"d": "Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL"
Expand All @@ -111,7 +113,6 @@
"v": 512,
"d": "Divisor for the quadratic particle of the memory cost equation"
},

"createData": {
"v": 200,
"d": ""
Expand All @@ -132,7 +133,6 @@
"v": 68,
"d": "Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions"
},

"copy": {
"v": 3,
"d": "Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added"
Expand Down Expand Up @@ -164,6 +164,238 @@
"identityWord": {
"v": 3,
"d": ""
},
"stop": {
"v": 0,
"d": "Base fee of the STOP opcode"
},
"add": {
"v": 3,
"d": "Base fee of the ADD opcode"
},
"mul": {
"v": 5,
"d": "Base fee of the MUL opcode"
},
"sub": {
"v": 3,
"d": "Base fee of the SUB opcode"
},
"div": {
"v": 5,
"d": "Base fee of the DIV opcode"
},
"sdiv": {
"v": 5,
"d": "Base fee of the SDIV opcode"
},
"mod": {
"v": 5,
"d": "Base fee of the MOD opcode"
},
"smod": {
"v": 5,
"d": "Base fee of the SMOD opcode"
},
"addmod": {
"v": 8,
"d": "Base fee of the ADDMOD opcode"
},
"mulmod": {
"v": 8,
"d": "Base fee of the MULMOD opcode"
},
"signextend": {
"v": 5,
"d": "Base fee of the SIGNEXTEND opcode"
},
"lt": {
"v": 3,
"d": "Base fee of the LT opcode"
},
"gt": {
"v": 3,
"d": "Base fee of the GT opcode"
},
"slt": {
"v": 3,
"d": "Base fee of the SLT opcode"
},
"sgt": {
"v": 3,
"d": "Base fee of the SGT opcode"
},
"eq": {
"v": 3,
"d": "Base fee of the EQ opcode"
},
"iszero": {
"v": 3,
"d": "Base fee of the ISZERO opcode"
},
"and": {
"v": 3,
"d": "Base fee of the AND opcode"
},
"or": {
"v": 3,
"d": "Base fee of the OR opcode"
},
"xor": {
"v": 3,
"d": "Base fee of the XOR opcode"
},
"not": {
"v": 3,
"d": "Base fee of the NOT opcode"
},
"byte": {
"v": 3,
"d": "Base fee of the BYTE opcode"
},
"address": {
"v": 2,
"d": "Base fee of the ADDRESS opcode"
},
"balance": {
"v": 20,
"d": "Base fee of the BALANCE opcode"
},
"origin": {
"v": 2,
"d": "Base fee of the ORIGIN opcode"
},
"caller": {
"v": 2,
"d": "Base fee of the CALLER opcode"
},
"callvalue": {
"v": 2,
"d": "Base fee of the CALLVALUE opcode"
},
"calldataload": {
"v": 3,
"d": "Base fee of the CALLDATALOAD opcode"
},
"calldatasize": {
"v": 2,
"d": "Base fee of the CALLDATASIZE opcode"
},
"calldatacopy": {
"v": 3,
"d": "Base fee of the CALLDATACOPY opcode"
},
"codesize": {
"v": 2,
"d": "Base fee of the CODESIZE opcode"
},
"codecopy": {
"v": 3,
"d": "Base fee of the CODECOPY opcode"
},
"gasprice": {
"v": 2,
"d": "Base fee of the GASPRICE opcode"
},
"extcodesize": {
"v": 20,
"d": "Base fee of the EXTCODESIZE opcode"
},
"extcodecopy": {
"v": 20,
"d": "Base fee of the EXTCODECOPY opcode"
},
"blockhash": {
"v": 20,
"d": "Base fee of the BLOCKHASH opcode"
},
"coinbase": {
"v": 2,
"d": "Base fee of the COINBASE opcode"
},
"timestamp": {
"v": 2,
"d": "Base fee of the TIMESTAMP opcode"
},
"number": {
"v": 2,
"d": "Base fee of the NUMBER opcode"
},
"difficulty": {
"v": 2,
"d": "Base fee of the DIFFICULTY opcode"
},
"gaslimit": {
"v": 2,
"d": "Base fee of the GASLIMIT opcode"
},
"pop": {
"v": 2,
"d": "Base fee of the POP opcode"
},
"mload": {
"v": 3,
"d": "Base fee of the MLOAD opcode"
},
"mstore": {
"v": 3,
"d": "Base fee of the MSTORE opcode"
},
"mstore8": {
"v": 3,
"d": "Base fee of the MSTORE8 opcode"
},
"sstore": {
"v": 0,
"d": "Base fee of the SSTORE opcode"
},
"jump": {
"v": 8,
"d": "Base fee of the JUMP opcode"
},
"jumpi": {
"v": 10,
"d": "Base fee of the JUMPI opcode"
},
"pc": {
"v": 2,
"d": "Base fee of the PC opcode"
},
"msize": {
"v": 2,
"d": "Base fee of the MSIZE opcode"
},
"gas": {
"v": 2,
"d": "Base fee of the GAS opcode"
},
"push": {
"v": 3,
"d": "Base fee of the PUSH opcode"
},
"dup": {
"v": 3,
"d": "Base fee of the DUP opcode"
},
"swap": {
"v": 3,
"d": "Base fee of the SWAP opcode"
},
"callcode": {
"v": 40,
"d": "Base fee of the CALLCODE opcode"
},
"return": {
"v": 0,
"d": "Base fee of the RETURN opcode"
},
"invalid": {
"v": 0,
"d": "Base fee of the INVALID opcode"
},
"selfdestruct": {
"v": 0,
"d": "Base fee of the SELFDESTRUCT opcode"
}
},
"vm": {
Expand Down Expand Up @@ -206,4 +438,4 @@
"d": "the amount a miner get rewarded for mining a block"
}
}
}
}
20 changes: 20 additions & 0 deletions packages/common/src/hardforks/constantinople.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
"netSstoreResetClearRefund": {
"v": 19800,
"d": "Once per SSTORE operation for resetting to the original zero value"
},
"shl": {
"v": 3,
"d": "Base fee of the SHL opcode"
},
"shr": {
"v": 3,
"d": "Base fee of the SHR opcode"
},
"sar": {
"v": 3,
"d": "Base fee of the SAR opcode"
},
"extcodehash": {
"v": 400,
"d": "Base fee of the EXTCODEHASH opcode"
},
"create2": {
"v": 32000,
"d": "Base fee of the CREATE2 opcode"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Constantinople looks ok, was a bit confused (again, this will likely never end 😋 ) on the Constantinople/Petersburg relation and how this translates to here but this look ok from this angle as well (since it's Constantinople introducing all those opcodes), Petersburg is just reverting changes to SSTORE gas calculation.

}
},
"vm": {},
Expand Down
Loading