Code Monkey home page Code Monkey logo

hyperledger-labs / blockchain-carbon-accounting Goto Github PK

View Code? Open in Web Editor NEW
186.0 21.0 103.0 264.91 MB

This project implements blockchain applications for climate action and accounting, including emissions calculations, carbon trading, and validation of climate claims. It is part of the Linux Foundation's Hyperledger Climate Action and Accounting SIG.

Home Page: https://wiki.hyperledger.org/display/CASIG/Carbon+Accounting+and+Certification+WG

License: Apache License 2.0

Shell 7.55% JavaScript 13.56% Go 5.06% TypeScript 62.27% Dockerfile 0.27% Solidity 6.40% HTML 2.94% CSS 0.26% Python 1.45% Makefile 0.02% HCL 0.08% Just 0.14%
climate-change climate blockchain blockchain-technology blockchain-network dlt

blockchain-carbon-accounting's Introduction

Hyperledger Labs

Hyperledger Labs provides a space (i.e., GitHub repos) where work can easily be started without the creation of a project. Please refer to the Hyperledger Labs wiki page for additional information.

Process to propose a new lab

  1. Fork the hyperledger-labs.github.io repository.

  2. Fill out the Proposal Template and save it into the labs subdirectory under the name of your lab, such as labs/mynewlab.md. It is expected that your lab repository will have the same name so keep that in mind.

  3. In the Proposal Template, there is an entry for sponsor(s). Although not required, proposers are encouraged to seek a sponsor who can help them create ties with the rest of the Hyperledger community and ensure that the proposal is cogent and novel (in conception, proposed execution, or interested community).

    To find sponsors:

    1. use your connections to existing projects and ask maintainers,
    2. find working groups or projects with affinities to the proposed lab and pitch the project (good to have the template already filled out) in associated channels and/or mailing lists. The WG chairs emails, the maintainers contacts etc can be found on the wiki or github. Make personal appeals if you can. Every repository contains a MAINTAINERS file that lists the current maintainers with their contact information and you can reach them all by posting to the Maintainers list.
  4. Commit your changes with proper sign-off. This means that your commit log message must contain a line that looks like the following one, with your actual name and email address:

     Signed-off-by: John Doe <[email protected]>
    

    Adding the -s flag to your git commit command will add that line automatically. You can also add it manually as part of your commit log message or add it afterwards with git commit --amend -s.

  5. Submit a Pull Request.

The labs stewards will then review your proposal. Like sponsors, stewards do not have a responsibility beyond this; ongoing work like contributing code or reviews is not tied to their role as stewards. In reviewing the proposal, the stewards make sure that the proposal is cogent and novel (in conception, proposed execution, or interested community).

IMPORTANT: It is up to the proposer to ensure that any comments or requested changes by the lab stewards are addressed. Failure to do so may delay the approval of your proposal.

Bringing in an existing repository

By default the Lab stewards will create a new repository for you to start from but if you have an existing github repo you would like to bring to your proposed lab you have the option to request for that repo to be reused instead. This is however only possible if every commit in your existing repo is signed-off so there is no DCO related issues. If that is not the case, you have two options:

  1. bring your code by squashing all of your commits into a single first commit made against your new lab repo with your sign-off.

  2. amend the commit history to include DCO sign-off for each of the commits. The Hyperledger Indy community has documented steps to fix DCO on previous commits. Also, the Fix DCO Guide from src-d contains some different steps you can take.

IMPORTANT: Regardless of which option you use, please be sure that the past committers to your project agree to the DCO.

Archiving

Stewards are responsible for curating the set of labs, archiving (see below) those that become dormant or unresponsive for an extended period (3+ months), or are explicitly deemed by the committers to be deprecated/obsoleted.

Deprecated, obsoleted, or dormant labs (as defined above) will be marked as "archived" in GitHub; that signifies that the lab is no longer maintained. Archived labs are read-only, and they can be moved back out of the archives, if there is interest in reviving them.

License requirement

All Hyperledger software must be made available under an Apache 2.0 license. This applies to Labs. Please, make sure to license all incoming code and new code accordingly, and ensure that all commits are made with proper sign-off so that no DCO related issue is introduced.

