textury / arlocal Goto Github PK
View Code? Open in Web Editor NEWLocal testnet for your Arweave products.
License: MIT License
Local testnet for your Arweave products.
License: MIT License
Everything worked fine, but at some point it stopped working.
Get 410 error when posting transaction.
Hey,
Since the #63 has been fixed - I've upgraded both arweave.js and arlocal in our testnet (https://testnet.redstone.tools/) to latest versions (arweave.js to 1.10.23 and arlocal to 1.1.21).
Now - while trying to load contract with smartweave.js (with arweave.js 1.10.23)
const arweave = Arweave.init({
host: 'testnet.redstone.tools',
protocol: 'https',
port: 443,
});
const result = await readContract(arweave,"6hzHw8wwOuojRMpFOzlJCWJm2ls1Ch5L1U2gFLQI7NM")
I'm getting this error (previously the "offset" error from #63 was thrown)
0|index | [23.02.2022, 12:36:44] <-- GET /tx/6hzHw8wwOuojRMpFOzlJCWJm2ls1Ch5L1U2gFLQI7NM/offset
0|index | [23.02.2022, 12:36:44] {
0|index | id: '6hzHw8wwOuojRMpFOzlJCWJm2ls1Ch5L1U2gFLQI7NM',
0|index | owner: 'xdEWn5OtEUVfN5tGX7E73wtIGNT2wKf3NZa3bqTEvC8yVhMSRXxmMx555puRfsWY6-SXc5Mv5S4DPa-KiCt9tLBDPizXn8dQ6zI6N5fuRa0hmVHphEDXIOZ5EFxIYqZe3HmrAh5xQJors3SFMBhPcBoCzxOd8Ce8Th78VysMjYnny1q0GfywcxZD87Rao-lrEZQh3pVOw_bkvAoIlaUE9SZKKW3JEWaOIQzFMfk910ngL6frqfIlgMRtQv3VoTpSHTPBVNDEfW-9W7T6nocHtMwLB8NK4ov9u0x2vILVK-_MbD9s3Nrn1L5roGcaUaAA96D1hxfdBPhOjiaXXuMNZeYOPYCkneke0ba7gX_G-8n9rFpylya7twTFoPAj1JSnftrVjBBXd5mt7EM0z76zdNN6yk-4S89Dwoc4ussPxzVLYmFB22WkQHjtEqg1QHq4ASqAmP1LSwywihZGhnycpJH8Ty7zaKUvwlasvA9ZPM3o2pzJG4cmTgJth-Qul-L3cNQ4__T-LOzMdJ9Ey3BraBYLu9GvnWo4T8yJYEKN9CCsrVepCkoGcz2_Y78smLJlQ8o9Or4cBoDeFv1QWUyZgrNBLEzAojGJ28LtzF4pmakKDKAtv9Y7XzpqY0NttFp8n2U6R-tADL_cp3evy13sE4q_xFavL4_EJKa1VL50chU',
0|index | tags: [
0|index | { name: 'QXBwLU5hbWU', value: 'U21hcnRXZWF2ZUNvbnRyYWN0' },
0|index | { name: 'QXBwLVZlcnNpb24', value: 'MC4zLjA' },
0|index | {
0|index | name: 'Q29udHJhY3QtU3Jj',
0|index | value: 'N01IaGtNVzMzZmd3SVQtSFc2WTJ3WkQwMVN2dzJyT1F6MXYzUmFvMlhKOA'
0|index | },
0|index | { name: 'U0RL', value: 'UmVkU3RvbmU' },
0|index | { name: 'Q29udGVudC1UeXBl', value: 'YXBwbGljYXRpb24vanNvbg' }
0|index | ],
0|index | target: '',
0|index | quantity: '0',
0|index | reward: '25546716',
0|index | signature: 'qLSjs0kqrcYCmvieM-3bft2g2cgcRD_ER59iwXYx3kvjP0oIoLaSTnx9RPBrDjD13K2lfoCvP8X6FGy8UTSwURJzcCeqihxbot_tMWgYwvNVWYrjI6WbHVbG54L8U-v0JjniG_gKk06y8Skl4We5_SL5ZNxg31fb5jy-lVRS7CMQjztKfPyGt9fKFIYJMNRIZAKsX7uILlUhbhu6MHztWBGuTmPV2Y6I42KUveH4uQNEonsLpd99tEZRNHUf4ODsGQe1vBIKD9lTG-XF98G78YtE5WQyyoT5oWNEUzZp-B3JfJlCkG6EIgptI4JsGLaWUQ2hY9fDilxCQViauLecHSb6GjbqL9i-HN9ryDK2ZKW4P-rh1WNQZcUGymKxhinvbhBCQHuf0uK4mZn0-Ki6nsgSd9Cm8m5Ud2xoxzZHOX254xv94PDrmkyfeSyIHmd42a3YG2Hqzu-L0dNckOwDjb52SdUH-BeSnDEXyoYVkyf6ySxBibxdqKbqAyuk5HCrIs-FDP3nOaDihlBWIwMLOwnU8ZVdnpLTb0J6QKwSm0F609Q_NojLljwCByYig4JqRaOkbNF1gh2lx89FGrn8t6EgoNTnRRGP-AAGYFqw5bSKn0ktWMsh7A2v0SiXKa8YyKGx7sv7hnMQaEg-eCVQHF7QtvUOUreusgbqeOv_JHA',
0|index | last_tx: '00034b2405uck4tns5ij6cniiwlv7r7eeci2b3v1vimhxxjnpid05yrzbj13mulc',
0|index | data_size: 13,
0|index | content_type: 'application/json',
0|index | format: 2,
0|index | height: 419173,
0|index | owner_address: 'rpx3X2kIfWPkbf9CvNVRFJR3OuJDtjXuWaQOQAeJujU',
0|index | data_root: 'GCwIrfft_Q4k5xnIWqnfdhEBGhNEbylpXT0N_e40FjM',
0|index | parent: null,
0|index | block: 'oecjqsw9vwh8fksx5g8e7i90loghwqm9waht3fnl7ke659xg95mno3d5ifywrd16',
0|index | created_at: '2022-02-23T08:26:25.188Z'
0|index | }
0|index | [23.02.2022, 12:36:44] <-- GET /mine
0|index | {
0|index | error: TypeError: Cannot read properties of undefined (reading 'findOne')
0|index | at /home/ec2-user/redstone-sw-testnet/node_modules/arlocal/bin/routes/transaction.js:106:43
0|index | at Generator.next (<anonymous>)
0|index | at fulfilled (/home/ec2-user/redstone-sw-testnet/node_modules/arlocal/bin/routes/transaction.js:5:58)
0|index | }
0|index | [23.02.2022, 12:36:44] --> GET /tx/6hzHw8wwOuojRMpFOzlJCWJm2ls1Ch5L1U2gFLQI7NM/offset 404 10ms -
It works when I'm reading the contract with the arweave.js 1.10.18.
Hello,
I notice that, after bundling data, if I try to fetch an individual data item's offset โ i.e. using the /tx/<id>/offset
route โ an error is thrown:
{
error: TypeError: Cannot read properties of undefined (reading 'offset')
at null.<anonymous> (node_modules/arlocal/src/routes/transaction.ts:133:33)
at Generator.next (<anonymous>)
at fulfilled (/node_modules/arlocal/bin/routes/transaction.js:5:58)
}
Alongside an HTTP response body of OK
(instead of the expected { size: number, offset: number }
).
Everything else pertaining to the data item's transaction is just dandy; it's only that route that's giving me problems. Normal (non-bundled) transactions also appear unaffected.
Thanks for looking into this!
The specific error is "Cannot return null for non-nullable field Tag.name." There's a sample query below. But when I try using an api I get back all the data when searching by transaction id and it includes the tags as well. I'm using http://localhost:1984/graphql.
query {
transactions(ids: ["<your transaction id>"]) {
edges {
node {
id
tags {
name
}
}
}
}
}
Here's a screenshot of the failure, but to be clear calls work as long as tags are not included. And as I said if I use the api, tags do come back without issue.
Creating transactions with a common tag then querying transactions by tag does not respect sort order The order is always ascending.
Sort order is the same regardless of the sort parameter.
query {
transactions(tags:[{ name: "holaplex:metadata:subdomain", values: ["localhost"]}], sort: HEIGHT_DESC || HEIGHT_ASC) {
edges {
node {
id
signature
tags {
name
value
}
}
}
}
}
Followed this tutorial on arweave, but was unable to run npx arlocal
. Tried with different node versions, including the latest. Tried in home directory vs repository directory. I am able to run this command on my windows 10 machine with npm 8.5.2. On my mac, however, I get the error SubtleCrypto not available!
. Running npm 8.11.0.
Logs point to the source being arweave/web/lib/crypto/webcrypto-driver.js
line 10. Looks like the function detectWebCrypto
returns false, causing the error to be thrown.
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-09-14T06_22_21_752Z-debug.log
Install for arlocal@latest failed with code 1
As the title suggests, I realized that the database Arlocal creates on startup is cleared for every new sessions. Looking at the code it seems that there is no way to optionally make the database persistent between restarts. Is there any barriers to this I am not aware of? How involved would it be to make this option available?
ps: my team really appreciate your effort on this tool, thank you!
I had an idea for some time to make the usage of arlocal more meaningful: making arlocal more realist by simulating failings.
The blockchain being what it is it's often not so reliable in terms of sending transactions and making sure they succeed. I propose to add an optional functionality to randomly simulate the rejection of transactions, mimicking the behavior of the blockchain. It wouldn't necessarily be that complex to start with, just rejecting some transactions from time to time on a configurable ratio would already be useful. Then maybe trying to iterate on it to make it more realistic and configurable over time. This feature could help to test for resilience in our case and I believe it could also be useful to many others.
How feasible do you think this idea is?
I've noticed that transaction posting or transaction fetching was broken in the 1.0.37 version.
After some low level debuggin in this project https://github.com/ppedziwiatr/swc-test I've found out that transaction data changes in a weird way after posting. After switching to 1.0.36 version of arlocal everything works fine.
Going off of Arweave Gateway behavior, bundled data-item transactions shouldn't be fetchable from any /tx
routes, but this works with arlocal
for most of them (e.g. /tx/[txid]/data
)
I was confused when trying to fetch a bundled data-item on mainnet via arweave.net/tx/[txid]/data
even though it was fetchable via arweave.net/[txid]
. So it seems to me some kind of mechanism to "not find" these data-item tx would need to be implemented.
Attempting to fetch the data for a path manifest via /tx/PATH_MANIFEST_TX_ID/data.json
returns a 302 and redirects to /PATH_MANIFEST_TX_ID/data.json
. This is not the same behavior as arweave.net
.
At the moment you can't use ArLocal with TypeScript.
The package is written in TypeScript so it should be easy to compile the package with types and post to npm
Hello,
I get the error below when i try to run Arlocal. I am currently on windows 10, node v12.18.
Unexpected token '.'
Hey :) I was trying to upgrade arweave-js lib to the newest version in the Warp SDK and our integration tests started to fail due to the following error:
console.error
{
error: TypeError: Cannot read property 'hash' of undefined
at chunkData (/Users/asiaziola/arweave/redstone-smartcontracts/node_modules/arlocal/src/common/lib/merkle.ts:73:36)
at generateTransactionChunks (/Users/asiaziola/arweave/redstone-smartcontracts/node_modules/arlocal/src/common/lib/merkle.ts:127:24)
at /Users/asiaziola/arweave/redstone-smartcontracts/node_modules/arlocal/src/routes/transaction.ts:209:55
at Generator.next (<anonymous>)
at fulfilled (/Users/asiaziola/arweave/redstone-smartcontracts/node_modules/arlocal/bin/routes/transaction.js:5:58)
}
at node_modules/arlocal/src/routes/transaction.ts:290:13
at Generator.throw (<anonymous>)
at rejected (node_modules/arlocal/bin/routes/transaction.js:6:65)
Hi,
Recently there were some issues that caused the arlocal not to function properly when used with SmartWeave contracts:
#17
#9
https://discord.com/channels/357957786904166400/756557551234973696/887777860994093108
Since more and more people are using ArLocal for testing their SmartWeave contracts (ArLocal seems to be a perfect fit for this use case) - including us (+ we're using it for integration tests within our smartweave sdk) - maybe you could add an integration test specifically for deploying and interacting with SmartWeave contracts?
Sth. similar to https://github.com/redstone-finance/redstone-smartcontracts/blob/main/src/__tests__/integration/deploy-write-read.test.ts (of course it could (or maybe even should in this case) be using the "official" Arweave SmartWeave SDK).
Thanks.
Hey!
That's probably a followup of #83
After switching to ArLocal 1.1.29, I'm getting these errors while trying to load wasm binary (using the /{txId}
endpoint:
If I try to load the data with
const txData = (await this.arweave.transactions.getData(id, {
decode: true
})) as Uint8Array;
Originally raised on Discord and reproduced by @kouraf
Hey,
I've upgraded ArLocal in our redstone-smartcontracts to the latest version and now during the contract deployment in our intergration tests (eg: https://github.com/redstone-finance/redstone-smartcontracts/blob/main/src/__tests__/integration/deploy-write-read.test.ts) I'm getting an error while creating a transaction with contract source:
srcTx = await this.arweave.createTransaction({ data: src }, wallet);
The last version that works properly, is 1.1.9
would be great if we could add bundle unpacking to this so we can test bundle uploads.
npx arlocal 8080
curl --request GET
--url 'http://127.0.0.1:8080/info'
mint 5000
curl --request GET
--url 'http://127.0.0.1:8080/mint/MlV6DeOtRmakDOf6vgOBlif795tcWimgyPsYYNQ8q1Y/5000'
Not Found
curl --request GET
--url 'http://127.0.0.1:8080/mine'
curl --request GET
--url 'http://127.0.0.1:8080/mine/5'
curl --request GET
--url 'http://127.0.0.1:8080/block/height/1'
Not Found
When playing back audio (queried from arlocal) in the native html <audio />
element, although playback is working fine, there seems to be an issue with seeking the audio as no there is no Content-Range header on the response. Using the default arweave.net
gateway, seeking is working fine.
Just wondering if you have any plans to support this feature anytime soon :)
Hello,
I recently started using Arlocal and when going to post a transaction, Arlocal returns a 410 error that says "You don't have enough tokens."
Before calling this method, I fund the wallet and confirm that the transaction completes successfully
let arWallet
arweave.wallets.generate().then((t) => { arWallet = t arweave.api.get('mint/${arWallet.n}/10000000000000000000').then((t) => console.log(t)) console.log(arWallet) })
...
const check = await fetch('http://localhost:1984/wallet/${arWallet.n}/balance') console.log(await check.json())
After creating and signing the transaction, I check the price of the transaction to ensure that it's less than the current wallet balance
console.log(JSON.stringify(courseDesc)) const cost = await fetch('http://localhost:1984/price/${tx.data_size}') console.log(await cost.json())
Upon running arweave.post(tx)
, I receive the following
I'm quite new to Arlocal so I'm hoping to receive some insight on why this behavior is occurring.
Thanks!
Hi,
I noticed that on 18 Nov 2021 src/routes/transaction.ts was refactored in such a way that transaction fee is calculated
roughly by (data.data_size * 1965132).
My app airdrops winston relying on arweave.transaction.getPrice(...) which yields a value more than ten times smaller than calculated by arlocal, so my transaction fails with status 410.
There is also online arweave fee calculator that yields yet another value.
So I'm confused of what is going on.
Is there a source of truth or a paper I could consult regarding this question ?
Arweave Gateways provide the header Access-Control-Allow-Origin: *
which is necessary if the site origin making the request is using Cross-Origin-Embedder-Policy: require-corp
(necessary for SharedArrayBuffer
WASM functionality)
I'm not sure if all Gateway routes provide this header, but I assume all the public facing ones do.
Hi, try to run arlocal but it doesn't start, it started to happen today:
PS D:\ar> npx arlocal
Need to install the following packages:
arlocal
Ok to proceed? (y)
npm WARN deprecated [email protected]: Switch to namespaced @noble/ed25519 for security and feature updates
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
PS D:\ar>
Please help, what could that be?
Best
GET http://localhost:1984/block/height/0
{
"indep_hash": "4eqrcbdscydag0th2mgs4wn2d7q0w9k2x23k3mzh221xcwf6kwleakdi4nrb2v50",
"timestamp": 1657744670,
"previous_block": "",
"height": 0,
"txs": [
""
]
}
In the SQLite blocks
table, this block has no transactions. I think the fix here is to just return an empty array.
Hi.
It seems that when I'm asking GQL endpoint for transactions with filter on min and max block height, the min. value is exclusive, instead of inclusive.
Eg. current block height is 5, I'm asking for transactions with min. block height = 3 and max block height = 5 - in response I'm getting transactions on block heights 4, 5 - instead of transactions on block heights 3, 4, 5.
Let's say the network info returns:
{
network: 'arlocal.N.1',
version: 1,
release: 1,
queue_length: 0,
peers: 0,
height: 2,
current: 'uh3m601k0kfj9c1r6i4yea79dp7fh9p9xt1d7gdg9l0',
blocks: 2,
node_state_latency: 0
}
I'm adding three new transactions:
await contract.writeInteraction({ function: 'add' });
await mine();
await contract.writeInteraction({ function: 'add' });
await mine();
await contract.writeInteraction({ function: 'add' });
await mine();
After that the network info is:
{
network: 'arlocal.N.1',
version: 1,
release: 1,
queue_length: 0,
peers: 0,
height: 5,
current: '4k4f6d13cq9u4pdxph1a5d1lghm03on2kt0tk9g5rno',
blocks: 5,
node_state_latency: 0
}
Then I'm asking for transactions with min. block height = 3 and max. block height = 5.
I'm getting 2 transactions as a result, instead of 3:
2021-09-16T21:37:06.242Z DEBUG [ContractInteractionsLoader] All loaded interactions: [ { from: 3, to: 5, loaded: 2 } ]
Hello!
Started running into problems after the latest release.
Many of the endpoints is returning 404 Not Found regardless how i call them
/mine
/mint/
Only endpoints i can get to work is /info and /peers
Downgrading Arlocal to the earlier release made it work again.
Im not sure how to get out any better logs so if you want me to get some better logs you gotta point me in the right direction :)
Edit:
Ive tried calling the endpoints using postman, through the browser and arweave.js. All with the same result.
Hey,
I'm trying to load a wasm binary file in my integration test. By default our SDK is using the
/{txId}
to load the data - if it fails, it falls back to await this.arweave.transactions.getData
.
In case of this binary (~360kb) - loading it from ArLocal's /{txId}
and then trying to instantiate a WASM module - ends-up with this error:
It looks as if the data was truncated / not fully loaded.
When I load the binary using the await this.arweave.transactions.getData
- it works properly.
Using ArLocal 1.1.26
Also - attaching the WASM binary.
go-pst.wasm.zip
Hello guys! Today I tried to run ArLocal 1.1.58 from node using the provided code example:
import ArLocal from 'arlocal';
(async () => {
const arLocal = new ArLocal();
// Start is a Promise, we need to start it inside an async function.
await arLocal.start();
// Your tests here...
// After we are done with our tests, let's close the connection.
await arLocal.stop();
})();
But I'm getting this error:
/index.js:4
const arLocal = new ArLocal();
^
TypeError: ArLocal is not a constructor
at file:///C:/xampp/htdocs/ardbweb/index.js:4:19
at file:///C:/xampp/htdocs/ardbweb/index.js:13:3
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
What do you think that could be the problem? Am I doing something wrong? Thanks in advance!
After minting some coins for an address A and sending a few to address B, when checking the balance of Address A a HTTP/1.1 204 No Content
error is received. When checking the balance of Address B, the balance check is successful and shows the transferred tokens.
Before the Transaction is submitted and after minting, the balance of Address A shows the correct amount.
Checking balance with curl -i localhost:1984/wallet/{Address A}/balance
.
Calling /mine
does not help either.
The following reproduces the issue.
import Arweave from "arweave";
const arweave = Arweave.init({
host: "127.0.0.1",
port: 1984,
protocol: "http",
});
(async () => {
// Generate a wallet
const wallet = await arweave.wallets.generate();
// Mint some tokens
const address1 = await arweave.wallets.jwkToAddress(wallet);
await arweave.api.get(`mint/${address1}/99990000000000`);
// Post some transactions with data, and keep their txid's
console.log("----------Post Transactions----------")
const txids = [];
for(let i = 1; i < 4; i++) {
const data = new Uint8Array([i,i,i,i,i,i,i,i,i]);
const tx = await arweave.createTransaction({data});
await arweave.transactions.sign(tx, wallet);
await arweave.transactions.post(tx);
console.log(`${tx.id}:${tx.data}`);
txids.push(tx.id);
}
// Mine those transactions as a cautionary mesaure
await arweave.api.get(`mine`);
// Request the transactions in parallel
console.log("----------Get Transactions----------")
let datas = await Promise.all<Uint8Array>(
txids.map( async function (txid) {
const tx = await arweave.transactions.get(txid);
console.log(`${tx.id}:${tx.data}`);
return tx.data;
})
);
console.log("done");
})();
This snippet will output the following
You can see that the parallel transaction requests result in all transactions having the same data.
(The other transaction header information is correct, it's just the transaction data property that seems to be getting clobbered)
Requesting transactions in parallel should not corrupt their data.
Hey,
it seems that ArLocal stores the block timestamps in ms - eg: https://testnet.redstone.tools/block/hash/yntizjk6y1s913sqk2xlvr2orlbkpaxbo4pkesukhj3n7rsgsdig0vbs0mbtaakh
"timestamp": 1651833550758
The mainnet (arweave.net and nodes) returns the block timestamp in seconds - eg:
https://arweave.net/block/hash/fVUSZD3gZr1LpmzqRpgFFUZT5ZsDd1-uvRZbT7tiM4t29xLl9LTdIXAwXJOB5I-g
"timestamp":1624197593
That's a bit problematic - e.g. in case of testing a smart contract that expects timestamp in seconds.
Hello again :-)
So I've switched to a 1.0.43
version, the #24 issue seems to be fixed, but now I have another problem.
I'm running my integration tests for the PSTs and I've noticed that on 1.0.43
the owner
that is set on a mined transaction is not the same owner that was used to create this transaction:
Posting interaction transaction (with "transfer" function): transaction owner's wallet address is set to gmmqRKbMGu6LY6WosOjlkcKt7xjDJG-3VugH-pQDdnQ
in this case
Loading the new transaction - the transaction's owner address is set to qaBAjOAooARGzvjdPfkj30jr0A2RxQ1i5anWQHynOYs
- instead of gmmqRKbMGu6LY6WosOjlkcKt7xjDJG-3VugH-pQDdnQ
.
Of course this causes the test to fail - basically it seems that the owner in the mined transaction is always set to some random wallet address...
This worked fine in the previous versions.
import Arweave from "arweave";
const arweave = Arweave.init({
host: "127.0.0.1",
port: 1984,
protocol: "http",
});
(async () => {
// Query the blockheight via GQL
let currentBlockHeight = await getArweaveBlockheight();
console.log(`initial blockHeight: ${currentBlockHeight}`);
// Mint 110 blocks
for (let i = 0; i < 110; i++) {
await arweave.api.get(`mine`);
}
// Query the blockheight via GQL again
currentBlockHeight = await getArweaveBlockheight();
console.error(`queried blockHeight: ${currentBlockHeight}`);
// Now check the blockheight via the info endpoint
const response = await arweave.api.get("");
console.log(`actual blockHeight: ${response.data.height}`);
console.log("done");
})();
async function getArweaveBlockheight(): Promise<number> {
const queryObject = { query: `query{ blocks(sort: HEIGHT_DESC, first:100 ){ edges{ node{ height } } } }` }
const result = await arweave.api.post(`/graphql`, queryObject)
const edge = result.data.data.blocks.edges[0];
if (edge) {
const arweaveBlockHeight = edge.node.height;
return arweaveBlockHeight;
}
return -1;
}
running this test with a fresh instance of arlocal
produces the following output...
A block height GQL query returns the same height as the info endpoint when there are more than 100 blocks.
Steps to reproduce:
arlocal
curl -X POST http://localhost:1984/wallet
- this gives an address f5xuglsb79wsnwvdk2jbqdepsxd0way8d4jwtngt2l8
curl http://localhost:1984/mint/f5xuglsb79wsnwvdk2jbqdepsxd0way8d4jwtngt2l8/222
- returns HTTP code 200 and 222
as the response bodycurl http://localhost:1984/wallet/f5xuglsb79wsnwvdk2jbqdepsxd0way8d4jwtngt2l8/balance
- gives 0
Expected result: balance should be = 222
Actual result: balance = 0
When trying to upload 1mb file get POST 413.
I found
arlocal/src/routes/transaction.ts
Lines 130 to 134 in 06624ab
/.npm/_npx/8250aebdfc72c15b/node_modules/arbundles/build/ar-data-create.js:15
const _target = opts?.target ? base64url_1.default.toBuffer(opts.target) : null;
SyntaxError: Unexpected token '.'
Let's say I make some transactions, then I want to retrieve their tags for instance:
query {
transactions {
edges {
node {
id
tags {
name
value
}
}
}
}
}
Above is the GraphQL query I use, Then using a tool like Insomnia
(or Postman
), I send a Post
request to localhost:1984
(where Arlocal
is run), but all I get is: Method Not Allowed
.
I'm a newbie in the blockchain world so I'd be grateful if you could show me what I'm doing wrong.
Hi,
While using arlocal, I saw it output this message for one of my transactions:
{
error: 'Validation Error',
validationErrors: [
'"last_tx" is invalid, should be "", indep_hash one of last 50 blocksor last transaction of owner address. It is always taken from the /tx_anchor endpoint.'
]
}
I can make a PR for this, but just wanted to confirm what the error message should be.
I see blocksor
in https://github.com/textury/arlocal/blob/main/src/middlewares/transaction.ts#L133-L134 being a concatenated string and probably just needs a space after blocks
. Is this correct?
Also, based on the last_tx
field definition (on the Arweave HTTP API docs at https://docs.arweave.org/developers/server/http-api#field-definitions) shown below ...
An anchor - a protection against replay attacks. It may be either a hash of one of the last 50 blocks or the last outgoing transaction ID from the sending wallet. If this is the first transaction from the wallet then an empty string may be used. The recommended way is to use the value returned by GET /tx_anchor. Two different transactions can have the same last_tx if a block hash is used.
... is the error message supposed to be something along the lines of:
"last_tx" is invalid, should be "", hash of one of last 50 blocks or last transaction of owner address. It is always taken from the /tx_anchor endpoint.
Or maybe just use what's shown in the field definition?
Getting this error back from the /graphql
endpoint when searching for transactions that were posted as bundled data items:
{
"errors": [
{
"message": "Cannot return null for non-nullable field Transaction.anchor.",
"locations": [{ "line": 37, "column": 7 }],
"path": ["transactions", "edges", 0, "node", "anchor"],
"extensions": { "code": "INTERNAL_SERVER_ERROR" }
}
],
"data": null
}
Investigating the SQLite DB shows that these data item transactions are being inserted with last_tx
value of NULL
. This is because data items don't have that field.
My guess is that it should be inserting empty string instead, like other tx that don't have a value for last_tx
Looking inside the db folder there is no connect module file.
Hi,
i want to run arweave transaction on nodejs locally with running arlocal. My arlocal run on http://localhost:1984/.
I initialized arweave as:
const arweave = Arweave.init({
'host': 'localhost',
'port': 1984,
'protocol': 'http'
})
i'm seding transaction as:
let transaction = await arweave.createTransaction({ data: "pipka" })
await arweave.transactions.sign(transaction)
I'm getting:
(node:213) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:1984
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:213) UnhandledPromiseRejectionWarning: Unhandled promise rejection.
Does arweave with arlocal not work on node? Because i copypasted everything from https://edgeandnode.com/blog/developers-guide-to-arweave except the part that my code is in node, and tutorials on react.
Any suggestions would be very appreciated
Best!
I've been having mixed success with retrieving transaction data. Normally the first transaction I execute completes and I'm able to fetch the blob but on the next transactions succeed but I get a 500 when querying the data.
This is a snippet of the logs.
<-- GET /CK5KQH7jhAstXUs1RTzbtBUYG__UnqE0yvJXYdEMEng
[7/6/2021, 9:59:56 PM] {
id: 'CK5KQH7jhAstXUs1RTzbtBUYG__UnqE0yvJXYdEMEng',
owner: '-uNN6D6K4cDPW1liclKyUbuO3sGPd4saaqsLOzID2ZKj_Bnj4XN3bLG2qbKAEMj8fOAzfd_x68gKqZ78mR04YPZeKTJA7q_vYm5f3W3uV2fsNdWYZAGLODKy-npBiyG2Cnc1_TgkHic2fY-t4KeiZPp9AUGeS7B-rceXacZfo-cR5bgFOTmPIM4G8s83kT-QiCQg71l8H4R-OY3NFNfIqNwOQ9NLNUjbcvBsySbUmHd3nrZ-eVaCke0YnGfq5C4AK1XuA-kDsW9b6JfA7guTtPabTdWQtgw8-mJsDzw-XZVn13UBNrz-1CDM2wpW0GVEw1gNvwIxfymAY7oZplhRGzNnKwqSEGz3bHpyGQWn4yuF52oSHiklX7hiiBp2lcblFnHRZC-knsZ4B0MCyWXywNNCXQJcid_AEZX1sDp9A6jHJ7_ERTMZitAq8lSAk2wINlv6Q9KEveU3Oucm0iRMwCfJVCWEMGjw-x7cDDEuaEcS4yvjnhQNGbk7UGcJPiagTxbh-hNAYiR_MNTpZUG5HbYnJ-OIcX7-ZFaJ3YK_YcifqFmg-q23ts4XaVH6c-q_sdkCH8TGzkGQWE2d8WlgekjnoP060QHdoq0EeaONpHagsIKdXWqRkyz2yW8iLLuRDFO1Zoi8spOLIeLoPEcDuxQAjxdL_-WEb2dw_PF6T5c',
tags: [
{ name: 'Q29udGVudC1UeXBl', value: 'dGV4dC9jc3M' },
{ name: 'aG9sYXBsZXg6c3ViZG9tYWlu', value: 'ZXNwaQ' },
{
name: 'c29sYW5hOnB1YmtleQ',
value: 'MlVuc2pjWHlYVEpHTEdjVXdCWVNUeEpWd0M5S1lmYU5ibWQ0d0trNHpDb1A'
},
{ name: 'U2lnbmluZy1DbGllbnQ', value: 'QXJDb25uZWN0' },
{ name: 'U2lnbmluZy1DbGllbnQtVmVyc2lvbg', value: 'MC4zLjA' }
],
target: '',
quantity: '0',
reward: '1159427880',
signature: 'RaGUq7NiHwwsG_QkkI11HjUWv_gCA_8y1Bxwbwrcg3VwYF6SGGG2menxM_WFKwuNzUUUxCHvr3M-xIbBVxfXk5nQEXvMzRHS46WLDkvdTJzYzM181KoMrBcTOC46ojJDUocGZ_Z8jsnKcqkcRlIJf8t-w7xzWPD1YDrAJVGg_9BDhsapgAlCP4W0jG9vRGNKPt3h5boyAiqTKJyV0smpPYUiYvyjVAZLIO5imbv8ihpyA6x7fT8FbcdLBf6TjJbXbzst9otHQnixAuuVaQC1B53F2vqQ41oGif0hzedF3Dqu78_5Y2NAJnnV_kdiM4qE6Q8moPqEOskTQmXUneh8hslkdgo3GQaLQOZ5f55UItZoRSwJMD57k14s8UwUdUvpnVCGFmpmF0B5OYT6PWVIfoMCjHyMlYY0NUHs_IaeyBEketYUtiYsUWoo-mcXngG9j_UhfU5CK-YCqvC-QfOaB6e3CGF2r-0n0M-JIDZQOZNDC1X0vLVZEQegzmvu7b3czjCA0nrpWD4qSuzvkziT35NBdFNCwOeNMtvivxI6nlw8Xe_2v4NKTV2Nayu2QOJXLmfgyT5wliqhOuKDgdmuA0ak632mZ-2MaAjb-_DTKsMHiI4O3DaIFYADlzVKKR34KmfJtz_PBVw3GlQq_PjQcn7JWyTAGMS8K7lApjcHjRY',
last_tx: 'jcYh7SdtqSmRUcauAxDMLFpLHzbyaw5JNmoOj9JVbec',
data_size: 590,
content_type: 'text/css',
format: 2,
height: 0,
owner_address: 'xxxxx',
data_root: 'IWVseuzIvOYniH6WWhvHeoYy7kKEkZSKsXY6_ahw_bnEb0IPlzPLmRSZnew-tDpMJVQGgzqErCXO844JQdvmXc',
parent: null,
created_at: '2021-07-07 04:50:21'
}
xxx GET /CK5KQH7jhAstXUs1RTzbtBUYG__UnqE0yvJXYdEMEng 500 3ms -
TypeError: Cannot read property 'data' of null
at /home/espi/.npm/_npx/93eb0fdaba426b32/node_modules/@textury/arlocal/bin/routes/data.js:65:66
at Generator.next (<anonymous>)
at fulfilled (/home/espi/.npm/_npx/93eb0fdaba426b32/node_modules/@textury/arlocal/bin/routes/data.js:5:58)
This async function doesn't seem to be unbundling tx uploaded via chunks. Small bundles (< ~5MB) seem to work fine as they're posted in full and un-bundled by the preceding clause of the if-statement. From debugging, it seems the while
loop never completes and just continues infinitely, even after all chunks have been uploaded? In my specific test case it's waiting for a data_size
of 5133639
but is waiting for this to equal an offset that will always be greater e.g. 44873426
from chunkDB
. Chunk offset seems to be universal from the table itself, rather than per-transaction. I'm not sure how this async function would ever un-bundle anything unless it's the very first data-storage transaction on a fresh DB.
https://github.com/textury/arlocal/blob/main/src/routes/transaction.ts#L183
I'm using custom code to create and sign DataItem
since the Signer
is generated from a browser-extension (e.g. ArConnect) and we don't have access to the user's JWK. This is in a browser environment.
DataItemFactory
import Arweave from 'arweave'
import { createData, DataItem } from 'arbundles'
import { Signer } from 'arbundles/src/signing'
import { getSignatureData } from 'arbundles/src/ar-data-base'
export default class DataItemFactory {
static async create(
data: string | Uint8Array,
signer: Signer,
tags?: { name: string, value: string }[]
): Promise<DataItem> {
const dataItem = createData(data, signer, { tags })
await signDataItem(dataItem, signer)
return dataItem
}
}
async function signDataItem(item: DataItem, signer: Signer): Promise<Buffer> {
const { signature, id } = await getSignatureAndId(item, signer)
item.getRaw().set(signature, 2)
return id
}
async function getSignatureAndId(
item: DataItem,
signer: Signer,
): Promise<{ signature: Buffer; id: Buffer }> {
const signatureData = await getSignatureData(item)
const signatureBytes = await signer.sign(signatureData)
const idBytes = await Arweave.crypto.hash(signatureBytes)
return { signature: Buffer.from(signatureBytes), id: Buffer.from(idBytes) }
}
BundleFactory
import { Bundle, DataItem } from 'arbundles'
import { longTo32ByteArray } from '~/app/util'
export default class BundleFactory {
static create(items: DataItem[]): Bundle {
console.log('BundleFactory.create(items) items', items)
const headers = Buffer.alloc(64 * items.length)
const binaries = items.map((item, index) => {
const header = Buffer.alloc(64)
header.set(longTo32ByteArray(item.getRaw().byteLength), 0)
header.set(item.rawId, 32)
headers.set(header, 64 * index)
return item.getRaw()
})
const buffer = Buffer.concat([
longTo32ByteArray(items.length),
headers,
...binaries
])
return new Bundle(buffer)
}
}
longTo32ByteArray
export function longTo32ByteArray(long: number): Uint8Array {
// we want to represent the input as a 8-bytes array
const byteArray = [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
];
for (let index = 0; index < byteArray.length; index++) {
const byte = long & 0xff;
byteArray[index] = byte;
long = (long - byte) / 256;
}
return Buffer.from(byteArray);
}
ArtworkBundleFactory
const manifestDataItem = await DataItemFactory.create(
JSON.stringify(manifest),
signer,
[
{ name: 'Content-Type', value: 'application/json' },
{ name: 'slug', value: opts.slug },
{ name: 'Category', value: 'artwork' },
{ name: 'App-Name', value: this.appName },
{ name: 'App-Version', value: this.appVersion }
]
)
const processedImages = [
await DataItemFactory.create(
preview, // Uint8Array
signer,
[{ name: 'Content-Type', value: previewType }]
),
await DataItemFactory.create(
preview4k,
signer,
[{ name: 'Content-Type', value: previewType }]
),
await DataItemFactory.create(
image,
signer,
[{ name: 'Content-Type', value: type }]
)
]
const processedAudio = [
await DataItemFactory.create(
audio,
signer,
[{ name: 'Content-Type', value: opts.audio.type }]
)
]
const bundle = BundleFactory.create([
manifestDataItem,
...processedImages,
...processedAudio
])
const manifestId = manifestDataItem.id
const data = bundle.getRaw()
const tx = await arweave.createTransaction({ data })
tx.addTag('Protocol', 'ArtByCity')
tx.addTag('App-Name', this.appName)
tx.addTag('App-Version', this.appVersion)
tx.addTag('Bundle-Format', 'binary')
tx.addTag('Bundle-Version', '2.0.0')
tx.addTag('Category', 'artwork:bundle')
tx.addTag('slug', opts.slug)
tx.addTag('Manifest-ID', manifestId)
const uploader = await arweave.transactions.getUploader(tx)
while (!uploader.isComplete) {
await uploader.uploadChunk()
}
I've noticed that simply posting (arweave.transactions.post
) a transaction to arlocal (without mining the block) makes it available through a GQL search,
e.g. I'm posting a SmartWeave interaction for a contract, load the contract interactions (without calling the arweave.api.get('mine')
) - the interaction is already there, but with block set to null, e.g.
[
{
"node":{
"id":"VVsN7duY7w9q5mMyRytYM7dZSb2_T4ADkAlnH5g9Jh8",
"owner":{
"address":"owSxQ1wSTAY8ZEo4oX5iVdDKjIz7icgBHJYVrT4TwFg"
},
"recipient":"",
"tags":[
{
"name":"App-Name",
"value":"SmartWeaveAction"
},
{
"name":"App-Version",
"value":"0.3.0"
},
{
"name":"SDK",
"value":"RedStone"
},
{
"name":"Contract",
"value":"enYRcGrdFIdU-KXp0MQ-KKgca0aP6j1tIn8qJW_4NXc"
},
{
"name":"Input",
"value":"{\"function\":\"add\"}"
}
],
"block":null,
"fee":{
"winston":"7860528"
},
"quantity":{
"winston":"0"
},
"parent":null,
"bundledIn":null
},
"cursor":"WyIyMDIyLTA2LTA1VDE5OjM0OjI0LjYxMVoiLDFd"
}
]
Tested on ArLocal 1.1.30 and 1.1.38
Query variables:
{
"tags":[
{
"name":"App-Name",
"values":[
"SmartWeaveAction"
]
},
{
"name":"Contract",
"values":[
"WUKD-tJkaPVsFtuQKZjUR3WCE1_90pthjPqKJZwhvxE"
]
}
],
"blockFilter":{
"min":null,
"max":null
},
"first":100
}
Query:
query Transactions($tags: [TagFilter!]!, $blockFilter: BlockFilter!, $first: Int!, $after: String) {
transactions(tags: $tags, block: $blockFilter, first: $first, sort: HEIGHT_ASC, after: $after) {
pageInfo {
hasNextPage
}
edges {
node {
id
owner { address }
recipient
tags {
name
value
}
block {
height
id
timestamp
}
fee { winston }
quantity { winston }
parent { id }
bundledIn { id }
}
cursor
}
}
}
Hey there,
I just learned that it is possible to call the http://localhost:1984/mine
endpoint to simulate the mining of a block, which could have the potential to extend the way we use this tool to test our platform. However I noticed that the number of block mined isn't persistent, even with the persistent
option set to true for new Arweave(...)
, which greatly reduce our use case. Would it be possible to make the information we get at http://localhost:1984/info
persistent?
Using [email protected] on [email protected]:
const arlocal = new ArLocal()
await arlocal.start()
When trying to fetch data using arweave-js
...
// Post transaction
await arweave.transactions.post(tx)
// Mine
await arweave.api.get('mine')
// Get data
await arweave.transactions.getData(tx.id) // <-- throws error
... arlocal throws:
{
error: TypeError: Cannot read properties of undefined (reading 'offset')
at null.<anonymous> (project/node_modules/arlocal/src/routes/transaction.ts:99:33)
at Generator.next (<anonymous>)
at fulfilled (project/node_modules/arlocal/bin/routes/transaction.js:5:58)
}
I've been getting the following SQLite error when posting binary bundle transactions, one for each data-item.
[SQLITE_CONSTRAINT: NOT NULL constraint failed: chunks.data_size] {
errno: 19,
code: 'SQLITE_CONSTRAINT'
}
}
From debugging, the issue is in txPostRoute
when the code tries to create a chunk for these data-item transactions. Data-items don't have data_root
or data_size
. In the transactions
table these data-items have NULL
for data_root
and reference their top-level transaction via bundledIn
field, which does have a data_root
and associated chunks created successfully.
My suggestion is to skip chunk creation if it's a data-item here: https://github.com/textury/arlocal/blob/main/src/routes/transaction.ts#L201
I've tested this locally and will submit a PR
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.