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

EIP 1559 Debug #2 #4171

Merged
merged 18 commits into from
Jul 19, 2021
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
20 changes: 15 additions & 5 deletions packages/web3-eth-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,24 @@ function _validateTransactionForSigning(tx) {
);
}

if (!tx.gas && !tx.gasLimit) {
if (
(!tx.gas && !tx.gasLimit) &&
(!tx.maxPriorityFeePerGas && !tx.maxFeePerGas)
) {
return new Error('"gas" is missing');
}

if (tx.nonce < 0 ||
tx.gas < 0 ||
tx.gasPrice < 0 ||
tx.chainId < 0) {
if (tx.gas && tx.gasPrice) {
if (tx.gas < 0 || tx.gasPrice < 0) {
return new Error('Gas, gasPrice, nonce or chainId is lower than 0');
}
} else {
if (tx.maxPriorityFeePerGas < 0 || tx.maxFeePerGas < 0) {
return new Error('maxPriorityFeePerGas or maxFeePerGas is lower than 0');
}
}

if (tx.nonce < 0 || tx.chainId < 0) {
return new Error('Gas, gasPrice, nonce or chainId is lower than 0');
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/e2e.geth.automine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ echo " "
# Launch client w/ two unlocked accounts.
# + accounts[0] default geth unlocked bal = ~infinity
# + accounts[1] unlocked, signing password = 'left-hand-of-darkness'
geth-dev-assistant --period 2 --accounts 1 --tag 'v1.10.3'
geth-dev-assistant --period 2 --accounts 1 --tag 'stable'

# Test
GETH_AUTOMINE=true nyc --no-clean --silent _mocha -- \
Expand Down
2 changes: 1 addition & 1 deletion scripts/js/ens.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function setupENS(web3) {

const options = {
bytecode: undefined,
gasPrice: '1',
gasPrice: 1000000000, // Default gasPrice set by Geth
gas: 5500000
}

Expand Down
6 changes: 3 additions & 3 deletions test/e2e.contract.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ describe('contract.deploy [ @E2E ]', function() {

var basicOptions = {
data: Basic.bytecode,
gasPrice: '1',
gasPrice: 1000000000, // Default gasPrice set by Geth
gas: 4000000
};

var revertsOptions = {
data: Reverts.bytecode,
gasPrice: '1',
gasPrice: 1000000000, // Default gasPrice set by Geth
gas: 4000000
}

var noBytecodeOptions = {
data: '0x',
gasPrice: '1',
gasPrice: 1000000000, // Default gasPrice set by Geth
gas: 4000000
}

Expand Down
6 changes: 3 additions & 3 deletions test/e2e.contract.events.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('contract.events [ @E2E ]', function() {

var basicOptions = {
data: Basic.bytecode,
gasPrice: '1',
gasPrice: 1000000000,// Default gasPrice set by Geth
gas: 4000000
};

Expand Down Expand Up @@ -289,7 +289,7 @@ describe('contract.events [ @E2E ]', function() {
let contract;

const options = {
gasPrice: '1',
gasPrice: 1000000000,// Default gasPrice set by Geth
gas: 4000000
};

Expand Down Expand Up @@ -336,7 +336,7 @@ describe('contract.events [ @E2E ]', function() {
// and geth instamine's websockets connection is too fragile for the tests in this file.
it('backfills missed events when auto-reconnecting', function(){
if(!process.env.GANACHE) return;
this.timeout(10000);
this.timeout(20000);

let counter = 0;
const acc = accounts[0];
Expand Down
2 changes: 1 addition & 1 deletion test/e2e.ens.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('ENS [ @E2E ]', function () {
options = {
from: account,
gas: 4000000,
gasPrice: 1
gasPrice: 1000000000 // Default gasPrice set by Geth
}
});

Expand Down
4 changes: 2 additions & 2 deletions test/e2e.method.call.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ describe('method.call [ @E2E ]', function () {

var basicOptions = {
data: Basic.bytecode,
gasPrice: '1',
gasPrice: 1000000000, // Default gasPrice set by Geth
gas: 4000000
};

var miscOptions = {
data: Misc.bytecode,
gasPrice: '1',
gasPrice: 1000000000, // Default gasPrice set by Geth
gas: 4000000
};

Expand Down
27 changes: 18 additions & 9 deletions test/e2e.method.send.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,40 @@ describe('method.send [ @E2E ]', function () {

var basicOptions = {
data: Basic.bytecode,
gasPrice: '1',
gasPrice: 1000000000, // Default gasPrice set by Geth
gas: 4000000
};

describe('http', function () {
before(async function () {
web3 = new Web3('http://localhost:8545');
accounts = await web3.eth.getAccounts();

accounts = await web3.eth.getAccounts();
basic = new web3.eth.Contract(Basic.abi, basicOptions);
instance = await basic.deploy().send({from: accounts[0]});

var nonceVal = await web3.eth.getTransactionCount(accounts[0]);

instance = await basic.deploy().send({from: accounts[0], nonce: nonceVal});
});

it('returns a receipt', async function () {
var nonceVal = await web3.eth.getTransactionCount(accounts[0]);
var receipt = await instance
.methods
.setValue('1')
.send({from: accounts[0]});
.send({from: accounts[0], nonceVal});

assert(receipt.status === true);
assert(web3.utils.isHexStrict(receipt.transactionHash));
});

it('errors on OOG', async function () {
try {
var nonceVal = await web3.eth.getTransactionCount(accounts[0]);
await instance
.methods
.setValue('1')
.send({from: accounts[0], gas: 100});
.send({from: accounts[0], gas: 100, nonce: nonceVal});

assert.fail();

Expand Down Expand Up @@ -114,27 +119,31 @@ describe('method.send [ @E2E ]', function () {

web3 = new Web3('ws://localhost:' + port);
accounts = await web3.eth.getAccounts();

basic = new web3.eth.Contract(Basic.abi, basicOptions);
instance = await basic.deploy().send({from: accounts[0]});

var nonceVal = await web3.eth.getTransactionCount(accounts[0]);
instance = await basic.deploy().send({from: accounts[0], nonce: nonceVal });
})

it('returns a receipt', async function () {
var nonceVal = await web3.eth.getTransactionCount(accounts[0]);
var receipt = await instance
.methods
.setValue('1')
.send({from: accounts[0]});
.send({from: accounts[0], nonce: nonceVal});

assert(receipt.status === true);
assert(web3.utils.isHexStrict(receipt.transactionHash));
});

it('errors on OOG', async function () {
try {
var nonceVal = await web3.eth.getTransactionCount(accounts[0]);
await instance
.methods
.setValue('1')
.send({from: accounts[0], gas: 100});
.send({from: accounts[0], gas: 100, nonce: nonceVal});

assert.fail();

Expand Down
Loading