Code of Conduct

All Hyperledger community members must adhere to the Code of Conduct.

blockchain-carbon-accounting's People

Contributors

a-5ingh avatar ackintya avatar adityajoshi12 avatar antonyip avatar arezd avatar bhaarat-khatri avatar brioux avatar crypt0legendx avatar dependabot[bot] avatar georgeroman avatar hs2361 avatar jamesondh avatar jwickers avatar ksilkthread avatar lamnd09 avatar michaelbauerinc avatar pavelkrolevets avatar petermetz avatar pihu1998 avatar renovate-bot avatar rybalko avatar ryjones avatar sichen1234 avatar slim-patchy avatar stu01509 avatar udosson avatar zzocker 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blockchain-carbon-accounting's Issues

Get emissions factor for utility

Input:

Utility Number
Thru Date

Output
Utility Emissions Factors from #2

How it works:

Find Utility using #3

With Utility.Divisions
if Division_type=BALANCING_AUTHORITY is available
then Division_type = BALANCING_AUTHORITY
else if Division_type=NERC_REGION is available
then Division_type = NERC_REGION
// could have others here like COUNTRY, STATE_PROVINCE, etc.

Get Utility Emissions Factors from #2 with Division_type and Year of Thru_date

Client applications for emissions

We're currently using opentpas SEAS for connecting utility data to the ledger.

There could and should be other client apps that could connect to the ledger, calculate total emissions, manage offsets, etc.

We should discuss ideas on what these apps should look like and how they should be built.

add renewable energy data to recorded emissions

Based on #2, add the portion of renewable vs non-renewable energy to the utility seed data and the calculated emissions on the ledger:

  1. Add columns DQ (Total Nonrenewable Generation) and DR (Total renewable generation) to the amazon dynamo database of utility data egrid dataloader
  2. In emissions-calculator.js, also calculate:
    2a. renewableEnergyUseAmount = energyUseAmount * Total Renewable Generation/Total Generation
    2b. nonrenewableEnergyUseAmount = energyUseAmount * Total NonRenewable Generation/Total Generation
  3. Store the following data in the ledger:
    3a. renewable energy use amount
    3b. nonrenewable energy use amount
    3c. energy use UOM
    3d. division type: NERC_REGION
    3e. division id value

Cannot start fabric network

After transferring to the hyperldger-labs repository, I've not been able to start the fabric network.

During the transfer binaries were removed to clean it up, but unfortunately it wasn't working any more -- reinstalling binaries got me the mac os x binaries, but the docker containers are ubuntu. So we tried to put binaries back in.

However it's still not working for me:
Terminal Saved Output.txt

problems with storing emissions on goerli from fabric

Trying the http://localhost:9000/api-docs/#/emissionscontract/recordAuditedEmissionsToken to store emissions on goerli from fabric, I noticed a few issues:

  1. Why is this API GET and not PUT?
  2. It should have utilityId and partyId to store only the emissions of one party
  3. The API should display emissionsAmount not energyUseAmount here in the log file:
  4. The quantity of tokens issued is wrong: The emissions amount in from the response is 0.07397955129208716 but on Goerli it shows a quantity of 7000

Screen Shot 2021-02-04 at 1 17 13 PM

Screen Shot 2021-02-04 at 1 18 27 PM

Screen Shot 2021-02-04 at 1 27 07 PM

Unexpected end of JSON input with retrieving emissions records after recent updates

After recent updates, I'm having an "Failed to evaluate transaction: SyntaxError: Unexpected end of JSON input" error after registering the org admin, the user, creating an emissions record, and then trying to retrieve the emissions record.

Screen Shot 2020-09-30 at 5 09 48 PM
Screen Shot 2020-09-30 at 5 09 56 PM
Screen Shot 2020-09-30 at 5 10 34 PM
Screen Shot 2020-09-30 at 5 10 53 PM

To test this, you will need to copy egrid-data-loader/emissions-calc.js to /chaincode/node/lib/ before deploying the chain code.

Unable to POST recordEmissions

Error from peer node

2020-10-26 09:43:59.456 UTC [comm.grpc.server] 1 -> INFO 097 unary call completed grpc.service=discovery.Discovery grpc.method=Discover grpc.peer_address=172.19.0.1:54056 grpc.peer_subject="CN=fabric-common" grpc.code=OK grpc.call_duration=3.095995ms
2020-10-26 09:43:59.575 UTC [comm.grpc.server] 1 -> INFO 098 unary call completed grpc.service=discovery.Discovery grpc.method=Discover grpc.peer_address=172.19.0.1:54056 grpc.peer_subject="CN=fabric-common" grpc.code=OK grpc.call_duration=2.636469ms
2020-10-26 09:44:02.047 UTC [endorser] callChaincode -> INFO 099 finished chaincode: emissionscontract duration: 2420ms channel=utilityemissionchannel txID=d6c2483d
2020-10-26 09:44:02.048 UTC [endorser] SimulateProposal -> ERRO 09a failed to invoke chaincode emissionscontract, error: container exited with 1
github.com/hyperledger/fabric/core/chaincode.(*RuntimeLauncher).Launch.func1
        /go/src/github.com/hyperledger/fabric/core/chaincode/runtime_launcher.go:118
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1373
chaincode registration failed
could not launch chaincode emissionscontract_1.0:0673e1940851448d9f182d24c28b0788f0747ecc16801d7bb33d71fba7aaa69c
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Launch
        /go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:85
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Invoke
        /go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:197
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Execute
        /go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:155
github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
        /go/src/github.com/hyperledger/fabric/core/endorser/support.go:126
github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
        /go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:119
github.com/hyperledger/fabric/core/endorser.(*Endorser).SimulateProposal
        /go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:187
github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposalSuccessfullyOrError
        /go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:397
github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposal
        /go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:340
github.com/hyperledger/fabric/core/handlers/auth/filter.(*expirationCheckFilter).ProcessProposal
        /go/src/github.com/hyperledger/fabric/core/handlers/auth/filter/expiration.go:61
github.com/hyperledger/fabric/core/handlers/auth/filter.(*filter).ProcessProposal
        /go/src/github.com/hyperledger/fabric/core/handlers/auth/filter/filter.go:32
github.com/hyperledger/fabric-protos-go/peer._Endorser_ProcessProposal_Handler.func1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/hyperledger/fabric-protos-go/peer/peer.pb.go:107
github.com/hyperledger/fabric/internal/peer/node.unaryGrpcLimiter.func1
        /go/src/github.com/hyperledger/fabric/internal/peer/node/grpc_limiters.go:51
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
github.com/hyperledger/fabric/common/grpclogging.UnaryServerInterceptor.func1
        /go/src/github.com/hyperledger/fabric/common/grpclogging/server.go:92
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
github.com/hyperledger/fabric/common/grpcmetrics.UnaryServerInterceptor.func1
        /go/src/github.com/hyperledger/fabric/common/grpcmetrics/interceptor.go:31
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
github.com/hyperledger/fabric-protos-go/peer._Endorser_ProcessProposal_Handler
        /go/src/github.com/hyperledger/fabric/vendor/github.com/hyperledger/fabric-protos-go/peer/peer.pb.go:109
google.golang.org/grpc.(*Server).processUnaryRPC
        /go/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1082
google.golang.org/grpc.(*Server).handleStream
        /go/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1405
google.golang.org/grpc.(*Server).serveStreams.func1.1
        /go/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:746
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1373
failed to execute transaction d6c2483dfcc735db341106d9da51c9a5cdf0610931df4cc17fe2757e0cd3a01c
github.com/hyperledger/fabric/core/chaincode.processChaincodeExecutionResult
        /go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:161
github.com/hyperledger/fabric/core/chaincode.(*ChaincodeSupport).Execute
        /go/src/github.com/hyperledger/fabric/core/chaincode/chaincode_support.go:156
github.com/hyperledger/fabric/core/endorser.(*SupportImpl).Execute
        /go/src/github.com/hyperledger/fabric/core/endorser/support.go:126
