profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/EvanJRichard/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Evan Richard EvanJRichard Boston, MA Cryptocurrencies and robotics.

obsidiansystems/ledger-app-avalanche 5

Ledger app providing an AVAX wallet

EvanJRichard/algo-wallet-gui--hackathon-demo 0

Monero: the secure, private, untraceable cryptocurrency

EvanJRichard/assets 0

A comprehensive, up-to-date collection of information about several thousands (!) of crypto tokens.

EvanJRichard/ethdev-class 0

Some standard demonstrations completed as part of a Udemy course in ethereum dev.

EvanJRichard/go-algorand 0

Algorand's official implementation in Go.

EvanJRichard/ledger-app-avalanche 0

Ledger app providing an AVAX wallet

EvanJRichard/msgpack-javascript 0

MessagePack for JavaScript/TypeScript/ECMA-262 / msgpack.org[JavaScript]

EvanJRichard/wallet-core 0

Cross-platform, cross-blockchain wallet library.

push eventEvanJRichard/why_is_v_wrong

Evan Richard

commit sha 536a2ac19afd0e4da31ff06d6679def128b13dd5

Change README.

view details

push time in 2 days

push eventEvanJRichard/why_is_v_wrong

Evan Richard

commit sha 8c202b9a4553f88aa016be15d48c3f039bb96414

Push version that runs.

view details

push time in 2 days

create barnchEvanJRichard/why_is_v_wrong

branch : main

created branch time in 2 days

created repositoryEvanJRichard/why_is_v_wrong

created time in 2 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha fc7d438822b376abdc08add16dc95827f1137d8a

Update expected prompt.

view details

push time in 2 days

create barnchobsidiansystems/ledger-app-avalanche

branch : oct19debug

created branch time in 2 days

push eventobsidiansystems/ledger-app-avalanche

Jean P

commit sha ef80f2e6980832c5b37317d53958fd0a6a19e21c

Merge pull request #10 from obsidiansystems/release/0.5.4 v0.5.4

view details

TamtamHero

commit sha 8621b270f8d0f297f5e30c2fc281bf1ba194ef9a

Bump version 0.5.4

view details

Evan Richard

commit sha 7fbff6a13b36694b58ab530d7480b90d5c5d4db2

Merge branch 'master' into release/0.5.6

view details

push time in 4 days

pull request commentobsidiansystems/ledger-app-avalanche

Remove pk prompt

I'll spin up the VM and run tests to confirm what's up.

EvanJRichard

comment created time in 7 days

PR opened obsidiansystems/ledger-app-avalanche

Reviewers
Remove pk prompt

Summary

Currently when importing accounts into MetaMask, a user must approve the export of addresses and pubkeys again and again. This PR proposes to change that UX, to instead automatically export.

Testing

No unit tests added. Needs QAing at time of writing.

+2 -25

0 comment

1 changed file

pr created time in 7 days

create barnchobsidiansystems/ledger-app-avalanche

branch : remove_pk_prompt

created branch time in 7 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha 2226b6a3d969b2c57ee647175f1208e7a2b3e814

