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

refactor the bill and gas system #312

Conversation

imotai
Copy link
Contributor

@imotai imotai commented Feb 9, 2023

DB3 token

1 db3 = 1000_000_000 tai

the gas price sheet

gas

1M data will cost 1 db3

create an empty database

assume the encoded database byte size is 100 bytes

gas_fee =     100            +        100 * 1 
              create_db      database meta bytes 

create a database with one collection and one index

assume the encoded database meta byte size is 300 bytes

gas_fee =     100       +         100            +         100         +      300 * 1 
              create_db   create_collection      create_index    database meta bytes 

gas demo

db3>-$ new-db
 database address                           | transaction id 
--------------------------------------------+----------------------------------------------
 0x387ad371e5f25975e3ae269790a5e6b97c48221d | Regf5J88ImEtMPgBklGRMdMMuzWPuynatxYwU9myV4Y= 
db3>-$ new-collection --addr 0x387ad371e5f25975e3ae269790a5e6b97c48221d --name books --index '{"id":1,"name":"idx1","fields":[{"field_path":"name","value_mode":{"Order":1}}]}'
send add collection done!
 tx_id 
----------------------------------------------
 syKcVa7OlXUjeRRp3pqKuJJFgYEaWvYyjMMqcnC80GA= 
db3>-$ new-doc --addr 0x387ad371e5f25975e3ae269790a5e6b97c48221d --collection-name books --documents '{"name": "John Doe","age": 43,"phones": ["+44 1234567","+44 2345678"]}'
send add document done
 transaction id 
----------------------------------------------
 x04b47+hIh+obmqBjB9afSwwV3+4S18vMQLVWq+GN0o= 
db3>-$ show-account
 address                                    | bills        | credits      | storage_used | mutations | session | nonce 
--------------------------------------------+--------------+--------------+--------------+-----------+---------+-------
 0x96bdb8e20fbd831fcb37dde9f81930a82ab5436b | 0.000001 db3 | 9.999999 db3 | 522.00       | 3         | 0       | 0 

Status

  • add network status
  • check the user left credits when checking the transaction
  • add query session gas
  • update the old test cases

@codecov
Copy link

codecov bot commented Feb 9, 2023

Codecov Report

Merging #312 (4d0af86) into main (e6a9bfa) will decrease coverage by 0.54%.
The diff coverage is 65.89%.

@@            Coverage Diff             @@
##             main     #312      +/-   ##
==========================================
- Coverage   62.87%   62.34%   -0.54%     
==========================================
  Files          57       56       -1     
  Lines        6357     5893     -464     
==========================================
- Hits         3997     3674     -323     
+ Misses       2360     2219     -141     
Flag Coverage Δ
rust 62.34% <65.89%> (-0.54%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/cmd/src/keystore.rs 89.33% <0.00%> (-5.04%) ⬇️
src/node/src/abci_impl.rs 0.82% <0.00%> (+0.17%) ⬆️
src/node/src/auth_storage.rs 0.81% <0.00%> (-0.15%) ⬇️
src/node/src/command.rs 39.14% <0.00%> (+0.11%) ⬆️
src/node/src/json_rpc_impl.rs 0.00% <0.00%> (ø)
src/node/src/storage_node_impl.rs 0.63% <0.00%> (+0.14%) ⬆️
src/storage/src/lib.rs 100.00% <ø> (ø)
src/cmd/src/command.rs 67.63% <3.03%> (-6.96%) ⬇️
src/types/src/cost.rs 45.58% <27.90%> (-52.66%) ⬇️
src/storage/src/bill_store.rs 86.20% <63.63%> (+6.61%) ⬆️
... and 23 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@imotai imotai changed the title support querying nonce from node refactor the bill and gas system Feb 13, 2023
@db3fans
Copy link
Collaborator

db3fans commented Feb 13, 2023

This PR exceeds the recommended size of 1200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@db3fans
Copy link
Collaborator

db3fans commented Feb 13, 2023

This PR exceeds the recommended size of 1200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@db3fans
Copy link
Collaborator

db3fans commented Feb 13, 2023

This PR exceeds the recommended size of 1200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@db3fans
Copy link
Collaborator

db3fans commented Feb 14, 2023

This PR exceeds the recommended size of 1200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@db3fans
Copy link
Collaborator

db3fans commented Feb 14, 2023

This PR exceeds the recommended size of 1200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@db3fans
Copy link
Collaborator

db3fans commented Feb 14, 2023

This PR exceeds the recommended size of 1200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@db3fans
Copy link
Collaborator

db3fans commented Feb 14, 2023

This PR exceeds the recommended size of 1200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@db3fans
Copy link
Collaborator

db3fans commented Feb 14, 2023

This PR exceeds the recommended size of 1200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@imotai imotai merged commit 44d160b into main Feb 14, 2023
@imotai imotai deleted the 190-wipadd-a-nonce-chain-id-and-chain-type-to-avoid-the-replay-attack branch February 14, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WIP:add a nonce, chain-id and chain-type to avoid the replay attack
2 participants