github.com/hyperledger/fabric/core/endorser.(*Endorser).callChaincode
        /go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:119
github.com/hyperledger/fabric/core/endorser.(*Endorser).SimulateProposal
        /go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:187
github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposalSuccessfullyOrError
        /go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:397
github.com/hyperledger/fabric/core/endorser.(*Endorser).ProcessProposal
        /go/src/github.com/hyperledger/fabric/core/endorser/endorser.go:340
github.com/hyperledger/fabric/core/handlers/auth/filter.(*expirationCheckFilter).ProcessProposal
        /go/src/github.com/hyperledger/fabric/core/handlers/auth/filter/expiration.go:61
github.com/hyperledger/fabric/core/handlers/auth/filter.(*filter).ProcessProposal
        /go/src/github.com/hyperledger/fabric/core/handlers/auth/filter/filter.go:32
github.com/hyperledger/fabric-protos-go/peer._Endorser_ProcessProposal_Handler.func1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/hyperledger/fabric-protos-go/peer/peer.pb.go:107
github.com/hyperledger/fabric/internal/peer/node.unaryGrpcLimiter.func1
        /go/src/github.com/hyperledger/fabric/internal/peer/node/grpc_limiters.go:51
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
github.com/hyperledger/fabric/common/grpclogging.UnaryServerInterceptor.func1
        /go/src/github.com/hyperledger/fabric/common/grpclogging/server.go:92
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
github.com/hyperledger/fabric/common/grpcmetrics.UnaryServerInterceptor.func1
        /go/src/github.com/hyperledger/fabric/common/grpcmetrics/interceptor.go:31
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1
        /go/src/github.com/hyperledger/fabric/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
github.com/hyperledger/fabric-protos-go/peer._Endorser_ProcessProposal_Handler
        /go/src/github.com/hyperledger/fabric/vendor/github.com/hyperledger/fabric-protos-go/peer/peer.pb.go:109
google.golang.org/grpc.(*Server).processUnaryRPC
        /go/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1082
google.golang.org/grpc.(*Server).handleStream
        /go/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:1405
google.golang.org/grpc.(*Server).serveStreams.func1.1
        /go/src/github.com/hyperledger/fabric/vendor/google.golang.org/grpc/server.go:746
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1373 channel=utilityemissionchannel txID=d6c2483d
2020-10-26 09:44:02.048 UTC [comm.grpc.server] 1 -> INFO 09b unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=172.19.0.1:54086 grpc.peer_subject="CN=fabric-common" grpc.code=OK grpc.call_duration=2.424982668s

API response

# RECORDING EMISSIONS DATA TO UTILITYEMISSIONS CHANNEL
OrgName: auditor1
Loaded the network configuration located at /Users/vats/Projects/Hyperledger-Climate_Action_SIG/blockchain-carbon-accounting/utility-emissions-channel/docker-compose-setup/organizations/peerOrganizations/auditor1.carbonAccounting.com/connection-auditor1.json
OrgName: auditor1
+++++++++++++++++ Walletpath: /Users/vats/Projects/Hyperledger-Climate_Action_SIG/blockchain-carbon-accounting/utility-emissions-channel/application/src/blockchain-gateway/wallets/auditor1
Built a file system wallet at /Users/vats/Projects/Hyperledger-Climate_Action_SIG/blockchain-carbon-accounting/utility-emissions-channel/application/src/blockchain-gateway/wallets/auditor1
2020-10-26T09:44:02.073Z - error: [Transaction]: Error: No valid responses from any peers. Errors:
    peer=peer1.auditor2.carbonAccounting.com:8051, status=500, message=error in simulation: failed to execute transaction d6c2483dfcc735db341106d9da51c9a5cdf0610931df4cc17fe2757e0cd3a01c: could not launch chaincode emissionscontract_1.0:0673e1940851448d9f182d24c28b0788f0747ecc16801d7bb33d71fba7aaa69c: chaincode registration failed: container exited with 1
    peer=peer1.auditor1.carbonAccounting.com:7051, status=500, message=error in simulation: failed to execute transaction d6c2483dfcc735db341106d9da51c9a5cdf0610931df4cc17fe2757e0cd3a01c: could not launch chaincode emissionscontract_1.0:0673e1940851448d9f182d24c28b0788f0747ecc16801d7bb33d71fba7aaa69c: chaincode registration failed: container exited with 1
Failed to submit transaction: Error: No valid responses from any peers. Errors:
    peer=peer1.auditor2.carbonAccounting.com:8051, status=500, message=error in simulation: failed to execute transaction d6c2483dfcc735db341106d9da51c9a5cdf0610931df4cc17fe2757e0cd3a01c: could not launch chaincode emissionscontract_1.0:0673e1940851448d9f182d24c28b0788f0747ecc16801d7bb33d71fba7aaa69c: chaincode registration failed: container exited with 1
    peer=peer1.auditor1.carbonAccounting.com:7051, status=500, message=error in simulation: failed to execute transaction d6c2483dfcc735db341106d9da51c9a5cdf0610931df4cc17fe2757e0cd3a01c: could not launch chaincode emissionscontract_1.0:0673e1940851448d9f182d24c28b0788f0747ecc16801d7bb33d71fba7aaa69c: chaincode registration failed: container exited with 1
{ info:
   'Failed to submit transaction: Error: No valid responses from any peers. Errors:\n    peer=peer1.auditor2.carbonAccounting.com:8051, status=500, message=error in simulation: failed to execute transaction d6c2483dfcc735db341106d9da51c9a5cdf0610931df4cc17fe2757e0cd3a01c: could not launch chaincode emissionscontract_1.0:0673e1940851448d9f182d24c28b0788f0747ecc16801d7bb33d71fba7aaa69c: chaincode registration failed: container exited with 1\n    peer=peer1.auditor1.carbonAccounting.com:7051, status=500, message=error in simulation: failed to execute transaction d6c2483dfcc735db341106d9da51c9a5cdf0610931df4cc17fe2757e0cd3a01c: could not launch chaincode emissionscontract_1.0:0673e1940851448d9f182d24c28b0788f0747ecc16801d7bb33d71fba7aaa69c: chaincode registration failed: container exited with 1',
  utilityId: 'ASD',
  partyId: 'ASD123',
  fromDate: '2018-06-01',
  thruDate: '2018-06-30',
  energyUseAmount: 150,
  energyUseUom: 'KWH' }`

replace composite key of emissions records with unique key

I've been thinking about changing the emissions records to use a unique UUID key instead of a composite key like we are now, and instead changing the composite key fields to attributes. This way we could do things in a way that would be compatible with other types of data channels and other types of ledgers (most importantly public ones like ethereum), which could require a single token id but then hold additional data as attributes.

Please let me know if anybody has any suggestions/comments.

Add AWS_REGION in config template

As the title says, currently data loader script does not allow to specify the AWS region for deploying the DynamoDB tables. By default it is set to use 'us-east-1' zone.

I think it will be a good idea to add that config also inside the template. I have taken the note that the code supports adding a config for AWS_REGION and it does look for that setting while creating a connection object but this info is missing inside the template.

implement get list of emissions record

Implement new chain code method to get list of emissions record for utility, customer, and from_date, thru_date range.

It will return a list of the emissions records with from_date > from_date and thru_date < thru_date

calculate CO2 emissions for US Utility

Based on #2 and #3, calculate the CO2 emissions for utility

Input:

  • Utility Number
  • Thru Date
  • Usage
  • Usage_UOM = for example, KWH or MWH
  • Emissions_UOM = Tons

Output:

  • Emissions
  • Division_type

Get Utility Emissions Factors from #12 with Division_type and Year of Thru_date

Calculate Emissions = Utility Emissions Factors.CO2_Equivalent_Emissions / Net_Generation * Usage * (Usage_UOM/Net_Generation_UOM) * (CO2_Equivalent_Emissions_UOM / Emissions_UOM)

Return Emissions, Division_Type

do not allow emissions to be recorded for same time

Do not allow emissions records for the same utility and account to be recorded in overlapping time periods. This means the chain code should check that there are no existing emissions records which have date range (from date to thru date) that contain the new emission record's from date and thru date.

For example, if you've already recorded emissions for utility 11208, account 1234567890, from 2020-09-01 00:00:00 to 2020-09-30 23:59:59, then you cannot record emissions for the same utility and account when it's

  • from 2020-09-10 00:00:00 to 2020-09-15 23:59:59
  • from 2020-08-27 00:00:00 to 2020-09-01 23:59:59
  • from 2020-09-30 00:00:00 to 2020-10-31 23:59:59
  • from 2020-09-01 00:00:01 to 2020-09-30 23:59:58

Private data for emissions record

Calculated from #4 should be stored as private data on the ledger, so that it's available to the company, the emissions auditor, and other authorized parties like customers, regulators, investors.

blockchain explorer container failing with Error: Cannot find module '/opt/explorer/main.js'

internal/modules/cjs/loader.js:638
throw err;
^

Error: Cannot find module '/opt/explorer/main.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Move emissionscontract to separate dir in chaincode

Move emissionscontract to separate dir in the chaincode dir because with the datalock chaincode we start having multiple chaincodes in the same channel. With the restructuring, deployCC.sh and additional dependencies need to be updated as well. The updated structure of the chaincode dir would be as follows:
./chaincode
---/emissionscontract
------/typescript
------/deploy
------/packaging
---/datalock

load utility identifiers into database

Utility_Data_2019_Data_Early_Release.xlsx
Based on the US Energy Information Administration's EIA-861, it seems there are standard utility numbers for each utility. We can use this to set up a lookup table UTILITY_LOOKUP for utilities:

  • Utility_Number
  • Utility_Name
  • State_Province
  • Country
  • Divisions: A Document containing one or more:
  • Division_type
  • Division_id

Load it with the data from the attached spreadshet:

  • Utility_Number = column C
  • Utility_Name = column D
  • State_Province = column E
  • Country = USA
  • Divisions:
  • Division_type = NERC_REGION
  • Division_id = column G value

Later we can add other divisions as they're known for the utility, like their balancing authority.

problem storing European emissions data on Mac OS X

This is happening on Mac OS X but not on Ubuntu. When trying to load the European co2 emissions intensity data, there is an error:
$ node egrid-data-loader.js load_utility_emissions co2-emission-intensity-6.csv Sheet1
Assuming 2019-RES_proxies_EEA.csv has already been imported...
Password:
Cannot get standard output for getUtilityFactor chaincode command
(node:26660) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'substring' of undefined
at getChaincode.then (/Users/sichen/hyperledger/blockchain-carbon-accounting/utility-emissions-channel/docker-compose-setup/egrid-data-loader.js:398:70)
(node:26660) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26660) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

script to reset wallets

During some tasks with the opentaps_seas repo, there has been several times where it would be convenient to have a quick script to reset the wallet data.

I'm not sure if this makes sense to include in networkDown, but having the option in the network script would be a simple and streamline way to verify a fresh slate when working with the fabric network/API.

store raw utility bill data

Find a way to store the raw utility bill data, which could be a PDF of a bill or a Green Button XML document.

It should be encrypted but available for review by authorized parties, for example external regulators, investors, etc.

Python is not set error in startApi.sh script

When starting the express API server as a docker container, we're getting this error:
Screen Shot 2021-01-27 at 11 03 30 AM

It can be fixed by going to
$ cd typescript_app
$ npm install

But it will reappear if you remove your node_modules directory.

It seems the Dockerfile for the docker container is not correctly installing all the dependencies.

create security for REST API

Currently the REST API is not secured. It should be secured with tokens for registering users and performing operations.

create a net emissions channel

Initial implementation of the net emissions channel (https://wiki.hyperledger.org/display/CASIG/Net+Emissions+Data+Channel) with only utility emissions netting out renewable energy certificates and carbon offsets.

We'll return dummy values for REC's of 100 KWH and 0.1 ton for carbon offsets for now. Later we'll hook up other blockchains to get the RECs and offsets.

The tasks would be:

  1. Get the utility emissions for the time period
  2. Re-calculate the net utility emissions adjusted for REC as (utility_emissions_channel.nonrenewable_energy - REC.energy) / utility_emissions_channel.nonrenewable_energy * utility_emissions_channel.emissions
  3. Subtract the carbon offsets from net utility emissions adjusted for REC
  4. Store this as the net emissions

There keys should be entity ID, from date, and thru date. The entity ID will be used to tie the ledger records to an actual entity, ie building, person, company, meter.

Questions about docker-compose

Hi @udosson When you have a moment, could you let me know:

  1. Can we move the application/ folder from utility-emissions-channel/docker-compose-setup/ to utility-emissions-channel/ so it is parallel to chaincode/ and docker-compose-setup? It seems the rest api should work with any chain code set up.

  2. Is there an explorer down with docker compose or how do we stop the explorer?

  3. Does deployCC deploy updated version of chain code? Or do we need to add a version parameter?

set up database and load eGRID database data

Set up a local database (couchdb) with a table for UTILITY_EMISSION_FACTORS with the following fields:

  • Year
  • Country (USA for now, can add others)
  • Division_type (can be BALANCING_AUTHORITY, STATE_PROVINCE, SUBREGION, COUNTRY)
    _ Division_id
  • Division_name
  • Net_Generation
  • Net_Generation_UOM (unit of measure, can be MWH)
  • CO2_Equivalent_Emissions
  • CO2_Equivalent_Emissions_UOM (unit of measure, can be tons)
  • Source

Load data from the EPA eGRID database

Specifically, we can start from the attached spreadsheet from https://www.epa.gov/sites/production/files/2020-01/egrid2018_all_files.zip

It has the following tabs which are useful:

  • ST18: emissions by state (Division_type = STATE_PROVINCE)
  • SRL18: emissions by subregion (Division_type = SUBREGION)
  • NRL18: emissions by NERC region (Divsion_type = NERC_REGION)
  • BA18: emissions by balancing authority (Division_type = BALANCING_AUTHORITY)
  • US18: emissions by country (Division_type = COUNTRY)

We can start with NRL18 for now:

expand utility emissions base data to other regions

Currently we're using the eGRID database from the USA. We'd like to expand utility emissions data to other regions, such as Europe, UK, India, etc. We need help identifying trusted data sets for calculating emissions in those regions.

Get the blockchain network up and running issue

I've found one strange issue, utils in the utility-emissions-channel/docker-compose-setup/bin/ are not linux execute binary files.
For example
bash: ./peer: cannot execute binary file: Exec format error
So I get same utils from
https://github.com/hyperledger/fabric.git
fabric/scripts/fabric-samples/bin/
put them into utility-emissions-channel/docker-compose-setup/bin1/
changed utility-emissions-channel/docker-compose-setup/network.sh to use it
export PATH=${PWD}/bin1:$PATH
and
./network.sh up createChannel
worked after those changes

Store emissions factor data on fabric ledger

Instead of storing emissions factor data in dynamodb or orbitdb, store the emissions factor data directly on fabric ledger. The benefits would be:

  1. Easier installation -- No need to set up either local or cloud based database separately
  2. Emissions factors will be replicated across all nodes
  3. Emissions factors used will be immutably stored and available for later auditing

Add data type field to ledger records to identify if the record is an EMISSIONS_FACTOR or AUDITED_EMISSIONS (or something else eventually)

Initializing data is done by running chain code to store data in ledger as EMISSIONS_FACTOR

Calculating emissions will get data from ledger for EMISSIONS_FACTOR first, then store the calculated results as AUDITED_EMISSIONS.

When storing AUDITED_EMISSIONS, link back to the EMISSIONS_FACTOR record used.

storing documents on document store of the local node

Currently we're storing the documents in amazon s3 which could be local or in the cloud based on the aws-config.js settings

This should be stored in a local file repository instead of the same being used by the entire network. The hash code should be stored on the chain and replicated across the nodes. Then each time a get emissions data record is called, it will retrieve the local copy of the document stored, compare it to the hash code stored on chain. If it is correct it will be returned. If not there will be an error and the emissions record cannot be returned.

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.