Fix eip1559 parsing (#84) Fixes calculation of fee to use builtin safe overflow math. Fixes bug where checkDataFieldLengthFitsTransaction was sometimes causing transaction parsing to fail. (Removes checkDataFieldLengthFitsTransaction) See also: https://github.com/obsidiansystems/ledger-app-avalanche/pull/84

view details

push time in 7 days

PR merged obsidiansystems/ledger-app-avalanche

Reviewers
Fix eip1559 parsing

Summary

  • Fixes calculation of fee to use builtin safe overflow math.
  • Fixes bug where checkDataFieldLengthFitsTransaction was sometimes causing transaction parsing to fail. (Removes checkDataFieldLengthFitsTransaction)

Testing

Unit tests ran successfully locally. Also, I was able to deploy this app to a FW1.6 device and deploy a smart contract with it through MetaMask, on macOS with a firefox browser.

+27 -12

1 comment

2 changed files

EvanJRichard

pr closed time in 7 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha a10bd547149cf77e418ec13bf69c7e50727b7e2d

Remove tarballs.

view details

push time in 9 days

PR opened obsidiansystems/ledger-app-avalanche

Fix eip1559 parsing

Summary

  • Fixes calculation of fee to use builtin safe overflow math.
  • Fixes bug where checkDataFieldLengthFitsTransaction was sometimes causing transaction parsing to fail. (Removes checkDataFieldLengthFitsTransaction)

Testing

Unit tests ran successfully locally. Also, I was able to deploy this app to a FW1.6 device and deploy a smart contract with it through MetaMask, on macOS with a firefox browser.

+27 -12

0 comment

4 changed files

pr created time in 9 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha 2a0e5a71acf97947339d08dd45df4e3b566dc52f

Fix compile error.

view details

Evan Richard

commit sha c78101765dbff603d0eb2d78b51dda997b3b4711

Fix malformed test.

view details

Evan Richard

commit sha 0485b2cfbc0f9df78c35794ccd79568fb01a4c8a

Run all the tests, not the metamask test only.

view details

Evan Richard

commit sha 8ea1645d48e2686f0c9e07c803ad4204bbc504a1

Use unsafe math for gas calculation, but keep the preliminary overflow check in place.

view details

Evan Richard

commit sha 0382152c2bbbc45f872fa389fbfa8e95b46656d1

Return to using builtin for save overflow math.

view details

Evan Richard

commit sha 5a5a87a5b058ea3096aa97e37e8d0ed90457378f

Add release tars.

view details

push time in 9 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha 5a5a87a5b058ea3096aa97e37e8d0ed90457378f

Add release tars.

view details

push time in 14 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha 0382152c2bbbc45f872fa389fbfa8e95b46656d1

Return to using builtin for save overflow math.

view details

push time in 14 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha c78101765dbff603d0eb2d78b51dda997b3b4711

Fix malformed test.

view details

Evan Richard

commit sha 0485b2cfbc0f9df78c35794ccd79568fb01a4c8a

Run all the tests, not the metamask test only.

view details

Evan Richard

commit sha 8ea1645d48e2686f0c9e07c803ad4204bbc504a1

Use unsafe math for gas calculation, but keep the preliminary overflow check in place.

view details

push time in 14 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha 2a0e5a71acf97947339d08dd45df4e3b566dc52f

Fix compile error.

view details

push time in 14 days

create barnchobsidiansystems/ledger-app-avalanche

branch : fix_eip1559_parsing

created branch time in 14 days

push eventobsidiansystems/ledger-app-avalanche

Evan Richard

commit sha 810c895b9b2ee966243ae07466fa657427750b8f

to-be-reverted: add finish item chunk

view details

Evan Richard

commit sha f78d647a9cd5d719d1967c7e132073fbf698a57c

Merge branch 'metamask-test-case' of github.com:obsidiansystems/ledger-app-avalanche into metamask-test-case

view details

Evan Richard

commit sha 35bfe6a6a17979a6ad44f3d880b5c61caf634ce7

Remove spurious length check. Update fee checking to use overflow math.

view details

push time in 14 days

create barnchEvanJRichard/ledger-app-avalanche

branch : evan/patchfile

created branch time in 15 days

push eventEvanJRichard/ledger-app-avalanche

Evan Richard

commit sha 3a7d4033569ee2ad60b5b12bc6f3ce72abc240d4

Move init_fixed to end of parser.h

view details

push time in 2 months

push eventEvanJRichard/ledger-app-avalanche

Evan Richard

commit sha 9a2f48339b346a44840a271579dd81da9deab8e2

Move impl_fixed(uint8_t) from .c files to a common header for import.

view details

push time in 2 months

Pull request review commentobsidiansystems/ledger-app-avalanche

Support EIP1559-style transactions.

 enum parse_rv parse_rlp_txn(struct EVM_RLP_list_state *const state, evm_parser_m     return sub_rv; } +enum parse_rv parse_eip1559_rlp_txn(struct EVM_RLP_txn_state *const state, evm_parser_meta_state_t *const meta) {+    enum parse_rv sub_rv;+    switch(state->state) {+      case 0: {+          if(meta->input.consumed >= meta->input.length) return PARSE_RV_NEED_MORE;+          uint8_t first = meta->input.src[meta->input.consumed++];+          if(first < 0xc0) REJECT("Transaction not an RLP list");+          if(first < 0xf8) {+              state->remaining = first - 0xc0;+              state->state=2;+          } else {+              state->len_len = first - 0xf7;+              state->state=1;+          }+      }+      case 1:+        if(state->state==1) {+            // Max length we could get for this value is 8 bytes so uint64_state is appropriate.+            sub_rv = parseFixed(((struct FixedState*)&state->uint64_state), &meta->input, state->len_len);+            if(sub_rv != PARSE_RV_DONE) return sub_rv;+            for(size_t i = 0; i < state->len_len; i++) {+                ((uint8_t*)(&state->remaining))[i] = state->uint64_state.buf[state->len_len-i-1];+            }+        }+        init_rlp_item(&state->rlpItem_state);+        state->state = 2;+      case 2: { // Now parse items.+          uint8_t itemStartIdx;+          switch(state->item_index) {+            PARSE_ITEM(EVM_EIP1559_TXN_CHAINID, _to_buffer);++            if(state->rlpItem_state.length != 2+               || state->rlpItem_state.buffer[0] != 0xa8+               || (state->rlpItem_state.buffer[1] != 0x68+                   && state->rlpItem_state.buffer[1] != 0x69+                   && state->rlpItem_state.buffer[1] != 0x6a))+                REJECT("Chain ID incorrect for the Avalanche C chain");+            meta->chainIdLowByte = 0; // explicitly clear chain ID low byte for EIP1559 transactions - only legacy transactions needed to include it++            FINISH_ITEM_CHUNK();++            PARSE_ITEM(EVM_EIP1559_TXN_NONCE, );+            FINISH_ITEM_CHUNK();++            PARSE_ITEM(EVM_EIP1559_TXN_MAX_PRIORITY_FEE_PER_GAS, _to_buffer);+            uint64_t maxFeePerGas = enforceParsedScalarFits64Bits(&state->rlpItem_state);+            size_t maxFeePerGasLength = state->rlpItem_state.length;+            state->priorityFeePerGas = maxFeePerGas;+            FINISH_ITEM_CHUNK();++            PARSE_ITEM(EVM_EIP1559_TXN_MAX_FEE_PER_GAS, _to_buffer);+            uint64_t baseFeePerGas = enforceParsedScalarFits64Bits(&state->rlpItem_state);+            size_t baseFeePerGasLength = state->rlpItem_state.length;+            state->baseFeePerGas = baseFeePerGas;+            FINISH_ITEM_CHUNK();++            PARSE_ITEM(EVM_EIP1559_TXN_GAS_LIMIT, _to_buffer);+            uint64_t gasLimit = enforceParsedScalarFits64Bits(&state->rlpItem_state);+            size_t gasLimitLength = state->rlpItem_state.length;+            state->gasLimit = gasLimit;+            FINISH_ITEM_CHUNK();++            // TODO: We don't currently support the C-chain gas limit of 100 million,+            // which would have a fee larger than what fits in a word+            // possible future improvement: using nanosdk to actually do the overflow-checked gas arithmetic+            if((maxFeePerGasLength > baseFeePerGasLength ? maxFeePerGasLength : baseFeePerGasLength) + gasLimitLength + 1 > 8)+              REJECT("Fee too large");+++            PARSE_ITEM(EVM_EIP1559_TXN_TO, _to_buffer);++            switch (state->rlpItem_state.length) {+            case 0:+              state->hasTo = false;+              break;+            case ETHEREUM_ADDRESS_SIZE:+              state->hasTo = true;+              break;+            default:+              REJECT("When present, destination address must have exactly %u bytes", ETHEREUM_ADDRESS_SIZE);+            }++            if(state->hasTo) {+              for(size_t i = 0; i < NUM_ELEMENTS(precompiled); i++) {+                if(!memcmp(precompiled[i].to, state->rlpItem_state.buffer, ETHEREUM_ADDRESS_SIZE)) {+                  meta->known_destination = &precompiled[i];+                  break;+                }+              }+              if(!meta->known_destination)+                SET_PROMPT_VALUE(memcpy(entry->data.output_prompt.address.val, state->rlpItem_state.buffer, ETHEREUM_ADDRESS_SIZE));+              FINISH_ITEM_CHUNK();+            }+            else {+              FINISH_ITEM_CHUNK();+              static char const label []="Creation";+              set_next_batch_size(&meta->prompt, 2);+              if(({+                  ADD_PROMPT("Contract", label, sizeof(label), strcpy_prompt);+                  SET_PROMPT_VALUE(entry->data.output_prompt.start_gas = state->gasLimit);+                  ADD_ACCUM_PROMPT("Gas Limit", output_evm_gas_limit_to_string);+                }))+                return PARSE_RV_PROMPT;+            }++            PARSE_ITEM(EVM_EIP1559_TXN_VALUE, _to_buffer);++            state->value = enforceParsedScalarFits256Bits(&state->rlpItem_state);+            SET_PROMPT_VALUE(entry->data.output_prompt.amount_big = state->value);++            FINISH_ITEM_CHUNK();++            if(state->hasTo) {+              // As of now, there is no known reason to send AVAX to any precompiled contract we support+              // Given that, we take the less risky action with the intent of protecting from unintended transfers+              if(meta->known_destination) {+                if (!zero256(&state->value))+                  REJECT("Transactions sent to precompiled contracts must have an amount of 0 WEI");+              }+            } else {+              if(!zero256(&state->value))+                if(ADD_ACCUM_PROMPT("Funding Contract", output_evm_fund_to_string)) return PARSE_RV_PROMPT;+            }++            PARSE_ITEM(EVM_EIP1559_TXN_DATA, _data);++            // If data field can't possibly fit in the transaction, the rlp is malformed+            if(state->rlpItem_state.len_len > state->remaining)+              REJECT("Malformed data length. Expected length of length %u", state->rlpItem_state.len_len);++            // If we exhaust the apdu while parsing the length, there's nothing yet to hand to the subparser+            if(state->rlpItem_state.state < 2)+              return sub_rv;++            if(state->hasTo) {+              if(meta->known_destination) {+                if(state->rlpItem_state.do_init && meta->known_destination->init_data)+                  ((known_destination_init)PIC(meta->known_destination->init_data))(&(state->rlpItem_state.endpoint_state), state->rlpItem_state.length);+                PRINTF("INIT: %u\n", state->rlpItem_state.do_init);+                PRINTF("Chunk: [%u] %.*h\n", state->rlpItem_state.chunk.length, state->rlpItem_state.chunk.length, state->rlpItem_state.chunk.src);+                if(meta->known_destination->handle_data) {+                  PRINTF("HANDLING DATA\n");+                  sub_rv = ((known_destination_parser)PIC(meta->known_destination->handle_data))(&(state->rlpItem_state.endpoint_state), &(state->rlpItem_state.chunk), meta);+                }+                PRINTF("PARSER CALLED [sub_rv: %u]\n", sub_rv);+              }+              else {+                struct EVM_RLP_item_state *const item_state = &state->rlpItem_state;+                struct EVM_ABI_state *const abi_state = &item_state->endpoint_state.abi_state;+                if(item_state->do_init)+                  init_abi_call_data(abi_state, item_state->length);++                if(abi_state->data_length == 0) {+                  sub_rv = PARSE_RV_DONE;+                  state->item_index++;+                  init_rlp_item(&state->rlpItem_state);+                  ADD_ACCUM_PROMPT("Transfer", output_evm_prompt_to_string);+                  return PARSE_RV_PROMPT;+                }+                else {+                  sub_rv = parse_abi_call_data(abi_state,+                                               &item_state->chunk,+                                               meta,+                                               !zero256(&state->value));+                }+              }+            }++            // Can't use the FINISH_ITEM_ macro here because we need to do a prompt in the middle of it.+            if(sub_rv != PARSE_RV_DONE) return sub_rv;+            state->item_index++;+            uint64_t len = state->rlpItem_state.length;+            if(!state->hasTo) {+              SET_PROMPT_VALUE(entry->data.output_prompt.calldata_preview.cropped = len > MAX_CALLDATA_PREVIEW);+              SET_PROMPT_VALUE(entry->data.output_prompt.calldata_preview.count = MIN(len, (uint64_t)MAX_CALLDATA_PREVIEW));+              SET_PROMPT_VALUE(memcpy(entry->data.output_prompt.calldata_preview.buffer,+                                      &state->rlpItem_state.buffer,+                                      entry->data.output_prompt.calldata_preview.count));+            }+            state->hasData = len > 0;+            init_rlp_item(&state->rlpItem_state);

Added a couple refactors - some stuff that I initially thought I could extract, I ended up being unable to refactor easily, due to embedded return statements for example. I'll spend a little time looking for more spots to extract.

EvanJRichard

comment created time in 2 months

PullRequestReviewEvent

push eventEvanJRichard/ledger-app-avalanche

Evan Richard

commit sha 4c566b3bdf0784fde6fea6ffdfd0199c1ee070f1

Refactor common calldata handling into shared function.

view details

push time in 2 months

push eventEvanJRichard/ledger-app-avalanche

Evan Richard

commit sha 91c05c7a2dbf52cadce41b069a109b5b31f83407

Refactor evm value parsing into common function.

view details

push time in 2 months

Pull request review commentobsidiansystems/ledger-app-avalanche

Support EIP1559-style transactions.

 const rawUnsignedTransaction = (chainId, unsignedTxParams) => {         bnToRlp(new BN(chainId)),         Buffer.from([]),         Buffer.from([]),-    ]);+    ]);   //  return unsignedTx.getMessageToSign(false);++};++const rawUnsignedEIP1559Transaction = (chainId, unsignedTxParams) => {+  const common = Common.forCustomChain(1, { name: 'avalanche', networkId: 1, chainId }, 'london');++  const unsignedTx = EIP1559Transaction.fromTxData({...unsignedTxParams}, { common });+ ++  // https://github.com/ethereumjs/ethereumjs-monorepo/issues/1188

Unfortunately it breaks calldata tests.

EvanJRichard

comment created time in 2 months

PullRequestReviewEvent