diff --git a/hookstests/hookset/test-aaw.js b/hookstests/hookset/test-aaw.js index 5727b1c54..d55d98467 100644 --- a/hookstests/hookset/test-aaw.js +++ b/hookstests/hookset/test-aaw.js @@ -6,7 +6,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> { t.fundFromGenesis(account2).then(()=> { - t.api.submit( + t.feeSubmit(account1.seed, { Account: account1.classicAddress, TransactionType: "SetHook", @@ -19,9 +19,8 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: t.wasmFee('aaw.wasm') - }, {wallet: account1}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) console.log(x); diff --git a/hookstests/hookset/test-create.js b/hookstests/hookset/test-create.js index a3e92e038..592142c7a 100644 --- a/hookstests/hookset/test-create.js +++ b/hookstests/hookset/test-create.js @@ -3,7 +3,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> const account = t.randomAccount(); t.fundFromGenesis(account).then(()=> { - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -16,13 +16,12 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: t.wasmFee('accept.wasm') - }, {wallet: account}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) console.log(x); - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -35,9 +34,8 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: t.wasmFee('accept.wasm') - }, {wallet: account}).then(x=> + ] + }).then(x=> { t.assertTxnFailure(x) process.exit(0); diff --git a/hookstests/hookset/test-delete.js b/hookstests/hookset/test-delete.js index 3d82ecab4..b5930955e 100644 --- a/hookstests/hookset/test-delete.js +++ b/hookstests/hookset/test-delete.js @@ -5,7 +5,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> t.fundFromGenesis(account).then(()=> { - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -15,7 +15,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> { t.assertTxnSuccess(x) console.log(x) - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -29,13 +29,12 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: t.wasmFee('accept.wasm') - }, {wallet: account}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) console.log(x); - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -47,8 +46,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> } } ], - Fee: "100000" - }, {wallet: account}).then(x=> + }).then(x=> { t.assertTxnSuccess(x) console.log(x); diff --git a/hookstests/hookset/test-fee-1.js b/hookstests/hookset/test-fee-1.js deleted file mode 100644 index d963ee50b..000000000 --- a/hookstests/hookset/test-fee-1.js +++ /dev/null @@ -1,59 +0,0 @@ -require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> -{ - const account = t.randomAccount(); - t.fundFromGenesis(account).then(()=> - { - t.api.submit( - { - Account: account.classicAddress, - TransactionType: "SetHook", - Hooks: [ - { - Hook: { - CreateCode: t.wasm('accept.wasm'), - HookApiVersion: 0, - HookNamespace: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF", - HookOn: "0000000000000000" - } - } - ], - Fee: t.wasmFee('accept.wasm') - }, {wallet: account}).then(x=> - { - t.assertTxnSuccess(x) - console.log(x); - t.pay_mock(t.genesisseed, 100, account).then(ser=> - { - t.fee(ser).then(fees => - { - let base_drops = fees.base_fee - console.log("base_drops", base_drops) - - let txn = t.rbc.decode(ser); - delete txn['SigningPubKey'] - delete txn['Fee'] - txn['Fee'] = base_drops + ''; - - console.log(txn) - t.api.submit(txn, {wallet: account}).then(s=> - { - t.assertTxnSuccess(s); - console.log(s); - txn['Fee'] = (base_drops - 20) + ''; - txn['Sequence'] = (txn['Sequence'] + 1) ; - console.log(txn) - t.api.submit(txn, {wallet: t.genesis}).then(s=> - { - t.assertTxnFailure(s); - console.log(s) - process.exit(0); - }); - }).catch(t.err); - }); - }); - }).catch(t.err); - }).catch(t.err); -}) - - - diff --git a/hookstests/hookset/test-fee-3.js b/hookstests/hookset/test-fee-3.js deleted file mode 100644 index 2e6ae30d3..000000000 --- a/hookstests/hookset/test-fee-3.js +++ /dev/null @@ -1,31 +0,0 @@ -require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> -{ - const account = t.randomAccount(); - t.fundFromGenesis(account).then(()=> - { - t.feeTxn(account.seed, - { - Account: account.classicAddress, - TransactionType: "SetHook", - Hooks: [ - { - Hook: { - CreateCode: t.wasm('accept.wasm'), - HookApiVersion: 0, - HookNamespace: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF", - HookOn: "0000000000000000" - } - } - ] - }).then(txn => { - console.log(txn) - t.api.submit(txn, {wallet: account}).then(s=> - { - t.assertTxnSuccess(s); - console.log(s); - process.exit(0); - }).catch(t.err); - }).catch(t.err); - }).catch(t.err); -}); - diff --git a/hookstests/hookset/test-install.js b/hookstests/hookset/test-install.js index 17c41b131..bc5d61d98 100644 --- a/hookstests/hookset/test-install.js +++ b/hookstests/hookset/test-install.js @@ -8,7 +8,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> { let hash = t.hookHash('checkstate.wasm') - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -20,13 +20,12 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: "100000" - }, {wallet: account}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) console.log(x) - t.api.submit( + t.feeSubmit(account2.seed, { Account: account2.classicAddress, TransactionType: "SetHook", @@ -42,15 +41,14 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookHash: hash }} ] - }, {wallet: account2}).then(x=> + }).then(x=> { t.assertTxnSuccess(x) console.log(x); - t.api.submit( + t.feeSubmit(account2.seed, { Account: account2.classicAddress, TransactionType: "SetHook", - Fee: "100000", Flags: 0, Hooks: [ { Hook: { @@ -58,16 +56,15 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> "CreateCode": "", }} ] - }, {wallet: account2}).then(x=> + }).then(x=> { console.log(x); t.assertTxnSuccess(x); - t.api.submit( + t.feeSubmit(account2.seed, { Account: account2.classicAddress, TransactionType: "SetHook", - Fee: "100000", Flags: 0, Hooks: [ {Hook:{}}, @@ -82,7 +79,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> ] }} ] - }, {wallet: account2}).then(x=> + }).then(x=> { console.log(x); t.assertTxnSuccess(x); diff --git a/hookstests/hookset/test-noop.js b/hookstests/hookset/test-noop.js index 9072687b9..5b8d83c89 100644 --- a/hookstests/hookset/test-noop.js +++ b/hookstests/hookset/test-noop.js @@ -3,7 +3,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> const account = t.randomAccount(); t.fundFromGenesis(account).then(()=> { - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -16,13 +16,12 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: "100000" - }, {wallet: account}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) console.log(x); - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -31,9 +30,8 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> { Hook: { } }, { Hook: { } }, { Hook: { } } - ], - Fee: "100000" - }, {wallet: account}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) console.log(x); diff --git a/hookstests/hookset/test-nsdelete-empty.js b/hookstests/hookset/test-nsdelete-empty.js index dedf56692..7880ee924 100644 --- a/hookstests/hookset/test-nsdelete-empty.js +++ b/hookstests/hookset/test-nsdelete-empty.js @@ -3,7 +3,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> const account = t.randomAccount(); t.fundFromGenesis(account).then(()=> { - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -27,16 +27,15 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> } ], Fee: "100000" - }, {wallet: account}).then(x=> + }).then(x=> { t.assertTxnSuccess(x) console.log(x); - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", - Fee: "100000", Hooks: [ { Hook: { @@ -45,7 +44,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> } } ] - }, {wallet: account}).then(x=> + }).then(x=> { t.assertTxnSuccess(x) console.log(x); diff --git a/hookstests/hookset/test-nsdelete.js b/hookstests/hookset/test-nsdelete.js index c8a3e93f7..935399dd7 100644 --- a/hookstests/hookset/test-nsdelete.js +++ b/hookstests/hookset/test-nsdelete.js @@ -3,7 +3,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> const account = t.randomAccount(); t.fundFromGenesis(account).then(()=> { - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -25,9 +25,8 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: "100000" - }, {wallet: account}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) t.api.submit( @@ -40,11 +39,10 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> t.assertTxnSuccess(x) console.log(x); - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", - Fee: "100000", Hooks: [ { Hook: { @@ -53,7 +51,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> } } ] - }, {wallet: account}).then(x=> + }).then(x=> { t.assertTxnSuccess(x) console.log(x); diff --git a/hookstests/hookset/test-state.js b/hookstests/hookset/test-state.js index 3e28cea02..62daffe0f 100644 --- a/hookstests/hookset/test-state.js +++ b/hookstests/hookset/test-state.js @@ -3,7 +3,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> const account = t.randomAccount(); t.fundFromGenesis(account).then(()=> { - t.api.submit( + t.feeSubmit(account.seed, { Account: account.classicAddress, TransactionType: "SetHook", @@ -32,9 +32,8 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: "100000" - }, {wallet: account}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) t.api.submit( diff --git a/hookstests/hookset/test-tsh-2.js b/hookstests/hookset/test-tsh-2.js index e8858b2b9..00602291b 100644 --- a/hookstests/hookset/test-tsh-2.js +++ b/hookstests/hookset/test-tsh-2.js @@ -6,7 +6,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> { t.fundFromGenesis(account2).then(()=> { - t.api.submit( + t.feeSubmit(account1.seed, { Account: account1.classicAddress, TransactionType: "SetHook", @@ -19,13 +19,12 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> HookOn: "0000000000000000" } } - ], - Fee: "100000" - }, {wallet: account1}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) console.log(x); - t.api.submit( + t.feeSubmit(account2.seed, { Account: account2.classicAddress, TransactionType: "SignerListSet", @@ -39,9 +38,8 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> SignerWeight: 1 } } - ], - Fee: "100000" - }, {wallet: account2}).then(x=> + ] + }).then(x=> { t.assertTxnFailure(x) process.exit(0); diff --git a/hookstests/hookset/test-tsh.js b/hookstests/hookset/test-tsh.js index 7d4943213..ed54295a7 100644 --- a/hookstests/hookset/test-tsh.js +++ b/hookstests/hookset/test-tsh.js @@ -6,7 +6,7 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> { t.fundFromGenesis(account2).then(()=> { - t.api.submit( + t.feeSubmit(account1.seed, { Account: account1.classicAddress, TransactionType: "SetHook", @@ -20,12 +20,11 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> } } ], - Fee: "100000" - }, {wallet: account1}).then(x=> + }).then(x=> { t.assertTxnSuccess(x) console.log(x); - t.api.submit( + t.feeSubmit(account2.seed, { Account: account2.classicAddress, TransactionType: "SignerListSet", @@ -39,9 +38,8 @@ require('./utils-tests.js').TestRig('ws://localhost:6005').then(t=> SignerWeight: 1 } } - ], - Fee: "100000" - }, {wallet: account2}).then(x=> + ] + }).then(x=> { t.assertTxnSuccess(x) process.exit(0); diff --git a/hookstests/hookset/utils-tests.js b/hookstests/hookset/utils-tests.js index e26e73d23..2961f8686 100644 --- a/hookstests/hookset/utils-tests.js +++ b/hookstests/hookset/utils-tests.js @@ -63,13 +63,6 @@ module.exports = { }; - const wasmFee = (x) => - { - if (x.slice(0,1) != '/') - x = 'wasm/' + x; - return "" + (fs.readFileSync( x).length * 500) + 20; - } - const feeCompute = (account_seed, txn_org) => { return new Promise((resolve, reject) => @@ -226,7 +219,6 @@ module.exports = { fee: fee, genesisseed: genesisseed, genesisaddr: genesisaddr, - wasmFee: wasmFee, feeCompute: feeCompute, feeSubmit: feeSubmit }); diff --git a/hookstests/hookset/wasm/rollback.c b/hookstests/hookset/wasm/rollback.c index ed29746f6..b250233be 100644 --- a/hookstests/hookset/wasm/rollback.c +++ b/hookstests/hookset/wasm/rollback.c @@ -5,13 +5,6 @@ extern int32_t _g (uint32_t id, uint32_t maxiter); extern int64_t rollback (uint32_t read_ptr, uint32_t read_len, int64_t error_code); -extern int64_t accept (uint32_t read_ptr, uint32_t read_len, int64_t error_code); - -int64_t cbak(uint32_t reserved) -{ - accept(0,0,0); - return 0; -} int64_t hook(uint32_t reserved ) { diff --git a/src/ripple/app/tx/impl/SetHook.cpp b/src/ripple/app/tx/impl/SetHook.cpp index 777246cd0..a4f7aa837 100644 --- a/src/ripple/app/tx/impl/SetHook.cpp +++ b/src/ripple/app/tx/impl/SetHook.cpp @@ -486,6 +486,22 @@ SetHook::calculateBaseFee(ReadView const& view, STTx const& tx) extraFee += FeeUnit64{ hook::computeCreationFee( hookSetObj->getFieldVL(sfCreateCode).size())}; + + // parameters are billed at the same rate as code bytes + if (hookSetObj->isFieldPresent(sfHookParameters)) + { + uint64_t paramBytes = 0; + auto const& params = hookSetObj->getFieldArray(sfHookParameters); + for (auto const& param : params) + { + paramBytes += + (param.isFieldPresent(sfHookParameterName) ? + param.getFieldVL(sfHookParameterName).size() : 0) + + (param.isFieldPresent(sfHookParameterValue) ? + param.getFieldVL(sfHookParameterValue).size() : 0); + } + extraFee += FeeUnit64 { paramBytes }; + } } return Transactor::calculateBaseFee(view, tx) + extraFee; @@ -1405,8 +1421,8 @@ SetHook::setHook() // sfHookDefinition is not reserved because it is an unowned object, rather the uploader is billed via fee // according to the following: - // sfCreateCode: 1000 drops per byte - // sfHookParameters: 1000 drops per byte + // sfCreateCode: 5000 drops per byte + // sfHookParameters: 5000 drops per byte // other fields: free int oldHookReserve = 0;