Skip to content

Fix/assign network to dvm address string#53

Open
secretnamebasis wants to merge 2 commits into
DEROFDN:community-mainnetfrom
secretnamebasis:fix/assign_network_to_dvm_address_string
Open

Fix/assign network to dvm address string#53
secretnamebasis wants to merge 2 commits into
DEROFDN:community-mainnetfrom
secretnamebasis:fix/assign_network_to_dvm_address_string

Conversation

@secretnamebasis

Copy link
Copy Markdown

Description

ADDRESS_STRING() in DVM-BASIC calls rpc.NewAddressFromKeys(), which cannot itself determine the current network — rpc can't import globals without a circular dependency — so the resulting address always defaulted to mainnet formatting (dero1...) regardless of whether the node is actually running on testnet or as a simulator. This fix explicitly assigns addr.Mainnet = globals.IsMainnet() after construction, so the address string returned inside a contract matches the network it's actually running on.

Verified independently against a simulator-deployed clone of the live FEED contract (e12689bf2e670ab627c90a24cf6d1a3ad0f6eea80a0cc55c32a0af4bc77ce5d0): a testnet signer's own registration key (STORE(ADDRESS_STRING(SIGNER()), ...)) was stored as dero1... instead of the expected deto1..., while the wallet's own GetAddress() correctly returned deto1... for the same key — confirming the mismatch lives in the DVM builtin, not the wallet.

Same fix as deroproject#192 (same author), carried forward here since that PR is still open/unmerged upstream.

Fixes # (no tracked issue number)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This will require a HardFork to be enabled

Which part is impacted?

  • Wallet
  • Daemon
  • Miner
  • Explorer
  • Simulator
  • Misc (documentation, comments, text...)

(dvm is shared by both cmd/derod and cmd/simulator, since the simulator embeds the same DVM interpreter.)

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas (single-line, self-explanatory change; no new comments needed)
  • My changes generate no new warnings

License

I am contributing & releasing the code under DERO Research License (which can be found here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant