Giter VIP home page Giter VIP logo

fortuna's Introduction

Fortuna

Bitcoin style proof of work in smart contract form

Licence Tests


Explorer

Thanks to @QCPOLstakepool we have an explorer.

Check it out here.

Mining $TUNA

The current miner is naive and a better implementation is coming soon.

Requirements

You can easily get access to Kupo and Ogmios with Demeter. Once you have a project in Demeter you can connect Ogmios and Kupo extensions for mainnet. Make sure to toggle Expose http port in each extensions' settings.

Environment variables

Once you have URLs for Kupo and Ogmios, create a .env file in the root of the project with the following content:

KUPO_URL="https://<Kupo URL>"
OGMIOS_URL="wss://<Ogmios URL>"

Wallet

You'll need to create a wallet for the miner which can be done with the following command:

deno task cli init

Then run the following command to get the miner address:

deno task cli address

You'll need to fund this address with some $ADA to pay for transaction fees.

Running

After everything is setup, you can run the miner with the following command:

deno task cli mine

Policy

The policy for the TUNA token is 279f842c33eed9054b9e3c70cd6a3b32298259c24b78b895cb41d91a

fortuna's People

Contributors

cfcosta avatar mgpai22 avatar microproofs avatar mitchturner avatar pehcastro avatar rvcas avatar yhsj avatar zachyking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fortuna's Issues

Missing input or output for some native asset

Found next datum: d8799f190c8b5820000003dd5988c71f9d9126583fdc799c61fa4738753540ff032bbb4aa18d7e6205193fff1a02d3ccf81b0000018a3d7f00804d416c4c204861496c2074556e419f582000000195372fc5d1ac30b2a68a56f754bea8c1e5eeb2092fecb7e42992e2acfd5820000000feedd58e87ee12e224efd631536c3d57aadbb18ec62f44180366a3def858200000005943d4dcb4755ae88d22f32220675f1a272078380bb8cb4c94902e2d1258200000001571546b479ba412dc37f5126ca465f29bdce01514e4b41ed9d3cd1a8558200000001571546b479ba412dc37f5126ca465f29bdce01514e4b41ed9d3cd1a85582000000000b91969a15f0116e0026b2169f5d9859146ca56741af39bb810ac933a582000000000b91969a15f0116e0026b2169f5d9859146ca56741af39bb810ac933a582000000000b91969a15f0116e0026b2169f5d9859146ca56741af39bb810ac933a582000000000b91969a15f0116e0026b2169f5d9859146ca56741af39bb810ac933a582000000000b91969a15f0116e0026b2169f5d9859146ca56741af39bb810ac933affff
Missing input or output for some native asset

Error when trying to mine

Getting this error when attempting to mine, I have all the requirements, built a wallet, can see the address, even funded the wallet, which I can see on chain but deno task cli address shows a 0 balance for the same wallet. Running on linux.

When I try to mine (deno task cli mine) I get:

Task cli deno run --allow-all miner/main.ts "mine"
error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'datum')
const validatorState = validatorOutRef.datum!;
^
at Command.actionHandler (file:///home/bk/Miners/fortuna/miner/main.ts:62:44)
at eventLoopTick (ext:core/01_core.js:183:11)
at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
at async file:///home/bk/Miners/fortuna/miner/main.ts:339:1

uncaught error: utxos.map is not a function

Heya, getting the following error. It worked for a while, then started throwing these.
Also curious: I managed to mint one block successfully back in the beginning, but everything since has been failures to win seeking the block, like dozens. Is that normal? No idea :)

Anyway, the error:

~/.git/fortuna$ deno task cli mine
Task cli deno run --allow-all miner/main.ts "mine"
error: Uncaught (in promise) TypeError: utxos.map is not a function
return Promise.all((utxos as any).map(async (utxo: any) => {
^
at Kupmios.kupmiosUtxosToUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:224:39)
at Kupmios.getUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:92:17)
at eventLoopTick (ext:core/01_core.js:183:11)
at async Command.actionHandler (file:///home/mei/.git/fortuna/miner/main.ts:61:28)
at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
at async file:///home/mei/.git/fortuna/miner/main.ts:401:1

I tried restarting the instance but to no avail.

utxos.map is not a function

Get this error fairly regular like.

error: Uncaught (in promise) TypeError: utxos.map is not a function
return Promise.all((utxos as any).map(async (utxo: any) => {
^
at Kupmios.kupmiosUtxosToUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:224:39)
at Kupmios.getUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:92:17)
at eventLoopTick (ext:core/01_core.js:183:11)
at async Command.actionHandler (file:///home/curly-knox/fortuna/miner/main.ts:107:28)
at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
at async file:///home/curly-knox/fortuna/miner/main.ts:413:1

No datum found for datum hash

Getting error sporadically:

error: Uncaught (in promise) Error: No datum found for datum hash: 5cd10c5dcb34917f94366aa526b46e535f4693d4ac9528ffd50c5d93e46d6d7b
throw new Error(No datum found for datum hash: ${datumHash});
^
at Kupmios.getDatum (https://deno.land/x/[email protected]/src/provider/kupmios.ts:182:13)
at eventLoopTick (ext:core/01_core.js:183:11)
at async https://deno.land/x/[email protected]/src/provider/kupmios.ts:238:13
at async Promise.all (index 0)
at async Command.actionHandler (file:///C:/Users/xx/Downloads/fortuna-main/fortuna-main/miner/main.ts:121:28)
at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
at async file:///C:/Users/xx/Downloads/fortuna-main/fortuna-main/miner/main.ts:417:1

Then the app crashes and the mining stops having to restart the miner

Error when running deno task cli address

System: Ubuntu 22.04 LTS virtual machine
Running a fully synced cardano-node. Kupo and ogmios running as a service locally.

deno task cli init - worked and created seed.txt

deno task cli address - yields this error:

Task cli deno run --allow-all miner/main.ts "address" error: Top-level await promise never resolved await new Command() ^ at <anonymous> (file://fortuna/miner/main.ts:401:1)

The .env file in fortuna root directory is configured as such (default values for kupo and ogmios):
KUPO_URL="wss://127.0.0.1" OGMIOS_URL="wss://127.0.0.1"

Continuously getting the same error.

Task cli deno run --allow-all miner/main.ts "mine"
error: Uncaught TypeError: utxos.map is not a function
return Promise.all((utxos as any).map(async (utxo: any) => {
^
at Kupmios.kupmiosUtxosToUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:224:39)
at Kupmios.getUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:92:17)
at eventLoopTick (ext:core/01_core.js:183:11)
at async Command.actionHandler (file:///Users/goncaloazevedo/Desktop/aiken/mine/fortuna/miner/main.ts:61:28)
at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
at async file:///Users/goncaloazevedo/Desktop/aiken/mine/fortuna/miner/main.ts:401:1

This is happening in multiple devices all of the sudden, after everything going well. Any clue whats happening?

Error when getting address

Getting this error when attempting to get address, I have all the requirements and built a wallet but can't get the actual wallet address. Running on Mac:

Task cli deno run --allow-all miner/main.ts "address"
error: Uncaught (in promise) SyntaxError: Unexpected token '<', "
<h"... is not valid JSON
const result = await fetch(
^
at parse ()
at packageData (ext:deno_fetch/22_body.js:369:14)
at consumeBody (ext:deno_fetch/22_body.js:246:12)
at eventLoopTick (ext:core/01_core.js:183:11)
at async Kupmios.getUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:86:20)
at async Command.actionHandler (file:///Users/user/Desktop/projects/cardano-aiken-fortuna/Fortuna/miner/main.ts:316:19)
at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
at async file:///Users/user/Desktop/projects/cardano-aiken-fortuna/Fortuna/miner/main.ts:345:1

config file not found?

Error: No config file found.

on windows 10 using powershell,,, any ideas what im doing wrong?

outsideOfValidityInterval

[
{
outsideOfValidityInterval: {
interval: { invalidBefore: 101671472, invalidHereafter: 101671652 },
currentSlot: 101671418
    }
  }
]

SyntaxError: Unexpected token '<', "<html> <h"... is not valid JSON

Got this after a period of mining with basic deno task cli mine run.

error: Uncaught (in promise) SyntaxError: Unexpected token '<', "<html>
<h"... is not valid JSON
    const result = await fetch(
                   ^
    at parse (<anonymous>)
    at packageData (ext:deno_fetch/22_body.js:369:14)
    at consumeBody (ext:deno_fetch/22_body.js:246:12)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async Kupmios.getUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:86:20)
    at async Command.actionHandler (file://xxx/fortuna/miner/main.ts:107:28)
    at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
    at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
    at async file:///xxx/fortuna/miner/main.ts:413:1

Unknown transaction input

New block not found in 30 seconds, updating state
Found next datum: d8799f1907065820000006dff9205db5e091234e60b34014714a5c9d1fef064b297e3702c04e39420519ffff1a06e8ad401b0000018a3a3957184d416c4c204861496c2074556e419f5820000006dff9205db5e091234e60b34014714a5c9d1fef064b297e3702c04e39425820000000c3eec000141b73d9f9009577b7fe43edd0a5f4eabcbaf88d959e5e562f5820000000c3eec000141b73d9f9009577b7fe43edd0a5f4eabcbaf88d959e5e562f5820000000c3eec000141b73d9f9009577b7fe43edd0a5f4eabcbaf88d959e5e562f58200000006eb7acf12b94c966d0581bbc2801815a3a34194c2e25a8acf85f7bb849582000000022dce0f741c1e9a4429896e2df6c145337dc6b428189de693c4f3e3522582000000002d0da241c8aed392c2afa621fb6b5ac5b4608e239ef7406b68f2ab354582000000002d0da241c8aed392c2afa621fb6b5ac5b4608e239ef7406b68f2ab354582000000002d0da241c8aed392c2afa621fb6b5ac5b4608e239ef7406b68f2ab354582000000002d0da241c8aed392c2afa621fb6b5ac5b4608e239ef7406b68f2ab354ffff
[
{ extraRedeemers: [ "spend:1" ] },
{
collectErrors: [
{
badTranslation: "Unknown transaction input (missing from UTxO set): 95c06c8d447206a5bdb6ed1042a99bdd6ed5617241abde834"... 17 more characters
}
]
},
{
valueNotConserved: {
consumed: {
coins: 10000000,
assets: {
"279f842c33eed9054b9e3c70cd6a3b32298259c24b78b895cb41d91a.54554e41": 5000000000
}
},
produced: {
coins: 12870460,
assets: {
"279f842c33eed9054b9e3c70cd6a3b32298259c24b78b895cb41d91a.54554e41": 5000000000,
"279f842c33eed9054b9e3c70cd6a3b32298259c24b78b895cb41d91a.6c6f72642074756e61": 1
}
}
}
},
{
badInputs: [
{
txId: "95c06c8d447206a5bdb6ed1042a99bdd6ed5617241abde8348878d171ab832a3",
index: 0
}
]
}
]
Mining...

unexpected EOF exception

After a few minutes, I get this error when mining:

error: Uncaught (in promise) TypeError: error sending request for url (https://kupo-mainnet-fortuna-api-<sanitized>.us1.demeter.run/matches/addr1wynelppvx0hdjp2tnc78pnt28veznqjecf9h3wy4edqajxsg7hwsc?unspent): connection error: unexpected end of file
    const result = await fetch(
                   ^
    at async mainFetch (ext:deno_fetch/26_fetch.js:277:12)
    at async fetch (ext:deno_fetch/26_fetch.js:501:7)
    at async Kupmios.getUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:86:20)
    at async Command.actionHandler (file:///C:/john/dev/workspace/fortuna/miner/main.ts:107:28)
    at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
    at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
    at async file:///C:/dev/fortuna/miner/main.ts:413:1

deno task cli address is able to show my wallet balance. Calling that unspent URL from a browser returns a well formed JSON response. Running 100% synced Kupo v2.5 and Ogmios v5.6.0. There are three UTxOs in my wallet (5, 5 and 12 ADA in each UTxO).

A question about validating previously blocks

I hope it's alright to ask questions, but I have one.... ;-)

When I look at the mining code, I can't help but question one bit of logic. The Nonce is a random value that is used to double SHA the block details until the threshold of difficultly and leading zeros are found. However, when the block is 'mined', the nonce is NOT written to the transaction DATUM.

How is one meant to be able to validate previous blocks are correct? I've been toying with the idea of writing a little miner myself, but I wanted to make sure existing blocks validate via my code.

Is it possible? Clearly I'm missing something here, as it logically should be possible?

Error when creating address

When I execute deno task cli address i get the following error:

Task cli deno run --allow-all miner/main.ts "address" error: Top-level await promise never resolved await new Command() ^ at <anonymous> (file:///config/workspace/repo/fortuna/miner/main.ts:399:1)

Also the vscode yells that can't find the modules that the main.ts file is importing:

I'm using demeter with Kupo 2.4.0 and Ogmios 5.6.0

Uncaught (in promise) TypeError: utxos.map is not a function: Keep crashing

This is what I am getting

eturn Promise.all((utxos as any).map(async (utxo: any) => {
at Kupmios.kupmiosUtxosToUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:224:39)

at Kupmios.getUtxos (https://deno.land/x/[email protected]/src/provider/kupmios.ts:92:17)
at eventLoopTick (ext:core/01_core.js:183:11)
at async Command.actionHandler (file:///home/x/fortuna/miner/main.ts:105:28)
at async Command.execute (https://deno.land/x/[email protected]/command/command.ts:1948:7)
at async Command.parseCommand (https://deno.land/x/[email protected]/command/command.ts:1780:14)
at async file:///home/x/fortuna/miner/main.ts:401:1

Fatal process out of memory: ExternalEntityTable::AllocateSegment

System is definitely not running out of memory any time soon, however this happens every few minutes:

<--- Last few GCs --->

[98508:000001CEA392BCD0]   922744 ms: Scavenge 116.9 (129.5) -> 109.9 (130.3) MB, 0.51 / 0.00 ms  (average mu = 0.925, current mu = 0.906) allocation failure;
[98508:000001CEA392BCD0]   922767 ms: Scavenge 117.6 (130.3) -> 110.7 (130.8) MB, 0.45 / 0.00 ms  (average mu = 0.925, current mu = 0.906) allocation failure;
[98508:000001CEA392BCD0]   922791 ms: Scavenge 118.4 (130.8) -> 111.6 (131.8) MB, 0.65 / 0.00 ms  (average mu = 0.925, current mu = 0.906) allocation failure;


<--- JS stacktrace --->


#
# Fatal process out of memory: ExternalEntityTable::AllocateSegment
#

Create wallet

I am executing the deno task cli init command that creates the wallet and creates the seed.txt but it tells me the following
error: Uncaught (in promise) MissingEnvVarsError: The following variables were defined in the example file but are not present in the environment:
KUPO_URL, OGMIOS_URL

Make sure to add them to your env file.
throw new MissingEnvVarsError(

Checking the .env file we see that the parameters are well defined and in the correct root:
KUPO_URL="xxx"
OGMIOS_URL="xxx"

Could it be that being from Europe won't let me?

thanks :D

Error when trying getting the miner address or mining command

I installed Kupo and Ogmios locally. Kupo is on port 1442 and Ogmios at 1337
I am suspecting the .env might be wrongly configured by me
I set it as follows
KUPO_URL="http://127.0.0.1:1442"
OGMIOS_URL="ws://127.0.0.1:1337"

I curled from Kupo and opened the monitoring page of Ogmios to check they are running and synced.

The error as shown in image below
Screenshot from 2023-08-29 23-05-46

By the way I used the --match field in Kupo to the policy ID of Tuna as follows --match "279f842c33eed9054b9e3c70cd6a3b32298259c24b78b895cb41d91a.*"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.