Fabcoin Core  0.16.2
P2P Digital Currency
fascDGP.h
Go to the documentation of this file.
1 #ifndef FASCDGP_H
2 #define FASCDGP_H
3 
4 #include <fasc/fascstate.h>
5 #include <primitives/block.h>
6 #include <validation.h>
7 #include <utilstrencodings.h>
8 
9 static const dev::Address GasScheduleDGP = dev::Address("0000000000000000000000000000000000000080");
10 static const dev::Address BlockSizeDGP = dev::Address("0000000000000000000000000000000000000081");
11 static const dev::Address GasPriceDGP = dev::Address("0000000000000000000000000000000000000082");
12 static const dev::Address DGPCONTRACT4 = dev::Address("0000000000000000000000000000000000000083");
13 static const dev::Address BlockGasLimitDGP = dev::Address("0000000000000000000000000000000000000084");
14 
15 static const uint32_t MIN_BLOCK_SIZE_DGP = 500000;
16 static const uint32_t MAX_BLOCK_SIZE_DGP = 32000000;
17 static const uint32_t DEFAULT_BLOCK_SIZE_DGP = 2000000;
18 
19 static const uint64_t MIN_MIN_GAS_PRICE_DGP = 1;
20 static const uint64_t MAX_MIN_GAS_PRICE_DGP = 10000;
21 static const uint64_t DEFAULT_MIN_GAS_PRICE_DGP = 40;
22 
23 static const uint64_t MIN_BLOCK_GAS_LIMIT_DGP = 1000000;
24 static const uint64_t MAX_BLOCK_GAS_LIMIT_DGP = 1000000000;
25 static const uint64_t DEFAULT_BLOCK_GAS_LIMIT_DGP = 40000000;
26 
27 class FascDGP {
28 
29 public:
30 
31  FascDGP(FascState* _state, bool _dgpevm = true) : dgpevm(_dgpevm), state(_state) {
33  }
34 
35  dev::eth::EVMSchedule getGasSchedule(unsigned int blockHeight);
36 
37  uint32_t getBlockSize(unsigned int blockHeight);
38 
39  uint64_t getMinGasPrice(unsigned int blockHeight);
40 
41  uint64_t getBlockGasLimit(unsigned int blockHeight);
42 
43 private:
44 
45  bool initStorages(const dev::Address& addr, unsigned int blockHeight, std::vector<unsigned char> data = std::vector<unsigned char>());
46 
47  void initStorageDGP(const dev::Address& addr);
48 
49  void initStorageTemplate(const dev::Address& addr);
50 
51  void initDataTemplate(const dev::Address& addr, std::vector<unsigned char>& data);
52 
53  void initDataEIP158();
54 
55  bool checkLimitSchedule(const std::vector<uint32_t>& defaultData, const std::vector<uint32_t>& checkData);
56 
57  void createParamsInstance();
58 
59  dev::Address getAddressForBlock(unsigned int blockHeight);
60 
61  uint64_t getUint64FromDGP(unsigned int blockHeight, const dev::Address& contract, std::vector<unsigned char> data);
62 
63  void parseStorageScheduleContract(std::vector<uint32_t>& uint32Values);
64 
65  void parseDataScheduleContract(std::vector<uint32_t>& uint32Values);
66 
67  void parseStorageOneUint64(uint64_t& blockSize);
68 
69  void parseDataOneUint64(uint64_t& value);
70 
72 
73  void clear();
74 
75 
76 
77  bool dgpevm;
78 
79  const FascState* state;
80 
82 
83  std::map<dev::h256, std::pair<dev::u256, dev::u256>> storageDGP;
84 
85  std::map<dev::h256, std::pair<dev::u256, dev::u256>> storageTemplate;
86 
87  std::vector<unsigned char> dataTemplate;
88 
89  std::vector<std::pair<unsigned int, dev::Address>> paramsInstance;
90 
91  std::vector<uint32_t> dataEIP158Schedule;
92 
93 };
94 #endif
void parseDataScheduleContract(std::vector< uint32_t > &uint32Values)
Definition: fascDGP.cpp:167
std::vector< uint32_t > dataEIP158Schedule
Definition: fascDGP.h:91
dev::Address templateContract
Definition: fascDGP.h:81
bool checkLimitSchedule(const std::vector< uint32_t > &defaultData, const std::vector< uint32_t > &checkData)
Definition: fascDGP.cpp:21
uint64_t getUint64FromDGP(unsigned int blockHeight, const dev::Address &contract, std::vector< unsigned char > data)
Definition: fascDGP.cpp:44
h160 Address
An Ethereum address: 20 bytes.
Definition: Common.h:62
void initDataTemplate(const dev::Address &addr, std::vector< unsigned char > &data)
Definition: fascDGP.cpp:110
void initStorageTemplate(const dev::Address &addr)
Definition: fascDGP.cpp:106
std::vector< std::pair< unsigned int, dev::Address > > paramsInstance
Definition: fascDGP.h:89
uint64_t getBlockGasLimit(unsigned int blockHeight)
Definition: fascDGP.cpp:76
bool dgpevm
Definition: fascDGP.h:77
dev::eth::EVMSchedule getGasSchedule(unsigned int blockHeight)
Definition: fascDGP.cpp:35
std::map< dev::h256, std::pair< dev::u256, dev::u256 > > storageTemplate
Definition: fascDGP.h:85
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Definition: FixedHash.h:47
void clear()
Definition: fascDGP.cpp:243
void parseStorageScheduleContract(std::vector< uint32_t > &uint32Values)
Definition: fascDGP.cpp:141
FascDGP(FascState *_state, bool _dgpevm=true)
Definition: fascDGP.h:31
std::map< dev::h256, std::pair< dev::u256, dev::u256 > > storageDGP
Definition: fascDGP.h:83
std::vector< unsigned char > dataTemplate
Definition: fascDGP.h:87
void parseStorageOneUint64(uint64_t &blockSize)
Definition: fascDGP.cpp:176
void initDataEIP158()
Definition: fascDGP.cpp:3
dev::eth::EVMSchedule createEVMSchedule()
Definition: fascDGP.cpp:189
uint32_t getBlockSize(unsigned int blockHeight)
Definition: fascDGP.cpp:56
dev::Address getAddressForBlock(unsigned int blockHeight)
Definition: fascDGP.cpp:129
bool initStorages(const dev::Address &addr, unsigned int blockHeight, std::vector< unsigned char > data=std::vector< unsigned char >())
Definition: fascDGP.cpp:87
const FascState * state
Definition: fascDGP.h:79
void initStorageDGP(const dev::Address &addr)
Definition: fascDGP.cpp:102
void parseDataOneUint64(uint64_t &value)
Definition: fascDGP.cpp:183
uint8_t const * data
Definition: sha3.h:19
uint64_t getMinGasPrice(unsigned int blockHeight)
Definition: fascDGP.cpp:66
void createParamsInstance()
Definition: fascDGP.cpp:114