File tree Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 11const utils = require ( 'ethereumjs-util' )
22const BN = utils . BN
33const error = require ( '../constants.js' ) . ERROR
4+ const fees = require ( 'ethereum-common' )
45
5- const Gquaddivisor = 20
6+ const Gquaddivisor = fees . modexpGquaddivisor . v
67
78function multComplexity ( x ) {
89 if ( x <= 64 ) {
Original file line number Diff line number Diff line change 11const utils = require ( 'ethereumjs-util' )
22const BN = utils . BN
33const error = require ( '../constants.js' ) . ERROR
4+ const fees = require ( 'ethereum-common' )
45
56const bn128_module = require ( 'rustbn.js' )
67const ecAdd_precompile = bn128_module . cwrap ( 'ec_add' , 'string' , [ 'string' ] )
@@ -10,8 +11,7 @@ module.exports = function (opts) {
1011 let data = opts . data
1112 let inputHexStr = data . toString ( 'hex' )
1213
13- // Temporary, replace with finalized gas cost from EIP spec (via ethereum-common)
14- results . gasUsed = new BN ( 500 )
14+ results . gasUsed = new BN ( fees . ecAddGas . v )
1515 try {
1616 let returnData = ecAdd_precompile ( inputHexStr )
1717 results . return = Buffer . from ( returnData , 'hex' )
Original file line number Diff line number Diff line change 11const utils = require ( 'ethereumjs-util' )
22const BN = utils . BN
3+ const fees = require ( 'ethereum-common' )
34
45const bn128_module = require ( 'rustbn.js' )
56const ecMul_precompile = bn128_module . cwrap ( 'ec_mul' , 'string' , [ 'string' ] )
@@ -21,7 +22,6 @@ module.exports = function (opts) {
2122 results . exception = 0
2223 }
2324
24- // Temporary, replace with finalized gas cost from EIP spec (via ethereum-common)
25- results . gasUsed = new BN ( 40000 )
25+ results . gasUsed = new BN ( fees . ecMulGas . v )
2626 return results
2727}
Original file line number Diff line number Diff line change 11const utils = require ( 'ethereumjs-util' )
22const BN = utils . BN
33const error = require ( '../constants.js' ) . ERROR
4+ const fees = require ( 'ethereum-common' )
45
56const bn128_module = require ( 'rustbn.js' )
67const ecPairing_precompile = bn128_module . cwrap ( 'ec_pairing' , 'string' , [ 'string' ] )
@@ -13,8 +14,8 @@ module.exports = function (opts) {
1314 let inputData = Buffer . from ( inputHexStr , 'hex' )
1415 let inputDataSize = Math . floor ( inputData . length / 192 )
1516
16- // Temporary, replace with finalized gas cost from EIP spec (via ethereum-common)
17- const gascost = 100000 + ( inputDataSize * 80000 )
17+
18+ const gascost = fees . ecPairingGas . v + ( inputDataSize * fees . ecPairingWordGas . v )
1819 results . gasUsed = new BN ( gascost )
1920
2021 if ( opts . gasLimit . ltn ( gascost ) ) {
You can’t perform that action at this time.
0 commit comments