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

Minting NFT on Besu Permissioned network with docker container has some issues. #8149

Open
TU0N0DAN opened this issue Jan 21, 2025 · 0 comments

Comments

@TU0N0DAN
Copy link

TU0N0DAN commented Jan 21, 2025

My goal is to mint NFT on a Permissioned Besu network realized using docker containers.

My issues are (hierarchically):

1. Can't deploy ERC-721 from Validator Private Key nor Minting ETH to accounts.

Details:
Insufficient funds (Validator has no ETH balance) and unable to fund validator via transaction from funded account.
Shall try funding it in genesis.json (alloc section), but Validator should be able to send tokens even if it doesn't have any.
Theorically it should be able to mint ETH instantly and sending it everywhere.
If i try to send money from Validator to account transaction is failed (insufficient funds).
If i try to send money from funded account to validator, transaction stucks in pending state forever.
I wanted to fund accounts making transaction from validators instead of funding them in the alloc section of genesis.json

"Solved by deploying the contract from funded account, but i wanted to find a better way around, more logically correct (validator should fund accounts and deploy contracts in a PoA network, instead of a genesis funded account doing it)"

2. Intrinsic Gas exceeds Gas Limit

Even if i set Gas Limit = 21000 and Gas Price = 1, the EVM still says Gas price > Gas Limit and reverts the transaction.
This makes no sense in my opinion.

"Solved by raising Gas Limit to 5 millions, and getting gas price via Eth Estimate Gas method.
Estimated gas is always a super big number, and i think there are problems withing the method.
Where does it get the esteem?"

In reality i wanted to implement GASLESS transactions, so i'd rather have gas to zero in the best option, but i don't know if this is possible and how. In the meanwhile i'm just playing with gas limit numbers.

Momentarily solved by changing the code from this:

const rawTxOptions = {
      nonce: web3.utils.numberToHex(txnCount),
      from: account.address,
      to: null,
      value: "0x00",
      data: '0x' + contractBin.toString('hex') + contractConstructorInit,
      gasPrice: "0x22",  // LOW GAS PRICE
      gas: "0x5208", // CUSTOM GAS LIMIT EQUAL TO GENESIS LIMIT
    };

To this: (gas limit is obviously modded in genesis.json also, to 5 millions)

const gasPrice = await web3.eth.getGasPrice();
const gasEstimate = await web3.eth.estimateGas({
      from: account.address,
      data: '0x' + contractBin.toString('hex') + contractConstructorInit  });

const rawTxOptions = {
      nonce: web3.utils.numberToHex(txnCount),
      from: account.address,
      to: null,
      value: "0x00",
      data: '0x' + contractBin.toString('hex') + contractConstructorInit,
      gasPrice: web3.utils.toHex(gasPrice),
      gas: web3.utils.toHex(gasEstimate)
   };

3. "Undefined Error", turned out to be Wrong EVM Version. Thanks to @Giridharan-Govindaraj suggestion.

"Solved by setting "Petersburg" hardfork as parameter when creating Tx object. Strange because my genesis.json only has Berlinblock milestone. As Besu documentation says to create. Also the contracts i'm deploying are compiled without specifying any EVM Version nor berlin or petersburg. I'm using latest besu version"

const tx = new Tx(rawTxOptions, { hardfork: 'petersburg' });

4. Wrong chain Id when deploying ERC-721 Contract. Chain ID is set to 0x1 by default. (NOT SOLVED)

How to set a custom Chain Id to tx options? I tried like this but it seems it doesn't work. Maybe the syntax is wrong.

const rawTxOptions = {
      nonce: web3.utils.numberToHex(txnCount),
      from: account.address,
      to: null,
      value: "0x00",
      data: '0x' + contractBin.toString('hex') + contractConstructorInit,
      gasPrice: web3.utils.toHex(gasPrice),
      gas: web3.utils.toHex(gasEstimate),
      chainId: "1337"
    };

I instead fixed it just by setting chain Id to 0x1 in genesis file, instead of 1337 chain id like besu docs say to, but i know this logic is wrong, since the transaction should be launched using custom 1337 chain id, but i'm not able to customize it so i will just set the chain Id to 1 so it matches to the default Tx chain id value

Should i instead do this?

const tx = new Tx(rawTxOptions, { chain: '1337', hardfork: 'petersburg' });

or this? Maybe changing 1337 to hex?

const tx = new Tx(rawTxOptions, { chainId: '1337', hardfork: 'petersburg' });

5. I have some doubts regarding Private and Permissioned network. My network seems to be Permissioned since i added permissions_config.toml file with node and account allowlists, but it seems isn't private as well since EEA/PRIV RPC API Methods are not available. Is privacy necessary for my goal? Could it improve things or just generate more errors?

These are the containerized node logs when starting up:

Node-1-1  | 2025-01-21 13:17:10.047+00:00 | main | WARN | Besu | Forcing price bump for transaction replacement to 0, since min-gas-price is set to 0
Node-1-1  | 2025-01-21 13:17:11.064+00:00 | main | WARN  | Besu | Forcing tx-pool-min-gas-price=0, since it cannot be greater than the value of min-gas-price
Node-1-1  | 2025-01-21 13:17:11.068+00:00 | main | INFO  | KeyPairUtil | Attempting to load public key from /data/key
Node-1-1  | 2025-01-21 13:17:11.114+00:00 | main | INFO  | KeyPairUtil | Loaded public key from /data/key
Node-1-1  | 2025-01-21 13:17:11.123+00:00 | main | WARN  | Besu | Privacy is disabled. Cannot use EEA/PRIV API methods when not using Privacy.

"Also, could this min-gas-price forcing be a cause of issues in the point 2?"

Thanks in advance to everyone willing to help me solving these issues!

I'm not a blockchain expert, i'm just a kid playing with it and tryina growing his skills. I'll be very grateful to everyone that's going to help me since i've been working on this private blockchain for minting NFT for months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant